【问题标题】:Ignore eslint errors during git pre-commit在 git 预提交期间忽略 eslint 错误
【发布时间】:2017-11-01 03:52:41
【问题描述】:

我想将 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"
  ]
}

我怎样才能实现它?

【问题讨论】:

    标签: javascript git eslint package.json pre-commit-hook


    【解决方案1】:

    好的,我认为它成功了:

    "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 package.json

    【讨论】:

      猜你喜欢
      • 2013-12-20
      • 2022-01-10
      • 2017-11-18
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 2020-10-28
      • 2012-07-06
      • 1970-01-01
      相关资源
      最近更新 更多