laverdet / xxscreeps

Other
71 stars 16 forks source link

force git to load files with lf instead of crlf on windows #49

Closed thmsndk closed 2 years ago

thmsndk commented 2 years ago

I am on Windows and According to this https://eslint.org/docs/rules/linebreak-style#using-this-rule-with-version-control-systems forcing LF should fix this, and it does look like it is fixed when I make a change to the file and discard it so it is loaded from git again. image

Alternatively we could disable the rule?

laverdet commented 2 years ago

I think what's happened here is you enabled autoclrf in your gitconfig, which I'd definitely recommend disabling since you're using VS Code. Anyway, * -text would be the correct fix in gitattributes if this is something we want to explicitly disable. The configuration you have there of course will fail on non-ts files.

thmsndk commented 2 years ago

@laverdet it's been a while since i've set up my dev environment, but I'm pretty sure it's a default thing on windows, as per the rule description I linked

For example, the default behavior of git on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the linebreak-style rule to report errors if configured with the "unix" setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your .gitattributes file to prevent git from converting linebreaks in .js files:

they suggest to do this, I just modified it to .ts files. *.js text eol=lf

I did however end up using a linux dev container with vscode instead due to not being able to start the server on windows as per #36

Do we want to change it to * text eol=lf or just close this PR? I did limit it to .ts files with the assumption that we only lint .ts files