简体   繁体   English

“lint-staged”软件包在Intellij构思中运行“ng lint --fix”后没有提交更新的文件

[英]“lint-staged” package is not committing the updated files after running “ng lint --fix” in Intellij idea

I have configured lint-staged as following in my Angular 7 app. 我已经在我的Angular 7应用程序中将lint-staged配置为以下内容。

  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "linters": {
      "*.ts": "ng lint --fix my-app --files"
    },
    "relative": true
  },

I am using Intellij idea. 我正在使用Intellij的想法。 When I am committing files in the editor, it runs husky. 当我在编辑器中提交文件时,它会运行哈士奇。 If there are any errors, it fixes them but commits the old files and not the ones which got changed after "ng lint --fix " and I have to commit the changed files again. 如果有任何错误,它会修复它们但提交旧文件,而不是在“ng lint --fix”之后更改的文件,我必须再次提交更改的文件。

Basically I want the changed files to be committed after it executes "ng lint --fix" and not the old ones. 基本上我希望更改的文件在执行“ng lint --fix”后提交,而不是旧的。

Any help on how to resolve this issue? 有关如何解决此问题的任何帮助?

Are you saying that committing from command-line works fine, but commuting from IDE does not? 你是说从命令行提交工作正常,但从IDE上下班不行吗?

In fact, it looks like the pre-commit hook does not stage files after running ng lint --fix . 实际上,看起来pre-commit运行挂钩在运行ng lint --fix之后不会ng lint --fix文件。 In this case, though, committing from the command line will not commit linter modifications as well. 但是,在这种情况下,从命令行提交也不会提交linter修改。

Make sure the hook calls git add after applying linters. 确保钩子在应用短线后调用git add

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM