Skip to content

Commit

Permalink
refactor(biome_analyze): add RuleAction::new
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed May 12, 2024
1 parent 0b68e30 commit f68d593
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 16 additions & 0 deletions crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,22 @@ pub struct RuleAction<L: Language> {
pub mutation: BatchMutation<L>,
}

impl<L: Language> RuleAction<L> {
pub fn new(
category: ActionCategory,
applicability: Applicability,
message: MarkupBuf,
mutation: BatchMutation<L>,
) -> Self {
Self {
category,
applicability,
message,
mutation,
}
}
}

/// An action meant to suppress a lint rule
#[derive(Clone)]
pub struct SuppressAction<L: Language> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ impl Rule for OrganizeImports {
let mut mutation = ctx.root().begin();
mutation.replace_node_discard_trivia(old_list, new_list);

Some(JsRuleAction {
category: ActionCategory::Source(SourceActionKind::OrganizeImports),
applicability: Applicability::MaybeIncorrect,
message: markup! { "Organize Imports (Biome)" }.to_owned(),
Some(JsRuleAction::new(
ActionCategory::Source(SourceActionKind::OrganizeImports),
Applicability::MaybeIncorrect,
markup! { "Organize Imports (Biome)" }.to_owned(),
mutation,
})
))
}
}

Expand Down

0 comments on commit f68d593

Please sign in to comment.