在 gulp 项目中使用 eslint 时,我遇到了这样的错误问题
Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
我正在使用 Windows 环境运行 gulp,下面给出了整个错误日志
Kiran (master *) Lesson 4 $ gulp
Using gulpfile c:\Users\Sai\Desktop\web-build-tools\4\
gulpfile.js
Starting 'styles'...
Finished 'styles' after 17 ms
Starting 'lint'...
'lint' errored after 1.14 s
ESLintError in plugin 'gulp-eslint'
sage: Expected linebreaks to be 'LF' but found 'CRLF'.
ails: fileName: c:\Users\Sai\Desktop\web-build-tools\4\js\extra.js
$>Users\Sai\Desktop\web-build-tools\4\js\extra.js
error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
我还包括extra.js文件作为错误指示可能的错误。
function getWindowHeight() {
return window.innerHeight;
}
getWindowHeight();
检查您是否有linebreak-style
在 .eslintrc 或源代码中配置如下规则:
/*eslint linebreak-style: ["error", "unix"]*/
由于您使用的是 Windows,因此您可能需要改用此规则:
/*eslint linebreak-style: ["error", "windows"]*/
请参阅文档 https://eslint.org/docs/latest/rules/linebreak-style of linebreak-style
:
当与很多人一起使用不同的编辑器进行开发时,VCS
应用程序和操作系统可能会出现不同的线路
结局是由提到的任何一个写的(可能特别是
使用Windows和Mac版本的SourceTree时会发生
一起)。
windows操作系统中使用的换行符(换行符)是
通常回车符 (CR) 后跟换行符 (LF),使其成为
回车换行 (CRLF),而 Linux 和 Unix 使用简单的
换行(LF)。相应的控制序列为"\n"
(对于低频)
和"\r\n"
对于(CRLF)。
这是一个可以自动修复的规则。这--fix
命令行上的选项会自动修复此规则报告的问题。
但如果你想保留CRLF
代码中的行结尾(当您在 Windows 上工作时)不要使用fix
option.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)