Skip to content

Fix: enforce LF line endings to resolve prettier errors on Windows#1990

Open
Kayd-06 wants to merge 2 commits intoopenstreetmap:mainfrom
Kayd-06:fix-windows-prettier
Open

Fix: enforce LF line endings to resolve prettier errors on Windows#1990
Kayd-06 wants to merge 2 commits intoopenstreetmap:mainfrom
Kayd-06:fix-windows-prettier

Conversation

@Kayd-06
Copy link

@Kayd-06 Kayd-06 commented Mar 5, 2026

Description

When checking out this repository on a Windows machine (which typically defaults to core.autocrlf=true), Git checks out files with Carriage Return Line Feed (CRLF) line endings. However, prettier enforces Line Feed (LF) endings (via .prettierrc). This mismatch causes npm run lint to fail out-of-the-box on Windows with thousands of formatting warnings.

To prevent this error and guarantee consistent file endings across all operating systems, I added a .gitattributes file to enforce LF for text files.

@matkoniecz
Copy link
Collaborator

if band aid for bad OSes is needed, maybe something as simple as

* text=auto

would be sufficient and work? What is the benefit of listing file types?

(idea taken from https://stackoverflow.com/questions/26075786/force-lf-line-endings-using-gitattributes-without-losing-automatic-text-binary - as I have no access to Windows I am unable to test it, but if I read https://git-scm.com/docs/gitattributes#_end_of_line_conversion correctly it should work well)

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

🍱 Your pull request preview is ready

Please use this preview to check your changes. Ideally use the test documentation template and document your test results by commenting on the PR. This will speed up the review process for everyone.

FYI, once this PR is merged, you can use the iD Editor Preview to test your changes in interaction with all other changes.

@Kayd-06
Copy link
Author

Kayd-06 commented Mar 5, 2026

Yes, using just * text=auto is much cleaner and sufficient. I've tested it locally on Windows and npm run lint now passes successfully. I have pushed the updated .gitattributes file to the PR.

@matkoniecz
Copy link
Collaborator

BTW, if I remember right you can set this also as system-wide default in your git settings on global configuration in your computer.

But I guess that adding such Windows-proofing here may make sense?

Copy link
Collaborator

@matkoniecz matkoniecz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not break anything on Linux, reportedly unbreaks Windows, looks safe to me

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