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

Recommend Prettier? #13

Open
saltcod opened this issue Dec 14, 2017 · 5 comments
Open

Recommend Prettier? #13

saltcod opened this issue Dec 14, 2017 · 5 comments

Comments

@saltcod
Copy link
Collaborator

saltcod commented Dec 14, 2017

Auto-formatting code is a Big Deal for me. I want to spend 0 seconds of my life indenting and spacing things when my computer can do a much better job of it anyway.

It would be amazing if we could (all) move to using something like Prettier and never have to deal with it again. I've played with Prettier a bunch of late and while it's not my favourite of the options, I think it's probably the leading contender and it has plugins for most major editors now (ST, vscode, PHPStorm, Atom).

It's not the job of this starter theme to dictate what text editor plugins you use, but if we decide to encourage the use of Prettier, we need to change some of the eslint config. In some cases, Prettier handles a lot of what eslint enforces already, while in other cases it's at odds with what's in the current .eslintrc.

Disclaimer: While we at 10up follow WordPress-like code standards in our js, with lots of ( 'spaces' ) around [ 'everything' ], Prettier currently doesn't support this, and isn't likely to. I thought this was going to be a deal-breaker for me at first, but I'm learning to move on and let the other benefits weigh against this detraction.

@saltcod
Copy link
Collaborator Author

saltcod commented Dec 14, 2017

Ps: Prettier supports css/scss out of the same box.

@magnificode
Copy link
Owner

Definitely worth a discussion, do you know if Prettier or a similar tool comes with a config file you can customize? If we had a .prettierrc file or something that we could shape around our standards that would be ideal.

Also, if Prettier doesn't play nice with CSS Next, then maybe we can look into using something like this: https://stylelint.io/user-guide/postcss-plugin/ -- since we're already using PostCSS, it may be a nice drop in solution. Though I don't think it'll automatically fix the linting issues like Prettier does.

@saltcod
Copy link
Collaborator Author

saltcod commented Dec 19, 2017

There is an rc file: https://prettier.io/docs/en/configuration.html
But Prettier's config options are purposely limited: https://prettier.io/docs/en/options.html

My feelings on Prettier aren't strong, but it would be very cool to have one solution that could handle css and js.

@gziolo
Copy link

gziolo commented Dec 22, 2017

We have the same issue with Gutenberg. The lack of spaces around everything that WordPress coding standards enforce is a blocker. See related thread: WordPress/gutenberg#2819.

We solved it at @Automattic for Calypso forking Prettier - https://github.com/Automattic/calypso-prettier. I don't think it's a long-term solution for WordPress community, but sharing it anyway :)

@magnificode
Copy link
Owner

Thanks a ton for the insight @gziolo much appreciated!!

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

No branches or pull requests

3 participants