本文介绍了如何保留eslint的特定于操作系统的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在一个团队中工作,该团队使用atom作为首选编辑器,但在Windows和OSX之间进行分配.我们的.eslintrc.js将换行符样式报告为Windows上的一个问题(预期行尾为LF,但找到CRLF),但在OSX上运行良好.有没有一种方法可以指定只在OSX上检查此规则

I currently work in a team which uses atom as the editor of choice but split between windows and OSX. Our .eslintrc.js reports the linebreak-style as an issue on windows(Expect line ending to be LF but found CRLF) but works fine on OSX.Is there a way to specify to eslint that only check this rule while on OSX

推荐答案

启用此规则的目的是统一所有OS和编辑器的行尾.您使用Windows的同事可能没有在编辑器中配置LF(OSX,Linux)行尾,而是使用了CRLF(Windows).通常在大多数编辑器中都可以配置.

The purpose of having this rule enabled is to unify the line endings along all the OS and editors. Probably your coworkers that are using Windows have not configured LF (OSX, Linux) line endings in their editors, and have instead CRLF (Windows). This is normally configurable in most editors.

如果要在Windows上允许不同的行尾,我认为最好的选择是配置版本控制以在提交时统一它,如此帖子,即项目的.gitattributes中的text eol=lf.

If you want to allow different line endings on Windows, I think the best option is to configure your version control to unify it on commit, like indicated in this post, i.e. text eol=lf in your project's .gitattributes.

否则,根据注释,一个好的解决方案是在 .editorconfig文件中创建end_of_line = lf

Otherwise, as per the comments, a good solution is to create a end_of_line = lf in a .editorconfig file.

这篇关于如何保留eslint的特定于操作系统的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 23:21