As we all know 🔥, the newline of Vscode has LF and CRLF

Different operating systems use different newlines for text files. UNIX/Linux used 0x0A (LF), early Mac OS used 0x0D (CR), and later OS X was brought into line with UNIX after a kernel change. But DOS/Windows has always used 0x0D0A (CRLF) as a newline character. Git provides an "automatic newline conversion" feature. This feature defaults to "automatic mode" and tries to replace UNIX line breaks (LF) with Windows line breaks (CRLF) when you check out files; When you commit the file, it tries to replace CRLF with LF. Git's "automatic newline conversion" may sound smart and sweet, as it tries to keep files consistent in the repository (Unix-style) while keeping files compatible locally (Windows-style). Unfortunately, this feature is buggy and unlikely to be fixed anytime soon.Copy the code

Git newline LF and CRLF conversion problem copied

Here we can see that on macOS and Linux, the newline character is inconsistent with Windows.

Once you use tools like ESLint, the whole project breaks down…

May search in Baidu for a long time, how to solve this problem, found are the following two:

1. How to set line breaks for new files

2. How can a single file change the newline character through the editor

Nothing about how to fix existing files

There are so many files in the project, how can you manually repair them one by one

So here’s how to fix it. Right

On the MAC/Linux:

CD project root directory find. -type f | grep -v "node_modules" | xargs dos2unixCopy the code

On Windows, use the Git-bash terminal, not CMD or Powershell

CD project root directory find. -type f | grep -v "node_modules" | xargs dos2unixCopy the code