Prettier endOfLine: LF, CRLF, and CI
endOfLine sets the line ending Prettier writes; the default is lf.
Line endings are an invisible but common cause of CI format failures, especially when Windows checkouts convert to CRLF. endOfLine plus git settings keep them consistent.
What it does
endOfLine controls the newline character Prettier emits: "lf" (default) for \n, "crlf" for \r\n, "cr" for \r, and "auto" to keep the file existing line ending. Most projects use "lf" and let git normalize, which is what the default expects.
Common usage
// .prettierrc.json
{ "endOfLine": "lf" }
# .gitattributes (pair with the above)
* text=auto eol=lfOptions
| Value | What it does |
|---|---|
| lf (default) | Unix line endings \n |
| crlf | Windows line endings \r\n |
| cr | Old Mac line endings \r |
| auto | Keep the existing ending of each file |
In CI
Set endOfLine to lf and add a .gitattributes with eol=lf so Windows developers do not commit CRLF that Linux CI then rejects. With autocrlf on, a Windows working copy can have CRLF on disk while the repo stores LF; endOfLine lf plus normalized git keeps prettier --check passing on every platform.
Common errors in CI
The classic failure is "[warn] Code style issues found" where the only difference is line endings, shown as "Delete \r" in editor diffs, because a Windows checkout has CRLF but config wants lf. Fix by setting endOfLine lf, adding .gitattributes eol=lf, and renormalizing with git add --renormalize .