Last active
March 24, 2018 20:51
-
-
Save Akryum/e303a8294f25096e70d741f4b6c66e15 to your computer and use it in GitHub Desktop.
@vue/cli-ui plugin API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @vue/cli-plugin-eslint/ui.js | |
module.exports = api => { | |
// Config file | |
api.describeConfig({ | |
name: 'ESLint configuration', | |
description: 'Error checking & Code quality', | |
link: 'https://eslint.org', | |
files: { | |
json: ['eslintrc', 'eslintrc.json'], | |
js: ['eslintrc.js'], | |
package: 'eslintConfig' | |
}, | |
onRead: ({ data }) => { | |
return { | |
prompts: [ | |
{ | |
name: 'rules.commaDangle', | |
type: 'list', | |
message: 'Trailing commas', | |
description: 'Enforce or disallow trailing commas at the end of the lines', | |
link: 'https://eslint.org/docs/rules/comma-dangle', | |
choices: [ | |
{ | |
name: 'Off', | |
value: 'off' | |
}, | |
{ | |
name: 'Never', | |
value: JSON.stringify(['error', 'never']) | |
}, | |
{ | |
name: 'Always', | |
value: JSON.stringify(['error', 'always']) | |
}, | |
{ | |
name: 'Always on multiline', | |
value: JSON.stringify(['error', 'always-multiline']) | |
}, | |
{ | |
name: 'Only on multiline', | |
value: JSON.stringify(['error', 'only-multiline']) | |
} | |
], | |
value: JSON.stringify(data.rules['comma-dangle'] || ['error', 'never']) | |
} | |
] | |
} | |
}, | |
onWrite: ({ file, answers }) => { | |
file.assignData({ | |
'rules.comma-dangle': answers.rules.commaDangle | |
}) | |
} | |
}) | |
// Tasks | |
api.describeTask({ | |
match: /vue-cli-service lint/, | |
description: 'Lints and fixes files', | |
link: 'https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint#injected-commands', | |
prompts: [ | |
{ | |
name: 'noFix', | |
type: 'confirm', | |
default: false, | |
description: 'Do not fix errors' | |
} | |
], | |
onRun: ({ answers, args }) => { | |
if (answers.noFix) { | |
args.push('no-fix') | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment