Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Parenthesize expressions #2449

Closed
Tracked by #2403 ...
MichaReiser opened this issue Apr 14, 2022 · 2 comments
Closed
Tracked by #2403 ...

Parenthesize expressions #2449

MichaReiser opened this issue Apr 14, 2022 · 2 comments
Labels
A-Formatter Area: formatter I-Normal Implementation: normal understanding of the tool and awareness

Comments

@MichaReiser
Copy link
Contributor

MichaReiser commented Apr 14, 2022

Prettier uses an exhaustive heuristic of when it should insert parentheses or not. Rome should implement a similar heuristic.

https://github.com/prettier/prettier/blob/6d02cd9650be29d1b11ab6ff1442eac4f5415c06/src/language-js/needs-parens.js#L20-L793

Relevant test cases with differences:

  • js/assignment/sequence.js
  • js/async/await-parse.js
  • js/async/conditional-expression.js
  • js/async/inline-await.js
  • js/async/nested.js
  • js/babel-plugins/private-fields-in-in.js
  • js/binary-expressions/equality.js
  • js/binary-expressions/exp.js
  • js/binary-expressions/math.js
  • js/binary_math/parens.js
  • js/class-extends/extends.js
  • js/classes/binary.js
  • js/classes/call.js
  • js/classes/member.js
  • js/classes/new.js
  • js/classes/ternary.js
  • js/conditional/no-confusing-arrow.js
  • js/export-default/function_tostring.js
  • js/for-of/async-identifier.js
  • js/function/function_expression.js
  • js/in/arrow-function.js
  • js/logical_expressions/issue-7024.js
  • js/logical_expressions/logical_expression_operators.js
  • js/new-expression/new_expression.js
  • js/nullish-coalescing/nullish_coalesing_operator.js
  • js/objects/expand.js
  • js/optional-chaining/chaining.js
  • js/optional-chaining/eval.js
  • js/reserved-word/interfaces.js
  • js/spread/spread.js
  • js/template/parenthesis.js
  • js/unary-expression/urnary_expression.js
  • js/yield/arrow.js
  • js/yield/conditional.js
  • js/yield/jsx.js
@MichaReiser MichaReiser added the A-Formatter Area: formatter label Apr 14, 2022
@ematipico ematipico added the I-Normal Implementation: normal understanding of the tool and awareness label May 5, 2022
@ematipico
Copy link
Contributor

FYI, our formatting architecture is different from prettier's:

  • By default they always remove parenthesis and they have a function that tells the IR to not remove them.
  • We format by node, they use a different strategy. Which means that check of parenthesis in our case must be done on node level, no need to recreate prettier's function.

@MichaReiser
Copy link
Contributor Author

Closed by #3057

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter I-Normal Implementation: normal understanding of the tool and awareness
Projects
Status: Done
Development

No branches or pull requests

2 participants