当在gulp项目中使用eslint时,我遇到过这样的错误问题 预期换行符是“LF”,但发现“CRLF”换行风格,我使用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();

当前回答

当我用eslint使用VSCode时,同样的情况也发生了。如果你使用VSCode,

1 -在VScode的右下角单击名称可以是LF或CRLF的区域。

2—在下拉菜单中选择“LF”。

这对我来说很有效。

其他回答

提示:如果没有,请确保您已经安装了图片中的Git。 您可以将其他功能作为默认,您可以选择visual studio代码作为默认编辑器。这对你以后很有帮助。

Windows用户: 卸载Visual Studio Code,然后重新安装,EditorConfig应该可以正常工作。

卸载Visual Studio Code仍然会保留旧的设置和扩展!完全删除Windows上的Visual Studio代码

卸载的Visual Studio

本机>本地盘(C) Users > CurrentUser > AppData > Local > Programs > Microsoft VS Code Unins000.exe或从控制面板卸载它 本机>本地盘(C) Users > CurrentUser > AppData > Local > Roaming 代码=>文件夹应该删除它 这台PC >本地盘(C) Users > CurrentUser > .vscode =>文件夹应该删除它 重新安装vs代码现在应该工作了。

如果你正在使用vscode,我会建议你点击窗口右下角的选项,并将其从CRLF设置为LF.这修正了我的错误

如果你想要更改为LF,并且你正在使用VS Code,你可以这样逐个文件执行:

如果你正在使用vscode并且你在Windows上,我建议你单击窗口右下角的选项,并将其从CRLF设置为LF。因为我们不应该仅仅为了删除Windows上的错误而关闭配置

如果没有看到LF / CLRF,则右击状态栏并选择编辑器行结束。

如果你想在crlf (Windows Eol),去文件->首选项->设置。在User选项卡中输入“line end of line”,并确保Files: Eol设置为\r\n,如果您使用的是Prettier扩展,请确保Prettier: line end of line设置为crlf。最后,在你的eslintrc文件中,添加以下规则:'linebreak-style': ['error', 'windows']