Skip to content

Commit 7fed0c8

Browse files
committed
fix: fix eslint cwd confusion during onCreateComplete hook execution
fixes vuejs#2554 fixes vuejs#3142
1 parent 0ecbb70 commit 7fed0c8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,18 @@ test('should not throw when src folder is ignored by .eslintignore', async () =>
139139
// should not throw
140140
await run('vue-cli-service lint')
141141
})
142+
143+
test('airbnb config + typescript + unit-mocha', async () => {
144+
await create('eslint-airbnb-typescript', {
145+
plugins: {
146+
'@vue/cli-plugin-eslint': {
147+
config: 'airbnb',
148+
lintOn: 'commit'
149+
},
150+
'@vue/cli-plugin-typescript': {
151+
classComponent: true
152+
},
153+
'@vue/cli-plugin-unit-mocha': {}
154+
}
155+
})
156+
})

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ module.exports = function lint (args = {}, api) {
5656
? args._
5757
: defaultFilesToLint
5858

59+
// mock process.cwd before executing
60+
// See:
61+
// https://github.com/vuejs/vue-cli/issues/2554
62+
// https://github.com/benmosher/eslint-plugin-import/issues/602
63+
// https://github.com/eslint/eslint/issues/11218
64+
const processCwd = process.cwd
65+
process.cwd = () => cwd
5966
const report = engine.executeOnFiles(files)
67+
process.cwd = processCwd
68+
6069
const formatter = engine.getFormatter(args.format || 'codeframe')
6170

6271
if (config.fix) {

0 commit comments

Comments
 (0)