diff --git a/bin/eslint-github-init.js b/bin/eslint-github-init.js index 7300b273..7a70377d 100755 --- a/bin/eslint-github-init.js +++ b/bin/eslint-github-init.js @@ -47,7 +47,8 @@ const questions = [ } ] -inquirer.prompt(questions).then(answers => { +;(async function() { + const answers = await inquirer.prompt(questions) const eslintrc = {extends: ['plugin:github/es6']} if (answers.project === 'app') { @@ -83,4 +84,4 @@ inquirer.prompt(questions).then(answers => { prettierConfig.push('') fs.writeFileSync(path.resolve(process.cwd(), 'prettier.config.js'), prettierConfig.join('\n'), 'utf8') -}) +})() diff --git a/bin/github-lint.js b/bin/github-lint.js index 820cecd3..76f8df21 100755 --- a/bin/github-lint.js +++ b/bin/github-lint.js @@ -18,47 +18,49 @@ function execFile(command, args) { } ;(async function() { - let runs = 0 - const codes = [] - const commands = [] + try { + let runs = 0 + const codes = [] + const commands = [] - let eslintOptions = ['--report-unused-disable-directives', '.'] + let eslintOptions = ['--report-unused-disable-directives', '.'] - if (hasBasicColorSupport) { - eslintOptions = eslintOptions.concat(['--color']) - } + if (hasBasicColorSupport) { + eslintOptions = eslintOptions.concat(['--color']) + } - const isTypeScriptProject = fs.existsSync('tsconfig.json') + const isTypeScriptProject = fs.existsSync('tsconfig.json') - if (isTypeScriptProject) { - eslintOptions = eslintOptions.concat(['--ext', '.js,.ts,.tsx']) - } + if (isTypeScriptProject) { + eslintOptions = eslintOptions.concat(['--ext', '.js,.ts,.tsx']) + } - commands.push(['eslint', eslintOptions]) + commands.push(['eslint', eslintOptions]) - if (isTypeScriptProject) { - commands.push(['tsc', ['--noEmit']]) - } + if (isTypeScriptProject) { + commands.push(['tsc', ['--noEmit']]) + } - for (const [command, args] of commands) { - if (runs > 0) process.stderr.write('\n') - process.stderr.write(`> ${command} ${args.join(' ')}\n`) + for (const [command, args] of commands) { + if (runs > 0) process.stderr.write('\n') + process.stderr.write(`> ${command} ${args.join(' ')}\n`) - const {code, stdout, stderr} = await execFile(command, args) - codes.push(code) - if (stderr) process.stderr.write(stderr) - if (stdout) process.stdout.write(stdout) + const {code, stdout, stderr} = await execFile(command, args) + codes.push(code) + if (stderr) process.stderr.write(stderr) + if (stdout) process.stdout.write(stdout) - runs++ - } + runs++ + } - const nonzero = codes.find(code => code !== 0) - if (nonzero) { - process.stderr.write(`\nCommand failed: ${nonzero}\n`) - process.exit(nonzero) + const nonzero = codes.find(code => code !== 0) + if (nonzero) { + process.stderr.write(`\nCommand failed: ${nonzero}\n`) + process.exit(nonzero) + } + } catch (error) { + setTimeout(() => { + throw error + }) } -})().catch(error => { - setTimeout(() => { - throw error - }) -}) +})() diff --git a/bin/npm-check-github-package-requirements.js b/bin/npm-check-github-package-requirements.js index 88c9aa41..236d266c 100755 --- a/bin/npm-check-github-package-requirements.js +++ b/bin/npm-check-github-package-requirements.js @@ -12,10 +12,13 @@ function run() { process.stdout.write(`1..${checks.length}\n`) for (const [count, name, callback] of checks) { Promise.resolve() + // eslint-disable-next-line github/no-then .then(callback) + // eslint-disable-next-line github/no-then .then(() => { process.stdout.write(`ok ${count} - ${name}\n`) }) + // eslint-disable-next-line github/no-then .catch(error => { process.stdout.write(`not ok ${count} - ${name}\n ${error}\n`) }) diff --git a/docs/configs.md b/docs/configs.md index 19ba9353..e2667608 100644 --- a/docs/configs.md +++ b/docs/configs.md @@ -22,10 +22,6 @@ $ node_modules/.bin/eslint-github-init A base layer of configuration recommended for any JS project. The [Prettier](https://prettier.io/) formatter is used to format code. -### `plugin:github/es6` +### `plugin:github/internal` -Recommended rules when using Babel to transpile features from ES2015+. - -### `plugin:github/app` - -Recommended rules when writing a browser application. +Recommended rules when writing a internal GitHub app. diff --git a/lib/configs/browser.js b/lib/configs/browser.js index aceab841..f236b75b 100644 --- a/lib/configs/browser.js +++ b/lib/configs/browser.js @@ -8,6 +8,7 @@ module.exports = { 'github/async-preventdefault': 'error', 'github/get-attribute': 'error', 'github/no-blur': 'error', + 'github/no-dataset': 'error', 'github/no-innerText': 'error', 'github/unescaped-html-literal': 'error' }, diff --git a/lib/configs/app.js b/lib/configs/internal.js similarity index 68% rename from lib/configs/app.js rename to lib/configs/internal.js index 92a4fc6d..20ac1486 100644 --- a/lib/configs/app.js +++ b/lib/configs/internal.js @@ -3,9 +3,7 @@ module.exports = { rules: { 'github/authenticity-token': 'error', 'github/js-class-name': 'error', - 'github/no-d-none': 'error', - 'github/no-dataset': 'error', - 'github/no-then': 'error' + 'github/no-d-none': 'error' }, extends: [require.resolve('./recommended'), require.resolve('./browser')] } diff --git a/lib/configs/recommended.js b/lib/configs/recommended.js index 43bc3fbc..c164a398 100644 --- a/lib/configs/recommended.js +++ b/lib/configs/recommended.js @@ -21,6 +21,7 @@ module.exports = { 'func-style': ['error', 'declaration', {allowArrowFunctions: true}], 'github/array-foreach': 'error', 'github/no-implicit-buggy-globals': 'error', + 'github/no-then': 'error', 'import/default': 'error', 'import/export': 'error', 'import/first': 'error', diff --git a/lib/index.js b/lib/index.js index e0a4c486..db2f060a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ module.exports = { 'unescaped-html-literal': require('./rules/unescaped-html-literal') }, configs: { - app: require('./configs/app'), + internal: require('./configs/internal'), browser: require('./configs/browser'), recommended: require('./configs/recommended'), typescript: require('./configs/typescript')