忽略GIT预先承诺期间的Eslint错误



我想将eslint与git pre-commit挂钩一起使用,因此它可以自动修复错误(至少可以自动修复(并忽略其他错误,因此它不会阻止提交自己。

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"
  ]
}

您还需要在dependencies中的lint-staged中使用CC_1

最新更新