(linebreak-style)预期的换行符为'LF'但找到'CRLF'。 (eslint)

时间:2015-10-17 17:48:49

标签: windows unix webstorm lint eslint

运行lint测试时出现此错误,如何解决此错误:

(linebreak-style) Expected linebreaks to be 'LF' but found 'CRLF'. (eslint)

enter image description here

PS:也许它会有所帮助:我正在使用Windows(WebStorm),项目正在Debian中运行和调试。

3 个答案:

答案 0 :(得分:10)

主要解决方案是Windows默认使用CRLF,就像我的WebStorm一样。

1)第一步是更改WebStorm默认编码,如:

https://www.jetbrains.com/phpstorm/help/configuring-line-separators.html

2)并在状态栏上更改

https://www.jetbrains.com/phpstorm/help/status-bar.html

保存!和

OKAY No lint warnings.

答案 1 :(得分:3)

在您的终端或cmd提示符下运行

git config core.autocrlf false
git rm --cached -r .
git reset --hard

注意-确保您没有任何未提交的更改,否则将被删除!

答案 2 :(得分:0)

如果您使用的是 Vs-Code ,只需在终端中运行以下命令:

yarn run lint --fix

我不确定这是否适用于所有编辑器,但绝对值得尝试。