Skip to content
Latchkey

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
// .prettierrc.json
{ "endOfLine": "lf" }

# .gitattributes (pair with the above)
* text=auto eol=lf

Options

ValueWhat it does
lf (default)Unix line endings \n
crlfWindows line endings \r\n
crOld Mac line endings \r
autoKeep 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 .

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →