Skip to content

Commit 054b28d

Browse files
committed
fix prefer-for-of violations
1 parent 351ff5e commit 054b28d

4 files changed

+16
-16
lines changed

bin/eslint-ignore-errors.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ const fs = require('fs')
1111
const execFile = require('child_process').execFile
1212

1313
execFile('eslint', ['--format', 'json', process.argv[2]], (error, stdout) => {
14-
JSON.parse(stdout).forEach(result => {
14+
for (const result of JSON.parse(stdout)) {
1515
const filename = result.filePath
1616
const jsLines = fs.readFileSync(filename, 'utf8').split('\n')
1717
const offensesByLine = {}
1818
let addedLines = 0
1919

2020
// Produces {47: ['github/no-d-none', 'github/no-blur'], 83: ['github/no-blur']}
21-
result.messages.forEach(message => {
21+
for (const message of result.messages) {
2222
if (offensesByLine[message.line]) {
2323
offensesByLine[message.line].push(message.ruleId)
2424
} else {
2525
offensesByLine[message.line] = [message.ruleId]
2626
}
27-
})
27+
}
2828

29-
Object.keys(offensesByLine).forEach(line => {
29+
for (const line of Object.keys(offensesByLine)) {
3030
const lineIndex = line - 1 + addedLines
3131
const previousLine = jsLines[lineIndex - 1]
3232
const ruleIds = offensesByLine[line].join(', ')
@@ -37,12 +37,12 @@ execFile('eslint', ['--format', 'json', process.argv[2]], (error, stdout) => {
3737
jsLines.splice(lineIndex, 0, `${leftPad}/* eslint-disable-next-line ${ruleIds} */`)
3838
}
3939
addedLines += 1
40-
})
40+
}
4141

4242
if (result.messages.length !== 0) {
4343
fs.writeFileSync(filename, jsLines.join('\n'), 'utf8')
4444
}
45-
})
45+
}
4646
})
4747

4848
function isDisableComment(line) {

bin/npm-check-github-package-requirements.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function check(name, callback) {
1010

1111
function run() {
1212
process.stdout.write(`1..${checks.length}\n`)
13-
checks.forEach(([count, name, callback]) => {
13+
for (const [count, name, callback] of checks) {
1414
Promise.resolve()
1515
.then(callback)
1616
.then(() => {
@@ -19,7 +19,7 @@ function run() {
1919
.catch(error => {
2020
process.stdout.write(`not ok ${count} - ${name}\n ${error}\n`)
2121
})
22-
})
22+
}
2323
}
2424

2525
const packageRoot = process.argv[2]

lib/rules/js-class-name.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ module.exports = {
1111

1212
function checkStringFormat(node, str) {
1313
const matches = str.match(allJsClassNameRegexp) || []
14-
matches.forEach(function(match) {
14+
for (const match of matches) {
1515
if (!match.match(validJsClassNameRegexp)) {
1616
context.report(node, 'js- class names should be lowercase and only contain dashes.')
1717
}
18-
})
18+
}
1919
}
2020

2121
function checkStringEndsWithJSClassName(node, str) {
@@ -40,13 +40,13 @@ module.exports = {
4040
}
4141
},
4242
TemplateLiteral(node) {
43-
node.quasis.forEach(function(quasi) {
43+
for (const quasi of node.quasis) {
4444
checkStringFormat(quasi, quasi.value.raw)
4545

4646
if (quasi.tail === false) {
4747
checkStringEndsWithJSClassName(quasi, quasi.value.raw)
4848
}
49-
})
49+
}
5050
}
5151
}
5252
}

lib/rules/no-implicit-buggy-globals.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ module.exports = {
99
Program() {
1010
const scope = context.getScope()
1111

12-
scope.variables.forEach(function(variable) {
12+
for (const variable of scope.variables) {
1313
if (variable.writeable) {
1414
return
1515
}
1616

17-
variable.defs.forEach(function(def) {
17+
for (const def of variable.defs) {
1818
if (
1919
def.type === 'FunctionName' ||
2020
def.type === 'ClassName' ||
@@ -23,8 +23,8 @@ module.exports = {
2323
) {
2424
context.report(def.node, 'Implicit global variable, assign as global property instead.')
2525
}
26-
})
27-
})
26+
}
27+
}
2828
}
2929
}
3030
}

0 commit comments

Comments
 (0)