mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-14 13:11:10 -05:00
lint prompts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module.exports = (api, { config, lintOnSave, lintOnCommit }) => {
|
||||
module.exports = (api, { config, lintOn }) => {
|
||||
const pkg = {
|
||||
scripts: {
|
||||
lint: 'vue-cli-service lint'
|
||||
@@ -24,13 +24,13 @@ module.exports = (api, { config, lintOnSave, lintOnCommit }) => {
|
||||
pkg.eslintConfig.extends.push('eslint:recommended')
|
||||
}
|
||||
|
||||
if (lintOnSave) {
|
||||
if (lintOn === 'save') {
|
||||
pkg.vue = {
|
||||
lintOnSave: true // eslint-loader configured in runtime plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (lintOnCommit) {
|
||||
if (lintOn === 'commit') {
|
||||
Object.assign(pkg.devDependencies, {
|
||||
'husky': '^0.14.3',
|
||||
'lint-staged': '^6.0.0'
|
||||
@@ -44,6 +44,6 @@ module.exports = (api, { config, lintOnSave, lintOnCommit }) => {
|
||||
api.extendPackage(pkg)
|
||||
|
||||
api.onCreateComplete(() => {
|
||||
// TODO run fix after creation
|
||||
// TODO lint fix
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ module.exports = (api, { lintOnSave }) => {
|
||||
.use('eslint-loader')
|
||||
.loader('eslint-loader')
|
||||
.options({
|
||||
fix: true,
|
||||
formatter: require('eslint/lib/formatters/codeframe')
|
||||
// emitWarnings: ???
|
||||
})
|
||||
|
||||
@@ -1,2 +1,66 @@
|
||||
module.exports = cli => {
|
||||
cli.injectFeature({
|
||||
name: 'Linter',
|
||||
value: 'eslint',
|
||||
short: 'Linter'
|
||||
})
|
||||
|
||||
cli.injectPrompt({
|
||||
name: 'eslintConfig',
|
||||
when: answers => answers.features.includes('eslint'),
|
||||
type: 'list',
|
||||
message: 'Pick a lint config:',
|
||||
choices: [
|
||||
{
|
||||
name: 'ESLint with error prevention only',
|
||||
value: 'base',
|
||||
short: 'Basic'
|
||||
},
|
||||
{
|
||||
name: 'ESLint + Airbnb config',
|
||||
value: 'airbnb',
|
||||
short: 'Airbnb'
|
||||
},
|
||||
{
|
||||
name: 'ESLint + Standard config',
|
||||
value: 'standard',
|
||||
short: 'Standard'
|
||||
},
|
||||
{
|
||||
name: 'ESLint + Prettier',
|
||||
value: 'prettier',
|
||||
short: 'Prettier'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
cli.injectPrompt({
|
||||
name: 'lintOn',
|
||||
message: 'Pick a lint mode:',
|
||||
when: answers => answers.features.includes('eslint'),
|
||||
type: 'list',
|
||||
choices: [
|
||||
{
|
||||
name: 'Lint + fix on save',
|
||||
value: 'save'
|
||||
},
|
||||
{
|
||||
name: 'Lint + fix on commit',
|
||||
value: 'commit'
|
||||
},
|
||||
{
|
||||
name: 'Manually run npm script',
|
||||
value: false
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
cli.onPromptComplete((answers, options) => {
|
||||
if (answers.features.includes('eslint')) {
|
||||
options.plugins['@vue/cli-plugin-eslint'] = {
|
||||
config: answers.eslintConfig,
|
||||
lintOn: answers.lintOn
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
43
yarn.lock
43
yarn.lock
@@ -896,10 +896,6 @@ assert@^1.1.1:
|
||||
dependencies:
|
||||
util "0.10.3"
|
||||
|
||||
assertion-error@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
|
||||
|
||||
astral-regex@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
|
||||
@@ -1919,17 +1915,6 @@ center-align@^0.1.1:
|
||||
align-text "^0.1.3"
|
||||
lazy-cache "^1.0.3"
|
||||
|
||||
chai@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c"
|
||||
dependencies:
|
||||
assertion-error "^1.0.1"
|
||||
check-error "^1.0.1"
|
||||
deep-eql "^3.0.0"
|
||||
get-func-name "^2.0.0"
|
||||
pathval "^1.0.0"
|
||||
type-detect "^4.0.0"
|
||||
|
||||
chalk@2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
|
||||
@@ -1960,10 +1945,6 @@ chardet@^0.4.0:
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
|
||||
|
||||
check-error@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
||||
|
||||
chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
|
||||
@@ -2803,12 +2784,6 @@ dedent@^0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
|
||||
|
||||
deep-eql@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
|
||||
dependencies:
|
||||
type-detect "^4.0.0"
|
||||
|
||||
deep-equal@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
|
||||
@@ -4001,10 +3976,6 @@ get-caller-file@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"
|
||||
|
||||
get-func-name@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
|
||||
|
||||
get-own-enumerable-property-symbols@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-2.0.1.tgz#5c4ad87f2834c4b9b4e84549dc1e0650fb38c24b"
|
||||
@@ -6658,10 +6629,6 @@ path-type@^2.0.0:
|
||||
dependencies:
|
||||
pify "^2.0.0"
|
||||
|
||||
pathval@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"
|
||||
|
||||
pbkdf2@^3.0.3:
|
||||
version "3.0.14"
|
||||
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.14.tgz#a35e13c64799b06ce15320f459c230e68e73bade"
|
||||
@@ -8481,10 +8448,6 @@ type-check@~0.3.2:
|
||||
dependencies:
|
||||
prelude-ls "~1.1.2"
|
||||
|
||||
type-detect@^4.0.0:
|
||||
version "4.0.5"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.5.tgz#d70e5bc81db6de2a381bcaca0c6e0cbdc7635de2"
|
||||
|
||||
type-is@~1.6.15:
|
||||
version "1.6.15"
|
||||
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410"
|
||||
@@ -8858,12 +8821,6 @@ vue-template-es2015-compiler@^1.5.3, vue-template-es2015-compiler@^1.6.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
|
||||
|
||||
vue-test-utils@^1.0.0-beta.9:
|
||||
version "1.0.0-beta.9"
|
||||
resolved "https://registry.yarnpkg.com/vue-test-utils/-/vue-test-utils-1.0.0-beta.9.tgz#bb67c01e2386f85c3ffbceae460b6e785eb7f81a"
|
||||
dependencies:
|
||||
lodash "^4.17.4"
|
||||
|
||||
vue@^2.5.13:
|
||||
version "2.5.13"
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.13.tgz#95bd31e20efcf7a7f39239c9aa6787ce8cf578e1"
|
||||
|
||||
Reference in New Issue
Block a user