Skip to content

fix: fix "lint on commit" projects generation error #4697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/@vue/cli-plugin-eslint/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {}
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-typescript/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down