tools icon indicating copy to clipboard operation
tools copied to clipboard

`noUnexpectedMultiline`, no-unexpected-multiline

Open ematipico opened this issue 2 years ago • 1 comments

https://eslint.org/docs/latest/rules/no-unexpected-multiline

ematipico avatar Dec 06 '22 11:12 ematipico

@MichaReiser is there some logic that we can borrow/share from the formatter, in order to implement this rule?

ematipico avatar Dec 06 '22 11:12 ematipico

👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed, S-Planned , S-Wishlist or umbrella

github-actions[bot] avatar Dec 20 '22 12:12 github-actions[bot]

@MichaReiser is there some logic that we can borrow/share from the formatter, in order to implement this rule?

Whoops. I missed this comment sorry.

yes, you can implement the needs_semicolons as a method on AnyExpressionStatement

https://github.com/rome/tools/blob/2655264565608e29229490101f7abbfa89a35598/crates/rome_js_formatter/src/js/statements/expression_statement.rs#L98-L156

You'll need to also move get_expression_left_side to rome_js_syntax but that shouldn't be difficult as well.

https://github.com/rome/tools/blob/2655264565608e29229490101f7abbfa89a35598/crates/rome_js_formatter/src/parentheses.rs#L317-L394

and here the corresponding logic for class members (in case this is something the rule should cover as well)

https://github.com/rome/tools/blob/2655264565608e29229490101f7abbfa89a35598/crates/rome_js_formatter/src/js/classes/property_class_member.rs#L93-L154

Edit: One challenge is that the expression logic calls into expression.needs_parentheses which is specific to the formatter. The linter could test if the expression is a ParenthesizedExpression.

MichaReiser avatar Dec 20 '22 12:12 MichaReiser

Closing. The formatter takes care of it, it wouldn't make sense to have a rule for it.

ematipico avatar Apr 11 '23 08:04 ematipico