fix(cli-plugin-eslint): Resolve proper ESLint package (#2560)

This commit is contained in:
Michał Sajnóg
2018-10-29 12:15:46 +01:00
committed by Haoqun Jiang
parent 38efc032e5
commit c50051262f
2 changed files with 7 additions and 4 deletions
+5 -2
View File
@@ -3,6 +3,9 @@ const path = require('path')
module.exports = (api, options) => {
if (options.lintOnSave) {
const extensions = require('./eslintOptions').extensions(api)
const { loadModule } = require('@vue/cli-shared-utils')
const cwd = api.getCwd()
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
@@ -11,7 +14,7 @@ module.exports = (api, options) => {
'eslint-loader',
{
'eslint-loader': require('eslint-loader/package.json').version,
'eslint': require('eslint/package.json').version
'eslint': eslintPkg.version
},
[
'.eslintrc.js',
@@ -42,7 +45,7 @@ module.exports = (api, options) => {
cacheIdentifier,
emitWarning: options.lintOnSave !== 'error',
emitError: options.lintOnSave === 'error',
formatter: require('eslint/lib/formatters/codeframe')
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
})
})
}
+2 -2
View File
@@ -28,8 +28,8 @@ const defaultFilesToLint = [
module.exports = function lint (args = {}, api) {
const path = require('path')
const cwd = api.resolve('.')
const { CLIEngine } = require('eslint')
const { log, done, exit, chalk } = require('@vue/cli-shared-utils')
const { log, done, exit, chalk, loadModule } = require('@vue/cli-shared-utils')
const { CLIEngine } = loadModule('eslint', cwd, true)
const extensions = require('./eslintOptions').extensions(api)
const argsConfig = normalizeConfig(args)