biome icon indicating copy to clipboard operation
biome copied to clipboard

feat(cli/lint): add `--rule` option

Open Conaclos opened this issue 1 month ago • 3 comments

Summary

Fix #58

This PR adds a new option --rule on the biome lint command. The option allows executing a given rule on a set of files. The configuration is taken into account. Only the severity is overridden to its default, i.e. error for recommended rules and warn for other rules. This ensures that the rule is not off. The rule is executed even if recommended is disabled. However, the rule is not executed if the linter is disabled in the configuration.

To implement this feature, I introduced a new type RuleCode that references a rule with static string slices. This allows passing the rule group/name without cloning it. I modified Rules::matches_diagnostic_code to return static string slices. It acts as a static string interner. I also added methods to set the severity level of a given rule.

The argument of the rule option is passed as parameters in the different calls.

Test Plan

I added tests.

Conaclos avatar May 14 '24 16:05 Conaclos