预期的换行符是'LF '但发现'CRLF '在使用大口ESLint断行风格

2018-04-01

Backdoor Cipher提出了一个问题:Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style in Eslint using gulp,或许与您遇到的问题类似。

回答者Dheeraj V.S.给出了该问题的处理方式:

Check if you have the linebreak-stylerule configure as below either in your .eslintrc or in source code:

/*eslint linebreak-style: ["error", "unix"]*/

Since you're working on Windows, you may want to use this rule instead:

/*eslint linebreak-style: ["error", "windows"]*/

Refer to the documentationof linebreak-style:

When developing with a lot of people all having different editors, VCS applications and operating systems it may occur that different line endings are written by either of the mentioned (might especially happen when using the windows and mac versions of SourceTree together).

The linebreaks (new lines) used in windows operating system are usually carriage returns (CR) followed by a line feed (LF) making it a carriage return line feed (CRLF) whereas Linux and Unix use a simple line feed (LF). The corresponding control sequences are "\n"(for LF) and "\r\n"for (CRLF).

This is a rule that is automatically fixable. The --fixoption on the command line automatically fixes problems reported by this rule.

But if you wish to retain CRLFline-endings in your code (as you're working on Windows) do not use the fixoption.

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:一次替换多个字符串
下一篇:WebSocket OnError如何读取错误的描述吗?
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部