Open anthonyshew opened 5 hours ago
I personally don't have any problems with the --write-suppressions="TODO: message"
flag. IMO, that's about as good as its gonna get. This will definitely be super valuable for migrating. My only suggestion is that there be a default message if none is provided, something to indicate it was automatically generated.
As for code pointers, I don't have perfect context on how suppressions are implemented. But from just a quick look around, I don't think it will be that difficult. You'll probably want to look at:
Rule
trait's suppress
method, because we already have a LSP code action to suppress lints. (this is probably the most useful one) https://github.com/biomejs/biome/blob/76a4f1a0ac4cfa63244d19c1f8c18a2defbc920b/crates/biome_analyze/src/rule.rs#L868biome_analyze::handle_comment()
biome_suppression
crate (as comment syntaxes are in there)SuppressionAction::find_token_to_apply_suppression()
Description
As described in this discussion and in Discord, it would be great to have an option to write in ignores for existing rule violations.
I stumbled upon the need for this feature while working on migrating a large codebase to Biome. There are rules I'd like to activate that have hundreds and thousands of violations, but I can't reasonably fix them all in one PR. I can use some creative override patterning to get it done, but an easier way would be to set ignores for them and follow up with PRs to fix those ignores. There are likely other use cases for this feature, as well.
I will be starting work on this feature momentarily, having received prior blessings from @ematipico and @Conaclos at that Discord pointer.
Open questions:
biome lint . --write-suppressions
while I work but can name it whatever the crowd prefers.// biome-ignore the/rule/name: <explanation>
, so I'd like to allow for an explanation withbiome lint . --write-suppressions="TODO: Fix Biome migration ignores."
, where my string would become the<explanation>
. If not provided, a default explanation will be provided (or we could just let it be<explanation>
?). Any thoughts here on what to provide for a default? And does that API sound good?