-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Can we use Prettier (or similar formatter) for Javascript code? #16115
Comments
I would guess as long as the eslint config is happy, then sure, go ahead. |
Prettier is going to remove all original styling in code and reprint it from scratch. So it'll touch all the Javascript files and create merge conflicts for all pull requests. I wanted to hear about what other contributors/owners think about it. |
@mscdex I've used Prettier CLI on the code which I've contributed to NodeJS. |
Eslint itself is a very powerful prettier and formatter. I would rather not add another tool. If there is need for more explicit styling there is probably already a rule in eslint that could be added. Adding one rule at a time also reduces the churn and it will be easier to find a compromise between all collaborators and their individual wishes. |
Prettier just takes care of stylistic issues. The move to Prettier will be tough in the beginning, but with time we'll see the benefits as we no longer worry about formatting and concentrate on code. |
We only switched from closure_linter to eslint two years ago! Like @BridgeAR mentions, eslint is already pretty good at fixing style issues. |
Maybe I misunderstood, I thought the suggestion was if individual contributors could use it on their own. Adopting it officially project-wide is probably not a good idea as Ben and Ruben have said. |
Yeah, individual developers are free to use any formatter they want as long as it doesn't interfere with eslint rules. I use Prettier CLI, and add parenthesis for single param arrow functions before running make lint in my code. |
Seems like this can be closed. If I'm mistaken about that, please comment. Thanks! |
Prettier is different from eslint, it bring the consistent style for project like semicolons and quotes.
|
I did a little dig
|
Can we use Prettier for formatting Javascript code in NodeJS?
Prettier is an opinionated code formatter. It removes all original styling and ensures that all outputted code conforms to a consistent style.
Reasons:
We recently started using Prettier for private projects, and life has been better. We don't worry/argue about formatting any more :-)
Of course there was initial oppositions to some of the decisions taken by Prettier (like lack of parenthesis around single param arrow functions), but we got used to it with time.
For Open Source projects which don't use Prettier, I manually run Prettier CLI for the files which I'm editing. I believe developers will be more productive if we use formatters like Prettier in NodeJS. What do you think?
The text was updated successfully, but these errors were encountered: