In daily team collaborative development, git is we very important code management tool, but in many developers use the computer operating system is not consistent, such as small A use of Windows, small B are using Linux, small C using MacOS, thus lead to the different operating systems do not match the newline character.
Windows – CRLF
– \r\n
Linux and MacOS-LF-\ n
Writing this article is to record and to help more people solve this problem.
Scene again
The current mainstream way for front-end team code style management is ESlint+Prettier, which is the way we use it today, where ESlint does style and syntax checking and Prettier is used to help format code
The other thing is that GIT will automatically convert Windows line breaks (CRLF) to Linux line breaks (LF) when you push your code
Our limit to ESlint line feeds is the Linux line feeds (LF), a problem caused by CRLF being turned on by default on Windows
The solution
My current solution is to set the editing default to newline, like VSCode:
Just search files.eol in File => Preferences => Settings and set it to \n
It’s the same thing with all the other editors and you can search for Settings yourself.
The last
If you are interested in open source and want to contribute to open source, you can join our Huayuguoshan team. You can click the link below to check it out
Github.com/hug-sun/ele…