是否可以将ESLINT直接添加到Git中?
我希望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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能强迫人们在机器上运行这些程序,也不能将它们直接集成到GIT中。人们使用各种工具与git进行交互,其中一些根本不运行挂钩或外部程序(例如,使用libgit2的程序)。使用常规git的任何人都可以简单地添加
- no-verify
到git 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
togit 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.