【问题标题】:lint-staged is running ng -lint for all the changed files instead of only staged fileslint-staged 正在为所有更改的文件运行 ng -lint,而不仅仅是暂存文件
【发布时间】:2019-11-05 15:53:06
【问题描述】:

我正在尝试将 husky 与 lint-staged 一起用于 angular5 中的预提交 git 钩子。 Prettier 仅格式化暂存文件。但是当我运行 ng lint 命令时,它会在所有更改的文件上运行,而不是仅在暂存文件上运行(我修改了 4 个文件,但只有 2 个文件使用 git add 命令添加到暂存区域。但是所有 4 个文件都检查了 linting 哪个不是我所期望的)

这是.lintstagedrc中的配置

  "*.{ts,json}": [
    "prettier --write",
    "ng lint myProjName --files",
    "git add"
  ],
  "*.less": [
    "prettier --write",
    "npm run stylelint",
    "git add"
  ]
}```

I debugged the issue to some extent. --files takes only the files which have been staged into the account. But still when the linters task completes, I get errors for non staged files as well.

【问题讨论】:

    标签: husky lint-staged


    【解决方案1】:

    --files 标志是在 Angular v7 中添加的(可能是 v7.1.2,除了this 评论,我在更新日志中找不到任何参考)。

    v7 之前的版本不支持该标志,或者至少是not documented

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 2019-08-14
      • 2020-01-06
      • 1970-01-01
      • 2021-05-24
      • 2021-12-17
      • 1970-01-01
      • 2019-06-09
      • 2019-08-22
      相关资源
      最近更新 更多