简体   繁体   English

在ESlint中强制执行“换行样式”规则有多重要? 我可以关掉它吗?

[英]How important is to enforce the “linebreak-style” rule in ESlint? Can I just turn it off?

I've created a Node.js module which I'm gonna be open-sourcing soon. 我已经创建了一个Node.js模块,我将很快将其开源。 I originally developed it on Linux and I decided to test it on Windows before publishing it. 我最初是在Linux上开发它的,因此决定在发布前先在Windows上对其进行测试。 When I ran ESLint on Windows I noticed I had a huge amount of linting errors which were all the same: 当我在Windows上运行ESLint时,我注意到我有大量相同的掉毛错误:

error  Expected linebreaks to be 'LF' but found 'CRLF'  linebreak-style

I read in a couple of places that these linebreaks were inserted by Git when I cloned the repo on Windows. 我在几个地方读到,当我在Windows上克隆存储库时,这些换行符是Git插入的。 I also read that it is possible to turn off this rule in the eslint config file. 我还读到,可以在eslint配置文件中关闭此规则。 Is it safe to do this? 这样安全吗? or is there a "best practice" regarding this rule? 还是关于此规则的“最佳实践”? (considering this will be an open source project and hopefully others will be contributing to it) (考虑到这将是一个开源项目,希望其他人会对此做出贡献)

Any advice or feedback will be appreciated. 任何建议或反馈将不胜感激。

Try to re-clone your repo after typing: 输入以下内容后,尝试重新克隆您的存储库:

git config --global core.autocrlf false

That should avoid Git converting your eol (end of lines) from LF to CRLF automatically on checkout. 那应该避免Git在结帐时将eol(行尾)从LF自动转换为CRLF。
Then your linter should find the expected eol. 然后,您的皮棉应该找到预期的eol。

Note: I have been advocating for that setting to be false by default for years: see " Git: Unix or DOS line termination ". 注意:多年来,我一直主张将该设置默认为false:请参见“ Git:Unix或DOS线路终止 ”。

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

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