星号 (*) 在 lint 阶段配置中起什么作用?

发布于 2025-01-15 09:17:14 字数 412 浏览 3 评论 0原文

我想使用 lint-staged 仅在 node.js 项目中的暂存文件上运行挂钩。 docs 建议将以下代码添加到 package.json 文件中;

{
  "lint-staged": {
    "*": "your-cmd"
  }
}

我还在另一个代码库的其他地方看到了以下代码;

"lint-staged": {
        "**/*": "prettier --write --ignore-unknown"
    }

星号有什么作用?我不认为这只是一个占位符。感谢您的帮助。

I want to use lint-staged to run hooks only on staged files in a node.js project. The docs suggest adding the following code to the package.json file;

{
  "lint-staged": {
    "*": "your-cmd"
  }
}

I have also seen the following code elsewhere in another codebase;

"lint-staged": {
        "**/*": "prettier --write --ignore-unknown"
    }

What purpose does the asterisk(s) serve? I don't suppose it's simply a placeholder. Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2025-01-22 09:17:14

正如自述文件所述,这些是 glob 模式。

"*": "your-cmd"

将匹配任何文件(* 根据定义匹配任何文件)

"**/*": "prettier --write --ignore-unknown"

将匹配

  • ** - “≥ 0 个字符跨越目录边界”,后跟
  • / - 目录边界,后跟
  • <代码>* - 任何事物

As the readme says, those are glob patterns.

"*": "your-cmd"

will match any file (* matches anything by definition)

"**/*": "prettier --write --ignore-unknown"

will match:

  • ** - "≥ 0 characters crossing directory boundaries", followed by
  • / - A directory boundary, followed by
  • * - Anything
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文