biome
biome copied to clipboard
feat(cli/lint): add `--rule` option
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.
Parser conformance results on
js/262
Test result | main count |
This PR count | Difference |
---|---|---|---|
Total | 49701 | 49701 | 0 |
Passed | 48721 | 48721 | 0 |
Failed | 980 | 980 | 0 |
Panics | 0 | 0 | 0 |
Coverage | 98.03% | 98.03% | 0.00% |
jsx/babel
Test result | main count |
This PR count | Difference |
---|---|---|---|
Total | 40 | 40 | 0 |
Passed | 37 | 37 | 0 |
Failed | 3 | 3 | 0 |
Panics | 0 | 0 | 0 |
Coverage | 92.50% | 92.50% | 0.00% |
symbols/microsoft
Test result | main count |
This PR count | Difference |
---|---|---|---|
Total | 6322 | 6322 | 0 |
Passed | 2036 | 2036 | 0 |
Failed | 4286 | 4286 | 0 |
Panics | 0 | 0 | 0 |
Coverage | 32.20% | 32.20% | 0.00% |
ts/babel
Test result | main count |
This PR count | Difference |
---|---|---|---|
Total | 662 | 662 | 0 |
Passed | 593 | 593 | 0 |
Failed | 69 | 69 | 0 |
Panics | 0 | 0 | 0 |
Coverage | 89.58% | 89.58% | 0.00% |
ts/microsoft
Test result | main count |
This PR count | Difference |
---|---|---|---|
Total | 17646 | 17646 | 0 |
Passed | 13439 | 13439 | 0 |
Failed | 4205 | 4205 | 0 |
Panics | 2 | 2 | 0 |
Coverage | 76.16% | 76.16% | 0.00% |
You use the following phrase inside the doc comments, but what does that mean? I believe it requires more explanation. The phrase is too opaque.
The configuration is taken into account.
CodSpeed Performance Report
Merging #2860 will improve performances by 6.09%
Comparing conaclos/cli-rule-option
(2b9c194) with main
(78d70d2)
Summary
⚡ 1
improvements
✅ 98
untouched benchmarks
Benchmarks breakdown
Benchmark | main |
conaclos/cli-rule-option |
Change | |
---|---|---|---|---|
⚡ | pure.css[uncached] |
25.8 ms | 24.4 ms | +6.09% |
@Conaclos you forgot to address
taking the configurations file into account
It's still somewhere inside the doc comments and in the description of the PR. Could you please make sure to follow up? I still find that phrase opaque. I truly don't understand what it means 😅
It's still somewhere inside the doc comments and in the description of the PR. Could you please make sure to follow up? I still find that phrase opaque. I truly don't understand what it means 😅
I made the following changes:
Run only the given rule taking the configurations into account
Then I changed to:
Run only the given rule taking the rule options in the configuration file into account
And so:
Run only the given rule or rule group taking the configuration file into account
I am unsure how to address your concern
What I don't understand is what "taking the configuration file into account" mean. It's very generic. I know you explained that in some comments, it would great to use that explanation here:
The severity of groups and rules configured in the configuration file won't change.