-
Notifications
You must be signed in to change notification settings - Fork 660
fix(rome_js_formatter): Single-line comment below a JSX prop triggers… #3641
Conversation
✅ Deploy Preview for docs-rometools canceled.
|
@@ -25,7 +25,6 @@ impl FormatNodeRule<JsxClosingElement> for FormatJsxClosingElement { | |||
l_angle_token.format(), | |||
slash_token.format(), | |||
name.format(), | |||
line_suffix_boundary(), |
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.
I'm not sure if this is safe or is it handled inside of the name formatting?. What happens for:
<div>content</div // comment
>
It seems that prettier has some explicit comment handling that we do not.
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.
fixed.
added a test case.
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.
Did you push the latest changes?
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.
I did,
I reverted changes for the file and added test case
let b = (
<section>
<div>
aVeryLongCOntentThat
</div // comment
>
</section>
);
@@ -45,7 +45,6 @@ impl Format<JsFormatContext> for JsxAnyOpeningElement { | |||
l_angle_token.format(), | |||
name.format(), | |||
type_arguments.format(), | |||
line_suffix_boundary(), |
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.
... the main reason this is safe because the Inline
layout guarantees that neither the name, type arguments have any comments and arguments is obviously empty :)
… different formatting rome#3598
5a1618a
to
5f01e6f
Compare
@@ -45,7 +45,6 @@ impl Format<JsFormatContext> for JsxAnyOpeningElement { | |||
l_angle_token.format(), | |||
name.format(), | |||
type_arguments.format(), | |||
line_suffix_boundary(), |
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.
... the main reason this is safe because the Inline
layout guarantees that neither the name, type arguments have any comments and arguments is obviously empty :)
* upstream/main: (45 commits) website(docs): set `color-scheme` on the root element (rome#3721) feat(rome_analyze): add a warning for unused suppression comments (rome#3718) feat(rome_js_analyze): Implement prefer-numeric-literals lint (rome#3558) feat(rome_js_formatter): jestEach template literals rome#3308 (rome#3582) doc(website): Add context about Romes philosophy (rome#3714) fix(rome_js_formatter): Single-line comment below a JSX prop triggers… (rome#3641) test(rome_js_formatter): update prettier tests (rome#3684) fix(rome_js_parser): improve await handling in non-async context (rome#3573) fix(rome_js_parser): improve yield parsing in non generator function (rome#3622) More playground polish Fix backgrounds Fix height Align docs.rome.tools with rome.tools Reenable compression Add missing width website(docs): More playground IDE features (rome#3711) fix(rome_js_formatter): new expression attribute (rome#3686) docs(website): added checkbox to toggle linter in playground (rome#3699) website(docs): More website tweaks (rome#3707) website(docs): Add default layout property (rome#3705) ...
Summary
Fix #3598
Try to make the same IR as Prettier has based on:
https://github.com/prettier/prettier/blob/5e0b88329e54df515d84dc33d6fc38c2cb176678/src/language-js/print/jsx.js#L567-L601
https://github.com/prettier/prettier/blob/5e0b88329e54df515d84dc33d6fc38c2cb176678/src/language-js/print/jsx.js#L643-L665
There is no
line_suffix_boundary
Test Plan
cargo test -p rome_js_formatter