Skip to content

Commit

Permalink
Merge pull request #3057 from NCI-Agency/enforce-curly-braces-on-sing…
Browse files Browse the repository at this point in the history
…le-line-statements

Add eslint rule for enforcing braces around single line statement body
  • Loading branch information
VassilIordanov authored Jun 12, 2020
2 parents eca01fc + c974b9b commit e4da5a0
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
17 changes: 16 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"build": "NODE_ENV=production webpack --mode production --config config/webpack.client.prod.js",
"start": "export SERVER_URL=${SERVER_URL:-'http://localhost:8080'} DEV_PORT=${DEV_PORT:-3000} ; NODE_ENV=development webpack-dev-server --mode development --open --config config/webpack.client.dev.js",
"lint": "eslint '*.js' 'config/**/*.js' 'platform/**/*.js' 'scripts/**/*.js' 'src/**/*.js' 'stories/**/*.js' 'tests/**/*.js'",
"lint-fix": "prettier --write --no-semi --arrow-parens=avoid '*.js' 'config/**/*.js' 'platform/**/*.js' 'scripts/**/*.js' 'src/**/*.js' 'stories/**/*.js' 'tests/**/*.js' && eslint --fix '*.js' 'config/**/*.js' 'platform/**/*.js' 'scripts/**/*.js' 'src/**/*.js' 'stories/**/*.js' 'tests/**/*.js'",
"lint-fix": "prettier --write '*.js' 'config/**/*.js' 'platform/**/*.js' 'scripts/**/*.js' 'src/**/*.js' 'stories/**/*.js' 'tests/**/*.js' && eslint --fix '*.js' 'config/**/*.js' 'platform/**/*.js' 'scripts/**/*.js' 'src/**/*.js' 'stories/**/*.js' 'tests/**/*.js'",
"test": "echo 'Run \"test-all\" to execute all client-side tests, or pick a specific test target: \"test-jest\", \"test-wdio\", \"test-e2e\".' ; exit 1",
"test-all": "yarn run test-jest && yarn run test-wdio && yarn run test-e2e",
"test-e2e": "export SERVER_URL=${SERVER_URL:-'http://localhost:8180'} ; NODE_ENV=test node $(npm bin)/ava --config ava.config.js",
Expand Down Expand Up @@ -332,7 +332,22 @@
"space-before-function-paren": [
"warn",
"never"
],
"curly": [
"error",
"all"
],
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": false
}
]
}
},
"prettier": {
"arrowParens": "avoid",
"semi": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ const FilterableAdvisorReportsTable = ({ pageDispatchers }) => {
const csv = convertArrayOfObjectsToCSV({
data: args.data
})
if (csv === null) return
if (csv === null) {
return
}

const filename = args.filename || "export-advisor-report.csv"
var blob = new Blob([csv], { type: "text/csv;charset=utf-8;" })
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/CancelledEngagementReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ const ChartByOrg = ({
return []
}
reportsList = reportsList.map(d => {
if (!d.advisorOrg) d.advisorOrg = noAdvisorOrg
if (!d.advisorOrg) {
d.advisorOrg = noAdvisorOrg
}
return d
})
return reportsList
Expand All @@ -97,7 +99,9 @@ const ChartByOrg = ({
return bIndex < 0
? a.advisorOrg.shortName.localeCompare(b.advisorOrg.shortName)
: 1
} else return bIndex < 0 ? -1 : aIndex - bIndex
} else {
return bIndex < 0 ? -1 : aIndex - bIndex
}
})
}, [data])
if (done) {
Expand Down Expand Up @@ -172,7 +176,9 @@ const ChartByReason = ({
return []
}
reportsList = reportsList.map(d => {
if (!d.cancelledReason) d.cancelledReason = "NO_REASON_GIVEN"
if (!d.cancelledReason) {
d.cancelledReason = "NO_REASON_GIVEN"
}
return d
})
return reportsList
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,19 @@ export default class Model {
static listName = null

static fromArray(array) {
if (!array) return []
if (!array) {
return []
}

return array.map(object =>
object instanceof this ? object : new this(object)
)
}

static map(array, func) {
if (!array) return []
if (!array) {
return []
}

return array.map((object, idx) =>
object instanceof this ? func(object, idx) : func(new this(object), idx)
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/PendingApprovalReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ const Chart = ({
return []
}
reportsList = reportsList.map(d => {
if (!d.advisorOrg) d.advisorOrg = noAdvisorOrg
if (!d.advisorOrg) {
d.advisorOrg = noAdvisorOrg
}
return d
})
return reportsList
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/RelatedObjectNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const BaseRelatedObjectNotes = ({
const assessmentJson = JSON.parse(assessment.text)

questions.forEach(question => {
if (!counters[question.id]) counters[question.id] = {}
if (!counters[question.id]) {
counters[question.id] = {}
}
const counter = counters[question.id]
if (assessmentJson[question.id]) {
counter[assessmentJson[question.id]] =
Expand Down
4 changes: 3 additions & 1 deletion client/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ Object.get = function(source, keypath) {
while (keys[0]) {
const key = keys.shift()
source = source[key]
if (source === undefined || source === null) return source
if (source === undefined || source === null) {
return source
}
}
return source
}
Expand Down
8 changes: 6 additions & 2 deletions client/tests/sim/simutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ const fuzzy = {
function randnBm() {
var u = 0
var v = 0
while (u === 0) u = Math.random() // Converting [0,1) to (0,1)
while (v === 0) v = Math.random()
while (u === 0) {
u = Math.random() // Converting [0,1) to (0,1)
}
while (v === 0) {
v = Math.random()
}
return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v)
}
/* eslint-enable no-unused-vars */
Expand Down

0 comments on commit e4da5a0

Please sign in to comment.