是否可以将ESLINT直接添加到Git中?

发布于 2025-01-31 22:00:42 字数 156 浏览 4 评论 0原文

我希望ESLINT在将文件提交git之前检查我的文件。我发现赫斯基和绒毛阶段是这样做的,但是这样,每个程序员都必须在他们的机器中铺上沙哑和绒毛。

如果将ESLINT直接注入GIT,以便使用ESLINT检查所有提交,而无需每个程序员都必须安装Husky and Lont阶段,该怎么办?

I want ESLint to check my files before committing them to git. I found husky and lint-staged to do this but in this way every programmer has to have husky and lint-staged in their machine.

What if ESLint is directly injected into git so that all the commits are checked with ESLint, without every programmer having to install husky and lint-staged?

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

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

发布评论

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

评论(1

花期渐远 2025-02-07 22:00:42

您不能强迫人们在机器上运行这些程序,也不能将它们直接集成到GIT中。人们使用各种工具与git进行交互,其中一些根本不运行挂钩或外部程序(例如,使用libgit2的程序)。使用常规git的任何人都可以简单地添加- no-verifygit commit绕过钩子,,如Git FAQ中概述

如果您需要实施有效的控制,以确保人们的代码达到某些标准,则应使用CI系统(例如,GitHub操作),并在将代码合并到所需的分支中之前检查是否通过。

此外,默认情况下,安装预加压挂钩甚至是常见问题解答所述,这甚至没有用,因为这意味着使用大量壁球或固定提交的高级用户最终会因为这些提交被错误地标记而感到沮丧。 Linter。

You cannot force people to run those programs on their machine or integrate them directly into Git. People use all sorts of tools to interact with Git, some of which don't run hooks or external program at all (e.g., those using libgit2). Anyone using regular Git can simply add --no-verify to git commit to bypass the hooks, as outlined in the Git FAQ.

If you need to implement an effective control that makes sure that people's code meets some standard, you should use a CI system (e.g., GitHub Actions) and check that the code passes before merging it into the desired branch.

In addition, it's not even useful to install pre-commit hooks by default, as the FAQ mentions, because this means that advanced users who use lots of squash or fixup commits can end up frustrated by the fact that those commits are incorrectly flagged by the linter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文