feat!: require ESLint as a peer dependency (#3852)

BREAKING CHANGE:
Users will have to explicitly list their required ESLint version in the
project's package.json.

The major concern behind this change is that ESLint release schedule is
never aligned with Vue CLI's.
See https://eslint.org/blog/2019/04/eslint-v6.0.0-alpha.0-released
So even if we upgraded our built-in ESLint version to v5, we'll see a
new major release of ESLint in the coming months. Meanwhile we can't
easily upgrade the built-in ESLint version again without bumping our
major version number. This could become a maintenance nightmare.
This commit is contained in:
Haoqun Jiang
2019-04-22 21:01:31 +08:00
parent f5a1950fd2
commit b70e0f6970
3 changed files with 17 additions and 14 deletions

View File

@@ -13,7 +13,14 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => {
lint: 'vue-cli-service lint'
},
eslintConfig,
devDependencies: {}
devDependencies: {
'eslint': '^5.16.0',
'eslint-plugin-vue': '^5.0.0'
}
}
if (!api.hasPlugin('typescript')) {
pkg.devDependencies['babel-eslint'] = '^10.0.1'
}
const injectEditorConfig = (config) => {

View File

@@ -6,9 +6,7 @@ module.exports = (api, options) => {
// Use loadModule to allow users to customize their ESLint dependency version.
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
const cwd = api.getCwd()
const eslintPkg =
loadModule('eslint/package.json', cwd, true) ||
require('eslint/package.json')
const eslintPkg = loadModule('eslint/package.json', cwd, true)
// eslint-loader doesn't bust cache when eslint config changes
// so we have to manually generate a cache identifier that takes the config
@@ -43,7 +41,7 @@ module.exports = (api, options) => {
.pre()
.exclude
.add(/node_modules/)
.add(require('path').dirname(require.resolve('@vue/cli-service')))
.add(path.dirname(require.resolve('@vue/cli-service')))
.end()
.test(/\.(vue|(j|t)sx?)$/)
.use('eslint-loader')
@@ -55,10 +53,8 @@ module.exports = (api, options) => {
emitWarning: allWarnings,
// only emit errors in production mode.
emitError: allErrors,
eslintPath: resolveModule('eslint', cwd) || require.resolve('eslint'),
formatter:
loadModule('eslint/lib/formatters/codeframe', cwd, true) ||
require('eslint/lib/formatters/codeframe')
eslintPath: resolveModule('eslint', cwd),
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
})
})
}

View File

@@ -23,12 +23,12 @@
"access": "public"
},
"dependencies": {
"@vue/cli-shared-utils": "^3.7.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"@vue/cli-shared-utils": "^3.6.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-vue": "^5.0.0",
"globby": "^9.0.0",
"globby": "^9.2.0",
"webpack": ">=4 < 4.29"
},
"peerDependencies": {
"eslint": ">= 1.6.0"
}
}