-
Notifications
You must be signed in to change notification settings - Fork 22
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
[prettierx] --paren-spacing option from WordPress #16
Conversation
(whitespace) according to WordPress style rules (with a quick lint fix by @brodybits) Add description of the changes from the WordPress fork to the start of README.md Update test snapshots to recognize the paren-spacing option in tests_integration Co-authored-by: Jarda Snajdr <[email protected]> Co-authored-by: Christopher J. Brody <[email protected]>
…xpression or MemberExpression Before: ```js ! ( a || b ) ``` After: ```js ! ( a || b ) ``` Fixed by inserting the parens directly when formatting a Binary or LogicalExpression instead of relying on `genericPrint` inserting them depending on result of `path.needParens`. Also fixes parens about MemberExpression object: ```js ( a || b ).c; ``` and semicolon insertion in no-semi mode for MemberExpressions: ```js x ;(a||b).c ``` All unit tests continue to pass (including the Flow and Typescript ones).
(with a quick lint fix by @brodybits)
cover parenSpacing in tests/space-before-function-paren/tslint-compat
(tests/standard/typescript)
and cove babel parser in tests/empty_statement
Thanks for making the option more widely available @brodybits 👍
Yes, interactions between options are sometimes fragile and tricky to debug. I think that's the technical reason behind the Prettier's dislike of options. They don't compose so easily like, e.g., ESLint rules. |
Interesting analysis, thanks. In this case the I think Prettier should have been based on something like Babel, with a customized output printer that is more flexible and maybe some other custom plugins. This is analogous to the way "Standard JS" is based on ESLint, with a couple new rules in its own ESLint plugin. In fact, the output printer should have been in smaller parts in a similar fashion to the way custom Babel parsers can be dynamically run together. I discovered The trick is nice work but is a very sad reflection on the design of Prettier. My thoughts on a better design are in #8 (comment):
|
Nice option that is cherry-picked from the WordPress fork of Prettier ref: prettier/prettier#5919, with a couple lint fixes and some test coverage added.
Note that the
alignObjectProperties
option is known to not work quite right with this new option enabled. I hope to get this fixed someday./cc @jsnajdr