-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
[style] Use Prettier #626
base: main
Are you sure you want to change the base?
[style] Use Prettier #626
Conversation
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thank you for working on this! I haven't yet looked at the individual changes much so this is an overall comment:
This kind of defeats the purpose.
I know I’m being weird about this, but is there any way we could use comments that don’t depend on any particular tooling? E.g. if in the future we want to switch to a different code formatter, we should not need to go and change all the |
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.
So yeah, rather than calling ESLint fix after Prettier, let's remove ESLint (or dramatically restrict it to only the things that Prettier doesn't touch at all) in this PR and see how we're doing.
E.g. it looks like the space before the opening paren is kept, but I don't know if that's ESLint or our Prettier config.
Same with stroustrup for braces.
Afaik there isn't any sort of tooling-agnostic ignore comment, so we'd just need to replace the comments if ever we wanted to change formatters. It's a bit annoying, but a global find+replace isn't the worst.
I just pushed a commit that has the code formatted without running |
Are there any Prettier plugins that could help reduce the difference? Googling a bit everything that comes up seems to imply that Prettier adds a space between function paren by default (e.g. https://prettier.io/blog/2020/03/21/2.0.0.html#always-add-a-space-after-the-function-keyword-3903httpsgithubcomprettierprettierpull3903-by-j-f1httpsgithubcomj-f1-josephfrazierhttpsgithubcomjosephfrazier-sosukesuzukihttpsgithubcomsosukesuzuki-thorn0httpsgithubcomthorn0-7516httpsgithubcomprettierprettierpull7516-by-bakkothttpsgithubcombakkot ) so I'm puzzled why it doesn't here. And there's a plugin for brace style: https://www.npmjs.com/package/prettier-plugin-brace-style |
Adds Prettier to format code for the project.
Since some Prettier rules conflict with eslint preferences, the lint script is currently set to run
eslint --fix
right after Prettier. I've tried to look for Prettier plugins to customize it to the way our code is formatted, but I couldn't find anything.Because of these differences, the
prettier --check
command will always return warnings, so we wouldn't be able to enforce Prettier through CI that way. The best idea I have to check formatting with CI would be to just runprettier --write; eslint --fix
and make sure that it doesn't produce any unstaged changes.Also, I've quickly gone through the code and added some
// prettier-ignore
comments to maintain custom formatting (eg. spacing for matrices), but lmk if I've missed anything 😄