From b70e0f6970a89bd29226fc8947f4a69663a6ab8b Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 22 Apr 2019 21:01:31 +0800 Subject: [PATCH] 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. --- packages/@vue/cli-plugin-eslint/generator/index.js | 9 ++++++++- packages/@vue/cli-plugin-eslint/index.js | 12 ++++-------- packages/@vue/cli-plugin-eslint/package.json | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/@vue/cli-plugin-eslint/generator/index.js b/packages/@vue/cli-plugin-eslint/generator/index.js index c2c4fc9c3..8a4b10e23 100644 --- a/packages/@vue/cli-plugin-eslint/generator/index.js +++ b/packages/@vue/cli-plugin-eslint/generator/index.js @@ -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) => { diff --git a/packages/@vue/cli-plugin-eslint/index.js b/packages/@vue/cli-plugin-eslint/index.js index a93c459d3..5e09be065 100644 --- a/packages/@vue/cli-plugin-eslint/index.js +++ b/packages/@vue/cli-plugin-eslint/index.js @@ -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) }) }) } diff --git a/packages/@vue/cli-plugin-eslint/package.json b/packages/@vue/cli-plugin-eslint/package.json index 50cb63fd8..5c6ddcf9d 100644 --- a/packages/@vue/cli-plugin-eslint/package.json +++ b/packages/@vue/cli-plugin-eslint/package.json @@ -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" } }