Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 983
HappyCoder888 Avatar asked Oct 17 '15 17:10

HappyCoder888


People also ask

What is LF in Eslint?

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).

How do I change from CRLF to LF in Vscode?

The Quick FixAt the bottom right of the screen in VS Code there is a little button that says “LF” or “CRLF”: Click that button and change it to your preference. Voila, the file you are editing now has the correct line breaks.

What's the difference between LF and CRLF?

CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line. LF = Line Feed ( \n , 0x0A in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.


2 Answers

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.

like image 172
HappyCoder888 Avatar answered Oct 22 '22 20:10

HappyCoder888


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!

like image 15
Sahil Shikalgar Avatar answered Oct 22 '22 21:10

Sahil Shikalgar