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

Commit

Permalink
refactor: 💡 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Jul 6, 2022
1 parent cfa358f commit d303628
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions crates/rome_js_analyze/src/analyzers/no_comment_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,22 @@ impl Rule for NoCommentText {
fn action(ctx: &RuleContext<Self>, _: &Self::State) -> Option<JsRuleAction> {
let Ast(node) = ctx.query();

let normalized_jsx_text = node.text();
let normalized_comment = format!(
"/*{}*/",
node.text()
.trim_start_matches("/**")
.trim_start_matches("//")
.trim_start_matches("/*")
.trim_end_matches("*/")
);
let root = ctx.root().replace_node(
JsxAnyChild::JsxText(node.clone()),
JsxAnyChild::JsxExpressionChild(
make::jsx_expression_child(
make::token(T!['{']).with_trailing_trivia(
[(
TriviaPieceKind::MultiLineComment,
format!(
"/*{}*/",
normalized_jsx_text
.trim_start_matches("/**")
.trim_start_matches("//")
.trim_start_matches("/*")
.trim_end_matches("*/")
)
.as_str(),
normalized_comment.as_str(),
)]
.into_iter(),
),
Expand Down

0 comments on commit d303628

Please sign in to comment.