17

I had this error when running lint test, how solve this error:

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

enter image description here

PS: Maybe it will be helpfull: I'm using Windows (WebStorm), and the project is running and debugging in Debian.

HappyCoder888
  • 736
  • 1
  • 8
  • 16
  • I'm not understand JSON of the error? – HappyCoder888 Oct 17 '15 at 18:07
  • 1
    Welcome to Stack Overflow :) Please familiarize yourself with how to ask a good question. You should provide us a code, that caused an error and prove that you did some research. LF and CRLF is an issue probably with line endings on UNIX like OS and Windows. But we are not wizards and cannot know out of heaven what was wrong. :) Good Luck – DawidPi Oct 17 '15 at 18:08
  • 1
    What is your question? You haven't asked one. You've posted a very clear and self-explanatory error message (twice) and stated you had the error. *nix (Unix, Linux, Mac OS X) all use LF for line endings; Windows uses CRLF. So apparently you have a file with Windows line endings that you're trying to use on Debian. So fix the line endings. – Ken White Oct 17 '15 at 18:12
  • I did a reserach of shure. Can't find solution – HappyCoder888 Oct 17 '15 at 18:14
  • also [link](https://www.jetbrains.com/phpstorm/help/configuring-line-separators.html) doesn't make a sense. But [link](https://www.jetbrains.com/phpstorm/help/status-bar.html) was a solution. Anywhere stackoverflow doesn't have this question maybe this comment will be helpful – HappyCoder888 Oct 17 '15 at 18:36

3 Answers3

16

The main solution was that Windows by default using CRLF, like my WebStorm.

1)first step is to change on WebStorm default encoding like there:

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

2)And change it on Status Bar

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

Save it! and

OKAY No lint warnings.

HappyCoder888
  • 736
  • 1
  • 8
  • 16
  • 1
    Didn't work for me. After I switching to master branch all linebreaks errors are back and changing it in the editor added like 100 files diff in my commit. – Anna Mar 28 '19 at 09:12
  • 1
    dont work for me too. Set LF on interface, settings, then all files from repo (all files from unix with LF) converted to SRLF – Nikolay Jun 22 '20 at 10:40
16

Run this in your terminal or cmd prompt

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

Note - Make sure you don't have any un-committed changes else it will be deleted!

Sahil Shikalgar
  • 761
  • 8
  • 20
0

If you are using Vs-Code just run this command in terminal:

yarn run lint --fix

I am not sure, if this will work for all editors, but definitely worths trying.

Hefaz
  • 526
  • 1
  • 8
  • 24