Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

thmsndk
Copy link
Contributor

@thmsndk thmsndk commented Dec 12, 2021

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?

@thmsndk thmsndk marked this pull request as ready for review December 12, 2021 03:42
@thmsndk thmsndk changed the title force git to load files with lf instead of crlf force git to load files with lf instead of crlf on windows Dec 12, 2021
@laverdet
Copy link
Owner

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
Copy link
Contributor Author

thmsndk commented Dec 14, 2021

@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

@laverdet laverdet closed this in 30f51bb Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants