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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/seven-glasses-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@biomejs/biome": patch
---

Fixed [#7130](https://github.com/biomejs/biome/issues/7130). Removed the emission of a false-positive diagnostic. Biome no longer emits the following diagnostic:
```
lib/main.ts:1:5 suppressions/unused ━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Suppression comment has no effect because the tool is not enabled.

> 1 │ /** biome-ignore-all assist/source/organizeImports: For the lib root file, we don't want to organize exports */
│ ^^^^^^^^^^^^^^^^

```
20 changes: 0 additions & 20 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ pub struct Analyzer<'analyzer, L: Language, Matcher, Break, Diag> {
suppression_action: Box<dyn SuppressionAction<Language = L>>,
/// Handles analyzer signals emitted by individual rules
emit_signal: SignalHandler<'analyzer, L, Break>,
/// The rule categories used during the run of the analyzer
categories: RuleCategories,
}

pub struct AnalyzerContext<'a, L: Language> {
Expand All @@ -113,7 +111,6 @@ where
parse_suppression_comment: SuppressionParser<Diag>,
suppression_action: Box<dyn SuppressionAction<Language = L>>,
emit_signal: SignalHandler<'analyzer, L, Break>,
categories: RuleCategories,
) -> Self {
Self {
phases: BTreeMap::new(),
Expand All @@ -123,7 +120,6 @@ where
parse_suppression_comment,
suppression_action,
emit_signal,
categories,
}
}

Expand All @@ -150,7 +146,6 @@ where
mut emit_signal,
suppression_action,
metadata: _,
categories,
} = self;

let mut line_index = 0;
Expand All @@ -171,7 +166,6 @@ where
suppression_action: suppression_action.as_ref(),
options: ctx.options,
suppressions: &mut suppressions,
categories,
deny_top_level_suppressions: false,
};

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

if !self.categories.contains(suppression.category) {
let signal = DiagnosticSignal::new(|| {
AnalyzerSuppressionDiagnostic::new(
category!("suppressions/unused"),
suppression.ignore_range.unwrap_or(range),
"Suppression comment has no effect because the tool is not enabled.",
)
});
(self.emit_signal)(&signal)?;
continue;
}

if let Err(diagnostic) = self.suppressions.push_suppression(
&suppression,
range,
Expand Down
5 changes: 2 additions & 3 deletions crates/biome_analyze/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ mod tests {
use super::MatchQueryParams;
use crate::{
Analyzer, AnalyzerContext, AnalyzerSignal, ApplySuppression, ControlFlow, MetadataRegistry,
Never, Phases, QueryMatcher, RuleCategories, RuleCategory, RuleKey, ServiceBag,
SignalEntry, SuppressionAction, SyntaxVisitor, signals::DiagnosticSignal,
Never, Phases, QueryMatcher, RuleCategory, RuleKey, ServiceBag, SignalEntry,
SuppressionAction, SyntaxVisitor, signals::DiagnosticSignal,
};
use crate::{AnalyzerOptions, AnalyzerSuppression};
use biome_diagnostics::{Diagnostic, Severity};
Expand Down Expand Up @@ -425,7 +425,6 @@ mod tests {
parse_suppression_comment,
Box::new(TestAction),
&mut emit_signal,
RuleCategories::all(),
);

analyzer.add_visitor(Phases::Syntax, Box::<SyntaxVisitor<RawLanguage>>::default());
Expand Down
6 changes: 2 additions & 4 deletions crates/biome_analyze/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleCategories, RuleGroup,
RuleKey, RuleMetadata, ServiceBag, SignalEntry, Visitor,
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleGroup, RuleKey,
RuleMetadata, ServiceBag, SignalEntry, Visitor,
context::RuleContext,
matcher::{GroupKey, MatchQueryParams},
query::{QueryKey, Queryable},
Expand Down Expand Up @@ -240,7 +240,6 @@ type BuilderResult<L> = (
ServiceBag,
Vec<Error>,
BTreeMap<(Phases, TypeId), Box<dyn Visitor<Language = L>>>,
RuleCategories,
);

impl<L: Language> RuleRegistryBuilder<'_, L> {
Expand All @@ -250,7 +249,6 @@ impl<L: Language> RuleRegistryBuilder<'_, L> {
self.services,
self.diagnostics,
self.visitors,
self.filter.categories,
)
}
}
Expand Down
5 changes: 2 additions & 3 deletions crates/biome_analyze/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ mod tests {

use crate::{
Analyzer, AnalyzerContext, AnalyzerOptions, AnalyzerSignal, ApplySuppression, ControlFlow,
MetadataRegistry, Never, QueryMatcher, RuleCategoriesBuilder, ServiceBag,
SuppressionAction, SyntaxVisitor, matcher::MatchQueryParams, registry::Phases,
MetadataRegistry, Never, QueryMatcher, ServiceBag, SuppressionAction, SyntaxVisitor,
matcher::MatchQueryParams, registry::Phases,
};

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

analyzer.add_visitor(Phases::Syntax, Box::<SyntaxVisitor<RawLanguage>>::default());
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_css_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ where
let mut registry = RuleRegistry::builder(&filter, root);
visit_registry(&mut registry);

let (registry, services, diagnostics, visitors, categories) = registry.build();
let (registry, services, diagnostics, visitors) = registry.build();

// Bail if we can't parse a rule option
if !diagnostics.is_empty() {
Expand All @@ -109,7 +109,6 @@ where
parse_linter_suppression_comment,
Box::new(CssSuppressionAction),
&mut emit_signal,
categories,
);

for plugin in plugins {
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_graphql_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
let mut registry = RuleRegistry::builder(&filter, root);
visit_registry(&mut registry);

let (registry, services, diagnostics, visitors, categories) = registry.build();
let (registry, services, diagnostics, visitors) = registry.build();

// Bail if we can't parse a rule option
if !diagnostics.is_empty() {
Expand All @@ -102,7 +102,6 @@ where
parse_linter_suppression_comment,
Box::new(GraphqlSuppressionAction),
&mut emit_signal,
categories,
);

for ((phase, _), visitor) in visitors {
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_js_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
source_type,
} = services;

let (registry, mut services, diagnostics, visitors, categories) = registry.build();
let (registry, mut services, diagnostics, visitors) = registry.build();

// Bail if we can't parse a rule option
if !diagnostics.is_empty() {
Expand All @@ -133,7 +133,6 @@ where
parse_linter_suppression_comment,
Box::new(JsSuppressionAction),
&mut emit_signal,
categories,
);

for plugin in plugins {
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_js_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
let mut registry = RuleRegistry::builder(&filter, root);
visit_transformation_registry(&mut registry);

let (registry, mut services, diagnostics, visitors, categories) = registry.build();
let (registry, mut services, diagnostics, visitors) = registry.build();

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

for ((phase, _), visitor) in visitors {
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_json_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ where
let mut registry = RuleRegistry::builder(&filter, root);
visit_registry(&mut registry);

let (registry, mut services, diagnostics, visitors, categories) = registry.build();
let (registry, mut services, diagnostics, visitors) = registry.build();

// Bail if we can't parse a rule option
if !diagnostics.is_empty() {
Expand All @@ -105,7 +105,6 @@ where
parse_linter_suppression_comment,
Box::new(JsonSuppressionAction),
&mut emit_signal,
categories,
);

for ((phase, _), visitor) in visitors {
Expand Down
3 changes: 1 addition & 2 deletions crates/biome_migrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
let mut registry = RuleRegistry::builder(&filter, root);
visit_migration_registry(&mut registry);

let (migration_registry, mut services, diagnostics, visitors, categories) = registry.build();
let (migration_registry, mut services, diagnostics, visitors) = registry.build();

// Bail if we can't parse a rule option
if !diagnostics.is_empty() {
Expand Down Expand Up @@ -91,7 +91,6 @@ where
|_, _| -> Vec<Result<_, Infallible>> { Default::default() },
Box::new(TestAction),
&mut emit_signal,
categories,
);

for ((phase, _), visitor) in visitors {
Expand Down
Loading