在 git 预提交期间忽略 eslint 错误
Ignore eslint errors during git pre-commit
我想将 eslint 与 git pre-commit hook 一起使用,这样它可以自动修复错误(至少可以自动修复的错误)并忽略其他错误,所以它不会阻止提交本身。
来自package.json的代码:
"scripts": {
"test-staged": "lint-staged"
},
"pre-commit": [
"test-staged"
],
"lint-staged": {
"*.{js,jsx}": [
"eslint --config=config/.eslintrc --fix",
"git add"
]
}
如何实现?
好的,我认为成功了:
"scripts": {
"eslint-fix-force": "npm run eslint --fix || true",
"test-staged": "lint-staged"
}
"lint-staged": {
"*.{js,jsx}": [
"eslint-fix-force",
"git add"
]
}
你还需要lint-staged
in dependencies
inside package.json
我想将 eslint 与 git pre-commit hook 一起使用,这样它可以自动修复错误(至少可以自动修复的错误)并忽略其他错误,所以它不会阻止提交本身。
来自package.json的代码:
"scripts": {
"test-staged": "lint-staged"
},
"pre-commit": [
"test-staged"
],
"lint-staged": {
"*.{js,jsx}": [
"eslint --config=config/.eslintrc --fix",
"git add"
]
}
如何实现?
好的,我认为成功了:
"scripts": {
"eslint-fix-force": "npm run eslint --fix || true",
"test-staged": "lint-staged"
}
"lint-staged": {
"*.{js,jsx}": [
"eslint-fix-force",
"git add"
]
}
你还需要lint-staged
in dependencies
inside package.json