biome
biome copied to clipboard
📎 Implement `biome lint --rule=<rule-name>`
Description
Executing biome lint --rule=<rule-name>
should only run the rule with name <rule-name>
, otherwise it will throw an error. See rome#4747 for more context.
EDIT: --rule=<rule-name>
should override the config, i.e. run <rule-name>
even if the rule is disabled in the config. However, the rule options and severity level should be taken into account.
If the option is combined with --summary
(e.g. biome lint --summary --rule=<rule-name>
) we should restrict the summary to <rule-name>
. See #57 for more details about the --summary
option.
An example:
$ biome lint --rule useSingleCaseStatement src
src/services/types.ts:1121:5 lint/nursery/useNamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This property name should be in camelCase.
> 1121 │ InsertSpaceAfterConstructor?: boolean;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
ℹ The name could be renamed to `insertSpaceAfterConstructor`.
$ biome lint --summary --rule useSingleCaseStatement src
Rule name Diagnostics
nursery/useSingleCaseStatement 1
Possible extensions
- Multi rule filtering (keeping diagnostics of a given set of rules)
- reverse filtering, i.e. keeping all diagnostics except the diagnostics of a given rule
I believe the description is misleading. Or maybe I didn't understand.
I would expect that Biome will run the codebase only against the rule passed by CLI, I wouldn't expect to run all rules and then filter the result.
Did I misunderstand the proposal?
Updated :)
Can this option be paired with --apply
and --apply-unsafe
?
Can this option be paired with
--apply
and--apply-unsafe
?
I don't see any blocker :) Composability is great.
This could also be good to expose this option in the playground. Someone testing the rule in the playground could then focus on the behavior of the rule without triggering other rules. This could allow also adding a Try this rule
on every rule's page.