Skip to content

Commit b70e0f6

Browse files
committed
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.
1 parent f5a1950 commit b70e0f6

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

packages/@vue/cli-plugin-eslint/generator/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => {
1313
lint: 'vue-cli-service lint'
1414
},
1515
eslintConfig,
16-
devDependencies: {}
16+
devDependencies: {
17+
'eslint': '^5.16.0',
18+
'eslint-plugin-vue': '^5.0.0'
19+
}
20+
}
21+
22+
if (!api.hasPlugin('typescript')) {
23+
pkg.devDependencies['babel-eslint'] = '^10.0.1'
1724
}
1825

1926
const injectEditorConfig = (config) => {

packages/@vue/cli-plugin-eslint/index.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ module.exports = (api, options) => {
66
// Use loadModule to allow users to customize their ESLint dependency version.
77
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
88
const cwd = api.getCwd()
9-
const eslintPkg =
10-
loadModule('eslint/package.json', cwd, true) ||
11-
require('eslint/package.json')
9+
const eslintPkg = loadModule('eslint/package.json', cwd, true)
1210

1311
// eslint-loader doesn't bust cache when eslint config changes
1412
// so we have to manually generate a cache identifier that takes the config
@@ -43,7 +41,7 @@ module.exports = (api, options) => {
4341
.pre()
4442
.exclude
4543
.add(/node_modules/)
46-
.add(require('path').dirname(require.resolve('@vue/cli-service')))
44+
.add(path.dirname(require.resolve('@vue/cli-service')))
4745
.end()
4846
.test(/\.(vue|(j|t)sx?)$/)
4947
.use('eslint-loader')
@@ -55,10 +53,8 @@ module.exports = (api, options) => {
5553
emitWarning: allWarnings,
5654
// only emit errors in production mode.
5755
emitError: allErrors,
58-
eslintPath: resolveModule('eslint', cwd) || require.resolve('eslint'),
59-
formatter:
60-
loadModule('eslint/lib/formatters/codeframe', cwd, true) ||
61-
require('eslint/lib/formatters/codeframe')
56+
eslintPath: resolveModule('eslint', cwd),
57+
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
6258
})
6359
})
6460
}

packages/@vue/cli-plugin-eslint/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"@vue/cli-shared-utils": "^3.7.0",
27-
"babel-eslint": "^10.0.1",
28-
"eslint": "^5.8.0",
26+
"@vue/cli-shared-utils": "^3.6.0",
2927
"eslint-loader": "^2.1.2",
30-
"eslint-plugin-vue": "^5.0.0",
31-
"globby": "^9.0.0",
28+
"globby": "^9.2.0",
3229
"webpack": ">=4 < 4.29"
30+
},
31+
"peerDependencies": {
32+
"eslint": ">= 1.6.0"
3333
}
3434
}

0 commit comments

Comments
 (0)