Skip to content

Commit 70abdb8

Browse files
committed
fix github/no-then violations
1 parent 6b23802 commit 70abdb8

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed

bin/eslint-github-init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const questions = [
4747
}
4848
]
4949

50-
inquirer.prompt(questions).then(answers => {
50+
for (const answers of inquirer.prompt(questions)) {
5151
const eslintrc = {extends: ['plugin:github/es6']}
5252

5353
if (answers.project === 'app') {
@@ -83,4 +83,4 @@ inquirer.prompt(questions).then(answers => {
8383
prettierConfig.push('')
8484

8585
fs.writeFileSync(path.resolve(process.cwd(), 'prettier.config.js'), prettierConfig.join('\n'), 'utf8')
86-
})
86+
}

bin/github-lint.js

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,50 @@ function execFile(command, args) {
1717
})
1818
}
1919

20-
;(async function() {
21-
let runs = 0
22-
const codes = []
23-
const commands = []
20+
try {
21+
;(async function() {
22+
let runs = 0
23+
const codes = []
24+
const commands = []
2425

25-
let eslintOptions = ['--report-unused-disable-directives', '.']
26+
let eslintOptions = ['--report-unused-disable-directives', '.']
2627

27-
if (hasBasicColorSupport) {
28-
eslintOptions = eslintOptions.concat(['--color'])
29-
}
28+
if (hasBasicColorSupport) {
29+
eslintOptions = eslintOptions.concat(['--color'])
30+
}
3031

31-
const isTypeScriptProject = fs.existsSync('tsconfig.json')
32+
const isTypeScriptProject = fs.existsSync('tsconfig.json')
3233

33-
if (isTypeScriptProject) {
34-
eslintOptions = eslintOptions.concat(['--ext', '.js,.ts,.tsx'])
35-
}
34+
if (isTypeScriptProject) {
35+
eslintOptions = eslintOptions.concat(['--ext', '.js,.ts,.tsx'])
36+
}
3637

37-
commands.push(['eslint', eslintOptions])
38+
commands.push(['eslint', eslintOptions])
3839

39-
if (isTypeScriptProject) {
40-
commands.push(['tsc', ['--noEmit']])
41-
}
40+
if (isTypeScriptProject) {
41+
commands.push(['tsc', ['--noEmit']])
42+
}
4243

43-
for (const [command, args] of commands) {
44-
if (runs > 0) process.stderr.write('\n')
45-
process.stderr.write(`> ${command} ${args.join(' ')}\n`)
44+
for (const [command, args] of commands) {
45+
if (runs > 0) process.stderr.write('\n')
46+
process.stderr.write(`> ${command} ${args.join(' ')}\n`)
4647

47-
const {code, stdout, stderr} = await execFile(command, args)
48-
codes.push(code)
49-
if (stderr) process.stderr.write(stderr)
50-
if (stdout) process.stdout.write(stdout)
48+
const {code, stdout, stderr} = await execFile(command, args)
49+
codes.push(code)
50+
if (stderr) process.stderr.write(stderr)
51+
if (stdout) process.stdout.write(stdout)
5152

52-
runs++
53-
}
53+
runs++
54+
}
5455

55-
const nonzero = codes.find(code => code !== 0)
56-
if (nonzero) {
57-
process.stderr.write(`\nCommand failed: ${nonzero}\n`)
58-
process.exit(nonzero)
59-
}
60-
})().catch(error => {
56+
const nonzero = codes.find(code => code !== 0)
57+
if (nonzero) {
58+
process.stderr.write(`\nCommand failed: ${nonzero}\n`)
59+
process.exit(nonzero)
60+
}
61+
})
62+
} catch (error) {
6163
setTimeout(() => {
6264
throw error
6365
})
64-
})
66+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ function run() {
1212
process.stdout.write(`1..${checks.length}\n`)
1313
for (const [count, name, callback] of checks) {
1414
Promise.resolve()
15+
// eslint-disable-next-line github/no-then
1516
.then(callback)
17+
// eslint-disable-next-line github/no-then
1618
.then(() => {
1719
process.stdout.write(`ok ${count} - ${name}\n`)
1820
})
21+
// eslint-disable-next-line github/no-then
1922
.catch(error => {
2023
process.stdout.write(`not ok ${count} - ${name}\n ${error}\n`)
2124
})

0 commit comments

Comments
 (0)