mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-23 21:40:00 -05:00
fix(cli-plugin-eslint): Resolve proper ESLint package (#2560)
This commit is contained in:
committed by
Haoqun Jiang
parent
38efc032e5
commit
c50051262f
@@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user