Skip to content
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

Add prettier config #472

Open
kjbrum opened this issue Oct 25, 2019 · 5 comments
Open

Add prettier config #472

kjbrum opened this issue Oct 25, 2019 · 5 comments

Comments

@kjbrum
Copy link

kjbrum commented Oct 25, 2019

I ran into a lot of errors when creating a new page. It would be nice to have a Prettier config setup to automatically format the code correctly.

@travi
Copy link
Member

travi commented Oct 25, 2019

we already have an eslint config set up and eslint supports some autofixing. i'd be open to prettier in addition, but have not taken the time to understand the implications of getting both to work together

@kjbrum
Copy link
Author

kjbrum commented Oct 25, 2019

Right on, I'm not sure how all that works so I thought Prettier would help.

Sounds like it's not needed and there is probably just some configuration that I would need to do.

@travi
Copy link
Member

travi commented Oct 25, 2019

i definitely see the benefit of prettier, but have just never taken the time to sort through the details of getting it to work with eslint. more than happy to learn from someone that has done it or wants to figure it out, though.

@micleners
Copy link
Member

eslint and Prettier can play well together. Good news it many people have forged that trail:
https://github.com/prettier/prettier-eslint
https://www.robinwieruch.de/prettier-eslint
https://medium.com/javascript-scene/streamline-code-reviews-with-eslint-prettier-6fb817a6b51d

You can set up Prettier auto-format with hotkeys or on save. This creates consistent code format and saves time from having to manual make your code adhere to styles.

Many discuss the benefits of prettier over eslint including stricter rules and opinionated-ness, so that it makes formatting decisions and folks don't have to fight over them.

Also- you can set up this with Husky and Lerna to automatically run prettier and eslint when you commit:
https://github.com/okonet/lint-staged

@travi
Copy link
Member

travi commented Oct 26, 2019

eslint and Prettier can play well together

yep, i just havent taken the time to figure out the details around how. if someone wants to help get us over the hurdle, i'm happy to work through getting us there

Many discuss the benefits of prettier over eslint including stricter rules and opinionated-ness, so that it makes formatting decisions and folks don't have to fight over them.

i'm a huge advocate of this stance. this is most of the reason the eslint config is as strict as it is. in general the actual rules are less important to me than being consistent. tools like eslint and prettier are much better reminders than humans in several ways, but most importantly are disconnected enough to minimize disagreements from each contribution, as you mention.

Also- you can set up this with Husky and Lerna to automatically run prettier and eslint when you commit:
okonet/lint-staged

lint-staged is also high on my list to incorporate into projects like this. ideally, i'd like npm test to run in that way. i think it would be supported, but i remember running into some sort of roadblock the last time i tried. dont remember the detail of what the problem was, but if you have experience, i'd love to learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants