Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/eslint-github-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const questions = [
}
]

inquirer.prompt(questions).then(answers => {
for (const answers of inquirer.prompt(questions)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need an await?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, this was supposed to be a await/async conversion and not a for-of one.

const eslintrc = {extends: ['plugin:github/es6']}

if (answers.project === 'app') {
Expand Down Expand Up @@ -83,4 +83,4 @@ inquirer.prompt(questions).then(answers => {
prettierConfig.push('')

fs.writeFileSync(path.resolve(process.cwd(), 'prettier.config.js'), prettierConfig.join('\n'), 'utf8')
})
}
66 changes: 34 additions & 32 deletions bin/github-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,50 @@ function execFile(command, args) {
})
}

;(async function() {
let runs = 0
const codes = []
const commands = []
try {
;(async function() {
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)
}
})().catch(error => {
const nonzero = codes.find(code => code !== 0)
if (nonzero) {
process.stderr.write(`\nCommand failed: ${nonzero}\n`)
process.exit(nonzero)
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. There needs to be parens to call this function

} catch (error) {
setTimeout(() => {
throw error
})
})
}
3 changes: 3 additions & 0 deletions bin/npm-check-github-package-requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
})
Expand Down
8 changes: 2 additions & 6 deletions docs/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions lib/configs/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand Down
4 changes: 1 addition & 3 deletions lib/configs/app.js → lib/configs/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
}
1 change: 1 addition & 0 deletions lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down