Skip to content

Commit 3a0caa6

Browse files
committed
fix: require.resolve eslint parser
1 parent 40a6684 commit 3a0caa6

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Diff for: packages/@vue/cli-plugin-eslint/eslintOptions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.config = (api, preset, rootOptions = {}) => {
1414

1515
if (api.hasPlugin('babel') && !api.hasPlugin('typescript')) {
1616
config.parserOptions = {
17-
parser: 'babel-eslint'
17+
parser: makeJSOnlyValue(`require.resolve('babel-eslint')`)
1818
}
1919
}
2020

@@ -59,6 +59,7 @@ function makeJSOnlyValue (str) {
5959
fn.__expression = str
6060
return fn
6161
}
62+
exports.makeJSOnlyValue = makeJSOnlyValue
6263

6364
const baseExtensions = ['.js', '.jsx', '.vue']
6465
exports.extensions = api => api.hasPlugin('typescript')

Diff for: packages/@vue/cli-plugin-eslint/generator/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module.exports.applyTS = api => {
9797
eslintConfig: {
9898
extends: ['@vue/typescript'],
9999
parserOptions: {
100-
parser: '@typescript-eslint/parser'
100+
parser: require('../eslintOptions').makeJSOnlyValue(`require.resolve('@typescript-eslint/parser')`)
101101
}
102102
},
103103
devDependencies: require('../eslintDeps').DEPS_MAP.typescript

Diff for: packages/@vue/cli/lib/Generator.js

+5
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ module.exports = class Generator {
219219
// project-wide configuration even to dependencies.
220220
// TODO: this can be removed when Babel supports root: true in package.json
221221
extract('babel')
222+
223+
// Always extract .eslintrc.js as the parser needs to be require.resolve'ed
224+
// since ESLint doesn't resolve things from where it's declared
225+
// TODO: this can be removed when ESLint starts resolving things correctly
226+
extract('eslint')
222227
}
223228
}
224229

0 commit comments

Comments
 (0)