diff --git a/packages/@vue/cli-plugin-eslint/generator/index.js b/packages/@vue/cli-plugin-eslint/generator/index.js index b5aa03d342..64688ff34f 100644 --- a/packages/@vue/cli-plugin-eslint/generator/index.js +++ b/packages/@vue/cli-plugin-eslint/generator/index.js @@ -68,7 +68,7 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => { if (lintOn.includes('commit')) { Object.assign(pkg.devDependencies, { - 'lint-staged': '^8.1.5' + 'lint-staged': '^9.4.2' }) pkg.gitHooks = { 'pre-commit': 'lint-staged' @@ -103,12 +103,18 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => { } } -const lint = require('../lint') - +// In PNPM v4, due to their implementation of the module resolution mechanism, +// put require('../lint') in the callback would raise a "Module not found" error, +// But we cannot cache the file outside the callback, +// because the node_module layout may change after the "intall additional dependencies" +// phase, thus making the cached module fail to execute. +// FIXME: at the moment we have to catch the bug and silently fail. Need to fix later. module.exports.hooks = (api) => { // lint & fix after create to ensure files adhere to chosen config api.afterAnyInvoke(() => { - lint({ silent: true }, api) + try { + require('../lint')({ silent: true }, api) + } catch (e) {} }) } diff --git a/packages/@vue/cli-plugin-typescript/generator/index.js b/packages/@vue/cli-plugin-typescript/generator/index.js index 151bfa3020..d2f564dd18 100644 --- a/packages/@vue/cli-plugin-typescript/generator/index.js +++ b/packages/@vue/cli-plugin-typescript/generator/index.js @@ -42,7 +42,7 @@ module.exports = (api, { if (lintOn.includes('commit')) { api.extendPackage({ devDependencies: { - 'lint-staged': '^8.1.5' + 'lint-staged': '^9.4.2' }, gitHooks: { 'pre-commit': 'lint-staged' diff --git a/packages/@vue/cli-ui/package.json b/packages/@vue/cli-ui/package.json index b84b3a31f6..f7c9244103 100644 --- a/packages/@vue/cli-ui/package.json +++ b/packages/@vue/cli-ui/package.json @@ -78,7 +78,7 @@ "cross-env": "^5.1.5", "eslint": "^5.16.0", "eslint-plugin-graphql": "^3.0.3", - "lint-staged": "^8.1.5", + "lint-staged": "^9.4.2", "lodash.debounce": "^4.0.8", "portal-vue": "^1.3.0", "rimraf": "^2.6.2",