Skip to content

Commit

Permalink
feat!: require ESLint as a peer dependency (#3852)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sodatea committed Apr 22, 2019
1 parent 282d1f9 commit 42c2b71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 8 additions & 1 deletion packages/@vue/cli-plugin-eslint/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 4 additions & 8 deletions packages/@vue/cli-plugin-eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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)
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@vue/cli-plugin-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
},
"dependencies": {
"@vue/cli-shared-utils": "^3.6.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-vue": "^5.0.0",
"globby": "^9.2.0",
"webpack": ">=4 < 4.29"
},
"peerDependencies": {
"eslint": ">= 1.6.0"
}
}

0 comments on commit 42c2b71

Please sign in to comment.