This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rome_js_formatter): class property members as assignment like (#…
- Loading branch information
Showing
8 changed files
with
146 additions
and
84 deletions.
There are no files selected for viewing
30 changes: 5 additions & 25 deletions
30
crates/rome_js_formatter/src/js/classes/property_class_member.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,18 @@ | ||
use crate::prelude::*; | ||
use rome_formatter::{format_args, write}; | ||
|
||
use crate::utils::FormatWithSemicolon; | ||
|
||
use crate::utils::{FormatWithSemicolon, JsAnyAssignmentLike}; | ||
use rome_formatter::write; | ||
use rome_js_syntax::JsPropertyClassMember; | ||
use rome_js_syntax::JsPropertyClassMemberFields; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub struct FormatJsPropertyClassMember; | ||
|
||
impl FormatNodeRule<JsPropertyClassMember> for FormatJsPropertyClassMember { | ||
fn fmt_fields(&self, node: &JsPropertyClassMember, f: &mut JsFormatter) -> FormatResult<()> { | ||
let JsPropertyClassMemberFields { | ||
modifiers, | ||
name, | ||
property_annotation, | ||
value, | ||
semicolon_token, | ||
} = node.as_fields(); | ||
|
||
let semicolon_token = node.semicolon_token(); | ||
let body = format_with(|f| write!(f, [JsAnyAssignmentLike::from(node.clone())])); | ||
write!( | ||
f, | ||
[FormatWithSemicolon::new( | ||
&format_args!( | ||
modifiers.format(), | ||
space_token(), | ||
name.format(), | ||
property_annotation.format(), | ||
value | ||
.format() | ||
.with_or_empty(|node, f| write![f, [space_token(), node]]), | ||
), | ||
semicolon_token.as_ref() | ||
)] | ||
[FormatWithSemicolon::new(&body, semicolon_token.as_ref())] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.