简体   繁体   English

如何忽略特定计算机的 eslint 规则

[英]How to ignore eslint rule for a specific computer

Our project specifies the linebreak-style rule to be "unix" .我们的项目将linebreak-style规则指定为"unix" Nevertheless, some developers use Windows with automatic conversion to CRLF and we would like to keep that as it is for now.尽管如此,一些开发人员使用自动转换为 CRLF 的 Windows,我们希望暂时保持原样。 Is it possible to disable the linebreak-style rule (or set it to "windows" ) on their computers in such a way that this configuration is not shared with the main repository (ie, not visible to git)?是否可以在他们的计算机上禁用linebreak-style规则(或将其设置为"windows" ),以使该配置不与主存储库共享(即对 git 不可见)?

You could use --skip-worktree to avoid git checking for changes to a configuration file.您可以使用--skip-worktree来避免 git 检查配置文件的更改。

Ex: git update-index --skip-worktree path\\to\\.eslintrc.json例如: git update-index --skip-worktree path\\to\\.eslintrc.json

You could optionally combine this with the extends functionality in the eslint configuration file(s) such that one configuration file has your base/shared configurations and a git-ignored configuration file can have local changes applied.您可以选择将其与 eslint 配置文件中的扩展功能结合起来,这样一个配置文件就有您的基本/共享配置,而忽略 git 的配置文件可以应用本地更改。 This approach should help you keep most of the eslint rules shared via git.这种方法应该可以帮助您保持通过 git 共享的大部分 eslint 规则。

I created a tool that can enable different rules for different platforms.我创建了一个工具,可以为不同的平台启用不同的规则。 It can do this by providing different .eslintrc.json on windows and other platforms.它可以通过在 windows 和其他平台上提供不同的.eslintrc.json来做到这一点。

Here is an example of using different cypress.zip depending on Windows or Linux:以下是根据 Windows 或 Linux 使用不同cypress.zip的示例:

https://github.com/tomasbjerre/dictator-cypress https://github.com/tomasbjerre/dictator-cypress

And here is an example using that approach:这是使用该方法的示例:

https://github.com/tomasbjerre/dictator-cypress-example https://github.com/tomasbjerre/dictator-cypress-example

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

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