-
Notifications
You must be signed in to change notification settings - Fork 4
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
Set "endOfLine" to auto in prettier config #2
base: main
Are you sure you want to change the base?
Conversation
I'm not sure if I want to set this in the Prettier config or not. For reference, when running checks in GH actions / via package.json, we set that value explicitly. See Stacks-Editor as an example: {
"scripts": {
"lint:prettier": "prettier --check . --end-of-line auto",
}
} |
If you set |
Prettier will set any command line options over existing config settings (which are in turn set over any default setting). What the given command does is force prettier to use |
Right, the script above is only checking and not modifying any files. I haven't tried yet, but do IDEs support pulling in a configuration from a package? Like, what if your IDE is configured to do a "prettier on save" function, would it modify the line ends to LF and then cause Git to see that as the file being changed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@b-kelly I believe we could consider endOfLine: "auto"
a sensible default for our Stack Overflow repositories which would make it a good candidate for this package. What about merging this PR and cut a release?
See StackExchange/stacks-utils#2 for reasoning
Prettier by default uses
LF
but when working on a cross-platform repo where we let git handle the CRLF <> LF conversions for us. This default behavior causes Prettier and Git to start battling with each other and causes lint checks to fail. By setting it to auto, Prettier will respect the line endings that exist on the file and not change them.