Skip to content

Commit 706efd9

Browse files
committed
fix(cli-plugin-eslint): Resolve proper ESLint inside "lintOnSave"
1 parent 1b3741e commit 706efd9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = (api, options) => {
22
if (options.lintOnSave) {
33
const extensions = require('./eslintOptions').extensions(api)
4+
const { loadModule } = require('@vue/cli-shared-utils')
5+
const cwd = api.getCwd()
6+
const eslintPkg = loadModule('eslint/package.json', cwd, true)
47

58
// eslint-loader doesn't bust cache when eslint config changes
69
// so we have to manually generate a cache identifier that takes the config
@@ -9,7 +12,7 @@ module.exports = (api, options) => {
912
'eslint-loader',
1013
{
1114
'eslint-loader': require('eslint-loader/package.json').version,
12-
'eslint': require('eslint/package.json').version
15+
'eslint': eslintPkg.version
1316
},
1417
[
1518
'.eslintrc.js',
@@ -38,7 +41,7 @@ module.exports = (api, options) => {
3841
cacheIdentifier,
3942
emitWarning: options.lintOnSave !== 'error',
4043
emitError: options.lintOnSave === 'error',
41-
formatter: require('eslint/lib/formatters/codeframe')
44+
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
4245
})
4346
})
4447
}

0 commit comments

Comments
 (0)