I don't want to explain it too much, I understand why you come to this blog
setup for your editor
if you use vscode, create a .vscode/settings.json
or a much general solution, create a .editorconfig
file
in this way, even if an editor haven't set eol sequence to LF, this will do it for you
for frontend developers
in your .prettierrc
file
you know what to do next
but it still happens
well, even though you set up these stuffs during developing, eol issue still happens when you clone a repository from a windows user. After your git commit
, git saves your code in CRLF on windows, while LF on linux/macos.
to handle this, create a .gitattributes
file
this config tells git to use LF on saving any file, except .cmd or .bat
not done yet
run following commands to reset eol. Before it, you should make sure your local repository is clean (commit/stash)
after these, eol in current files will be set to LF