biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.28k stars 442 forks source link

📎 CLI flag in linter to write ignores for existing violations #4007

Open anthonyshew opened 5 hours ago

anthonyshew commented 5 hours ago

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:

dyc3 commented 4 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: