Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7638e84

Browse files
authored
fix(analyzer): remove unhelpful diagnostic (#7295)
1 parent 28cc996 commit 7638e84

File tree

11 files changed

+26
-42
lines changed

11 files changed

+26
-42
lines changed

.changeset/seven-glasses-attack.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7130](https://github.com/biomejs/biome/issues/7130). Removed the emission of a false-positive diagnostic. Biome no longer emits the following diagnostic:
6+
```
7+
lib/main.ts:1:5 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━
8+
9+
⚠ Suppression comment has no effect because the tool is not enabled.
10+
11+
> 1 │ /** biome-ignore-all assist/source/organizeImports: For the lib root file, we don't want to organize exports */
12+
│ ^^^^^^^^^^^^^^^^
13+
14+
```

crates/biome_analyze/src/lib.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ pub struct Analyzer<'analyzer, L: Language, Matcher, Break, Diag> {
8888
suppression_action: Box<dyn SuppressionAction<Language = L>>,
8989
/// Handles analyzer signals emitted by individual rules
9090
emit_signal: SignalHandler<'analyzer, L, Break>,
91-
/// The rule categories used during the run of the analyzer
92-
categories: RuleCategories,
9391
}
9492

9593
pub struct AnalyzerContext<'a, L: Language> {
@@ -113,7 +111,6 @@ where
113111
parse_suppression_comment: SuppressionParser<Diag>,
114112
suppression_action: Box<dyn SuppressionAction<Language = L>>,
115113
emit_signal: SignalHandler<'analyzer, L, Break>,
116-
categories: RuleCategories,
117114
) -> Self {
118115
Self {
119116
phases: BTreeMap::new(),
@@ -123,7 +120,6 @@ where
123120
parse_suppression_comment,
124121
suppression_action,
125122
emit_signal,
126-
categories,
127123
}
128124
}
129125

@@ -150,7 +146,6 @@ where
150146
mut emit_signal,
151147
suppression_action,
152148
metadata: _,
153-
categories,
154149
} = self;
155150

156151
let mut line_index = 0;
@@ -171,7 +166,6 @@ where
171166
suppression_action: suppression_action.as_ref(),
172167
options: ctx.options,
173168
suppressions: &mut suppressions,
174-
categories,
175169
deny_top_level_suppressions: false,
176170
};
177171

@@ -329,8 +323,6 @@ struct PhaseRunner<'analyzer, 'phase, L: Language, Matcher, Break, Diag> {
329323
options: &'phase AnalyzerOptions,
330324
/// Tracks all suppressions during the analyzer phase
331325
suppressions: &'phase mut Suppressions<'analyzer>,
332-
/// The current categories
333-
categories: RuleCategories,
334326
/// Whether we have already encountered a token that can't precede top level suppressions
335327
deny_top_level_suppressions: bool,
336328
}
@@ -573,18 +565,6 @@ where
573565
(self.emit_signal)(&signal)?;
574566
}
575567

576-
if !self.categories.contains(suppression.category) {
577-
let signal = DiagnosticSignal::new(|| {
578-
AnalyzerSuppressionDiagnostic::new(
579-
category!("suppressions/unused"),
580-
suppression.ignore_range.unwrap_or(range),
581-
"Suppression comment has no effect because the tool is not enabled.",
582-
)
583-
});
584-
(self.emit_signal)(&signal)?;
585-
continue;
586-
}
587-
588568
if let Err(diagnostic) = self.suppressions.push_suppression(
589569
&suppression,
590570
range,

crates/biome_analyze/src/matcher.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ mod tests {
210210
use super::MatchQueryParams;
211211
use crate::{
212212
Analyzer, AnalyzerContext, AnalyzerSignal, ApplySuppression, ControlFlow, MetadataRegistry,
213-
Never, Phases, QueryMatcher, RuleCategories, RuleCategory, RuleKey, ServiceBag,
214-
SignalEntry, SuppressionAction, SyntaxVisitor, signals::DiagnosticSignal,
213+
Never, Phases, QueryMatcher, RuleCategory, RuleKey, ServiceBag, SignalEntry,
214+
SuppressionAction, SyntaxVisitor, signals::DiagnosticSignal,
215215
};
216216
use crate::{AnalyzerOptions, AnalyzerSuppression};
217217
use biome_diagnostics::{Diagnostic, Severity};
@@ -425,7 +425,6 @@ mod tests {
425425
parse_suppression_comment,
426426
Box::new(TestAction),
427427
&mut emit_signal,
428-
RuleCategories::all(),
429428
);
430429

431430
analyzer.add_visitor(Phases::Syntax, Box::<SyntaxVisitor<RawLanguage>>::default());

crates/biome_analyze/src/registry.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2-
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleCategories, RuleGroup,
3-
RuleKey, RuleMetadata, ServiceBag, SignalEntry, Visitor,
2+
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleGroup, RuleKey,
3+
RuleMetadata, ServiceBag, SignalEntry, Visitor,
44
context::RuleContext,
55
matcher::{GroupKey, MatchQueryParams},
66
query::{QueryKey, Queryable},
@@ -240,7 +240,6 @@ type BuilderResult<L> = (
240240
ServiceBag,
241241
Vec<Error>,
242242
BTreeMap<(Phases, TypeId), Box<dyn Visitor<Language = L>>>,
243-
RuleCategories,
244243
);
245244

246245
impl<L: Language> RuleRegistryBuilder<'_, L> {
@@ -250,7 +249,6 @@ impl<L: Language> RuleRegistryBuilder<'_, L> {
250249
self.services,
251250
self.diagnostics,
252251
self.visitors,
253-
self.filter.categories,
254252
)
255253
}
256254
}

crates/biome_analyze/src/syntax.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ mod tests {
100100

101101
use crate::{
102102
Analyzer, AnalyzerContext, AnalyzerOptions, AnalyzerSignal, ApplySuppression, ControlFlow,
103-
MetadataRegistry, Never, QueryMatcher, RuleCategoriesBuilder, ServiceBag,
104-
SuppressionAction, SyntaxVisitor, matcher::MatchQueryParams, registry::Phases,
103+
MetadataRegistry, Never, QueryMatcher, ServiceBag, SuppressionAction, SyntaxVisitor,
104+
matcher::MatchQueryParams, registry::Phases,
105105
};
106106

107107
#[derive(Default)]
@@ -191,7 +191,6 @@ mod tests {
191191
|_, _| -> Vec<Result<_, Infallible>> { unreachable!() },
192192
Box::new(TestAction),
193193
&mut emit_signal,
194-
RuleCategoriesBuilder::default().with_syntax().build(),
195194
);
196195

197196
analyzer.add_visitor(Phases::Syntax, Box::<SyntaxVisitor<RawLanguage>>::default());

crates/biome_css_analyze/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
let mut registry = RuleRegistry::builder(&filter, root);
9797
visit_registry(&mut registry);
9898

99-
let (registry, services, diagnostics, visitors, categories) = registry.build();
99+
let (registry, services, diagnostics, visitors) = registry.build();
100100

101101
// Bail if we can't parse a rule option
102102
if !diagnostics.is_empty() {
@@ -109,7 +109,6 @@ where
109109
parse_linter_suppression_comment,
110110
Box::new(CssSuppressionAction),
111111
&mut emit_signal,
112-
categories,
113112
);
114113

115114
for plugin in plugins {

crates/biome_graphql_analyze/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ where
8989
let mut registry = RuleRegistry::builder(&filter, root);
9090
visit_registry(&mut registry);
9191

92-
let (registry, services, diagnostics, visitors, categories) = registry.build();
92+
let (registry, services, diagnostics, visitors) = registry.build();
9393

9494
// Bail if we can't parse a rule option
9595
if !diagnostics.is_empty() {
@@ -102,7 +102,6 @@ where
102102
parse_linter_suppression_comment,
103103
Box::new(GraphqlSuppressionAction),
104104
&mut emit_signal,
105-
categories,
106105
);
107106

108107
for ((phase, _), visitor) in visitors {

crates/biome_js_analyze/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ where
121121
source_type,
122122
} = services;
123123

124-
let (registry, mut services, diagnostics, visitors, categories) = registry.build();
124+
let (registry, mut services, diagnostics, visitors) = registry.build();
125125

126126
// Bail if we can't parse a rule option
127127
if !diagnostics.is_empty() {
@@ -134,7 +134,6 @@ where
134134
parse_linter_suppression_comment,
135135
Box::new(JsSuppressionAction),
136136
&mut emit_signal,
137-
categories,
138137
);
139138

140139
for plugin in plugins {

crates/biome_js_transform/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
let mut registry = RuleRegistry::builder(&filter, root);
4646
visit_transformation_registry(&mut registry);
4747

48-
let (registry, mut services, diagnostics, visitors, categories) = registry.build();
48+
let (registry, mut services, diagnostics, visitors) = registry.build();
4949

5050
// Bail if we can't parse a rule option
5151
if !diagnostics.is_empty() {
@@ -92,7 +92,6 @@ where
9292
|_, _| -> Vec<Result<_, Infallible>> { unreachable!() },
9393
Box::new(TestAction),
9494
&mut emit_signal,
95-
categories,
9695
);
9796

9897
for ((phase, _), visitor) in visitors {

crates/biome_json_analyze/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
let mut registry = RuleRegistry::builder(&filter, root);
9393
visit_registry(&mut registry);
9494

95-
let (registry, mut services, diagnostics, visitors, categories) = registry.build();
95+
let (registry, mut services, diagnostics, visitors) = registry.build();
9696

9797
// Bail if we can't parse a rule option
9898
if !diagnostics.is_empty() {
@@ -105,7 +105,6 @@ where
105105
parse_linter_suppression_comment,
106106
Box::new(JsonSuppressionAction),
107107
&mut emit_signal,
108-
categories,
109108
);
110109

111110
for ((phase, _), visitor) in visitors {

0 commit comments

Comments
 (0)