javascriptgitnewlineeolcore.autocrlf

NPM Package - LF or CRLF or auto line endings?


I'm the developer of an NPM package, and am trying to normalize line endings. I'm on a Windows machine with VSCode, so most of my files are in CRLF format. However, minified and sourcemap files generated by my bundler, Rollup, are in LF format.

I personally prefer LF format, and would like to have my distributed builds in LF format, as well as the files in my personal editor. However, I don't want to mess other Windows users using different editors.

How should I configure .gitattributes, .editorconfig, my VSCode Settings, and my Git settings to best accomplish this? Thanks!


Solution

  • If is better to specifiy in a .gitattributes (as in here) a consistent eol policy for files with specific extensions: see this .gitattributes for instance, which uses LF.

    VSCode has "auto" as its default file.eol, which should be enough: Git will do the conversion on checkout, and VSCode won't convert it.