mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-15 20:00:38 -06:00
fix: fix eslint cwd confusion during onCreateComplete hook execution (#3212)
* fix: fix eslint cwd confusion during onCreateComplete hook execution fixes #2554 fixes #3142 * fix: do not mock process.cwd during invoking
This commit is contained in:
@@ -163,3 +163,18 @@ test('append to existing .editorconfig', async () => {
|
||||
expect(editorconfig).toMatch('root = true')
|
||||
expect(editorconfig).toMatch('[*.{js,jsx,ts,tsx,vue}]')
|
||||
})
|
||||
|
||||
test('airbnb config + typescript + unit-mocha', async () => {
|
||||
await create('eslint-airbnb-typescript', {
|
||||
plugins: {
|
||||
'@vue/cli-plugin-eslint': {
|
||||
config: 'airbnb',
|
||||
lintOn: 'commit'
|
||||
},
|
||||
'@vue/cli-plugin-typescript': {
|
||||
classComponent: true
|
||||
},
|
||||
'@vue/cli-plugin-unit-mocha': {}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -56,7 +56,18 @@ module.exports = function lint (args = {}, api) {
|
||||
? args._
|
||||
: defaultFilesToLint
|
||||
|
||||
// mock process.cwd before executing
|
||||
// See:
|
||||
// https://github.com/vuejs/vue-cli/issues/2554
|
||||
// https://github.com/benmosher/eslint-plugin-import/issues/602
|
||||
// https://github.com/eslint/eslint/issues/11218
|
||||
const processCwd = process.cwd
|
||||
if (!api.invoking) {
|
||||
process.cwd = () => cwd
|
||||
}
|
||||
const report = engine.executeOnFiles(files)
|
||||
process.cwd = processCwd
|
||||
|
||||
const formatter = engine.getFormatter(args.format || 'codeframe')
|
||||
|
||||
if (config.fix) {
|
||||
|
||||
Reference in New Issue
Block a user