-
Notifications
You must be signed in to change notification settings - Fork 660
feat(rome_js_formatter): EcmaScript @decorators #4252 #4442
Conversation
✅ Deploy Preview for docs-rometools ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
soft_line_break_or_space(), | ||
&FormatClass::from(&node.clone().into()), | ||
]), | ||
soft_line_break_or_space() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f.join_with(&soft_line_break_or_space()) | ||
.entries(node.iter().formatted()) | ||
.finish()?; | ||
// we need to rearrange decorators to be before export if we have decorators before class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut join = f.join_nodes_with_soft_line(); | ||
|
||
// join only decorators here | ||
while let Some(node) = iter.peek() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -941,6 +941,8 @@ pub(crate) fn should_break_after_operator( | |||
}) | |||
} | |||
|
|||
AnyJsExpression::JsClassExpression(class) => !class.decorators().is_empty(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
fn needs_parentheses(&self, item: &JsClassExpression) -> bool { | ||
item.needs_parentheses() | ||
!item.decorators().is_empty() || item.needs_parentheses() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! 🏆 Let's ship it!
Co-authored-by: Emanuele Stoppa <[email protected]>
Summary
This PR implements the decorator formatting.
https://github.com/prettier/prettier/blob/main/src/language-js/print/decorators.js
Test Plan
cargo test -p rome_js_formatter
Changelog
Documentation