You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/biome_analyze/CONTRIBUTING.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ The analyzer allows implementors to create **three different** types of rules:
26
26
*[Biome lint rules inspired by other lint rules](#biome-lint-rules-inspired-by-other-lint-rules)
27
27
-[`rule_category!` macro](#rule_category-macro)
28
28
-[Rule severity](#rule-severity)
29
+
-[Rule group and severity](#rule-group-and-severity)
29
30
-[Rule domains](#rule-domains)
30
31
-[Rule Options](#rule-options)
31
32
*[Options for our example rule](#options-for-our-example-rule)
@@ -516,6 +517,28 @@ declare_lint_rule! {
516
517
}
517
518
```
518
519
520
+
#### Rule group and severity
521
+
522
+
> [!NOTE]
523
+
> This section is relevant to Biome maintainers when they want to move (promote) a rule to a group that is not `nursery`.
524
+
525
+
We try to maintain consistency in the default severity level and group membership of the rules.
526
+
For legacy reasons, we have some rules that don't follow these constraints.
527
+
528
+
-`correctness`, `security`, and `a11y` rules **must** have a severity set to `error`.
529
+
530
+
If `error` is too strict for a rule, then it should certainly be in another group (for example `suspicious` instead of `correctness`).
531
+
532
+
-`style` rules **must** have a severity set to `info` or `warn`. If in doubt, choose `info`.
533
+
534
+
-`complexity` rules **must** have a severity set to `warn` or `info`. If in doubt, choose `info`.
535
+
536
+
-`suspicious` rules **must** have a severity set to `warn` or `error`. If in doubt, choose `warn`.
537
+
538
+
-`performance` rules **must** have a severity set to `warn`.
539
+
540
+
- Actions **must** have a severity set to `info`.
541
+
519
542
#### Rule domains
520
543
521
544
Domains are very specific ways to collect rules that belong to the same "concept". Domains are a way for users to opt-in/opt-out rules that belong to the same domain.
@@ -548,6 +571,7 @@ Instead, if the rule is **recommended** but _doesn't have domains_, the rule is
548
571
> [!NOTE]
549
572
> Before adding a new domain, please consult with the maintainers of the project.
550
573
574
+
551
575
#### Rule Options
552
576
553
577
Some rules may allow customization [using per-rule options in `biome.json`](https://biomejs.dev/linter/#rule-options).
"The rule '{rule_name}' belongs to the group '{group}' and has a severity set to '{rule_severity}'. Rules that belong to the group {group} must have a severity set to 'error'. Set the severity to 'error' or change the group of the rule."
"The rule '{rule_name}' belongs to the group '{group}' and has a severity set to '{rule_severity}'. Rules that belong to the group '{group}' must not have a severity set to 'error'. Lower down the severity or change the group of the rule."
"The rule '{rule_name}' belongs to the group '{group}' and has a severity set to '{rule_severity}'. Rules that belong to the group '{group}' must have a severity set to 'warn'. Set the severity to 'warn' or change the group of the rule."
111
+
)));
112
+
}elseif group == "suspicious"
113
+
&& rule_severity == Severity::Information
114
+
&& !matches!(
115
+
rule_name,
116
+
// TODO: remove these exceptions in Biome 3.0
117
+
"noAlert"
118
+
| "noBitwiseOperators"
119
+
| "noConstantBinaryExpressions"
120
+
| "noUnassignedVariables"
121
+
| "useStaticResponseMethods"
122
+
| "noQuickfixBiome"
123
+
| "noDuplicateFields"
124
+
)
125
+
{
126
+
self.errors.push(Errors::new(format!(
127
+
"The rule '{rule_name}' belongs to the group '{group}' and has a severity set to '{rule_severity}'. Rules that belong to the group '{group}' must have a severity set to 'warn' or 'error'. Change the severity or change the group of the rule."
"The action '{rule_name}' has a severity set to '{rule_severity}'. Actions must have a severity set to 'info'. Set the severity of the rule to 'info'."
0 commit comments