Skip to content

Commit

Permalink
Merge pull request #98 from github/rename-app-config
Browse files Browse the repository at this point in the history
Rename app config
  • Loading branch information
koddsson committed Mar 19, 2020
2 parents 5711f95 + a9f54ea commit 4128e9c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 45 deletions.
5 changes: 3 additions & 2 deletions bin/eslint-github-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -83,4 +84,4 @@ inquirer.prompt(questions).then(answers => {
prettierConfig.push('')

fs.writeFileSync(path.resolve(process.cwd(), 'prettier.config.js'), prettierConfig.join('\n'), 'utf8')
})
})()
68 changes: 35 additions & 33 deletions bin/github-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
})()
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

0 comments on commit 4128e9c

Please sign in to comment.