fix: should fallback to local eslint, fixes instant prototyping

closes #2866
This commit is contained in:
Haoqun Jiang
2018-11-02 22:44:22 +08:00
parent b1bba2fbae
commit becde3056b
3 changed files with 7 additions and 4 deletions

View File

@@ -6,7 +6,9 @@ module.exports = (api, options) => {
// Use loadModule to allow users to customize their ESLint dependency version.
const { loadModule } = require('@vue/cli-shared-utils')
const cwd = api.getCwd()
const eslintPkg = loadModule('eslint/package.json', cwd, true)
const eslintPkg =
loadModule('eslint/package.json', cwd, true) ||
require('eslint/package.json')
// eslint-loader doesn't bust cache when eslint config changes
// so we have to manually generate a cache identifier that takes the config
@@ -46,7 +48,9 @@ module.exports = (api, options) => {
cacheIdentifier,
emitWarning: options.lintOnSave !== 'error',
emitError: options.lintOnSave === 'error',
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
formatter:
loadModule('eslint/lib/formatters/codeframe', cwd, true) ||
require('eslint/lib/formatters/codeframe')
})
})
}

View File

@@ -21,7 +21,7 @@ module.exports = function lint (args = {}, api) {
const path = require('path')
const cwd = api.resolve('.')
const { log, done, exit, chalk, loadModule } = require('@vue/cli-shared-utils')
const { CLIEngine } = loadModule('eslint', cwd, true)
const { CLIEngine } = loadModule('eslint', cwd, true) || require('eslint')
const extensions = require('./eslintOptions').extensions(api)
const argsConfig = normalizeConfig(args)

View File

@@ -27,7 +27,6 @@
"@vue/cli-service": "^3.1.0",
"babel-eslint": "^10.0.1",
"chalk": "^2.4.1",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0",
"resolve": "^1.8.1",
"vue": "^2.5.17",