File tree Expand file tree Collapse file tree 4 files changed +75
-8
lines changed
snapshots/main_cases_suppressions Expand file tree Collapse file tree 4 files changed +75
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @biomejs/biome " : patch
3+ ---
4+
5+ Fixed [ #7877 ] ( https://github.com/biomejs/biome/issues/7877 ) : Range suppressions now handle suppressed categories properly.
6+
7+ ** Valid:**
8+
9+ ``` js
10+ // biome-ignore-start lint: explanation
11+ const foo = 1 ;
12+ // biome-ignore-end lint: explanation
13+ ```
Original file line number Diff line number Diff line change @@ -276,10 +276,12 @@ impl RangeSuppressions {
276276 }
277277
278278 let range_suppression = match filter {
279- None => {
280- self . suppressions . pop ( ) ;
281- return Ok ( ( ) ) ;
282- }
279+ None => self
280+ . suppressions
281+ . iter_mut ( )
282+ . rev ( )
283+ . filter ( |s| !s. is_ended )
284+ . find ( |s| s. suppressed_categories . contains ( suppression. category ) ) ,
283285 Some ( PLUGIN_LINT_RULE_FILTER ) => self
284286 . suppressions
285287 . iter_mut ( )
@@ -334,10 +336,13 @@ impl RangeSuppressions {
334336 if range_suppression
335337 . suppression_range
336338 . contains_range ( * position)
337- && range_suppression
338- . filters_by_category
339- . get ( rule_category)
340- . is_some_and ( |filters| filters. iter ( ) . any ( |f| f == filter) )
339+ && ( range_suppression
340+ . suppressed_categories
341+ . contains ( rule_category)
342+ || range_suppression
343+ . filters_by_category
344+ . get ( rule_category)
345+ . is_some_and ( |filters| filters. iter ( ) . any ( |f| f == filter) ) )
341346 {
342347 range_suppression. did_suppress_signal = true ;
343348 return true ;
Original file line number Diff line number Diff line change @@ -458,6 +458,37 @@ function sommething(chalk: ChalkInstance) {
458458 ) ) ;
459459}
460460
461+ #[ test]
462+ fn syntax_rule_range_suppression_category_only ( ) {
463+ let fs = MemoryFileSystem :: default ( ) ;
464+ let mut console = BufferConsole :: default ( ) ;
465+
466+ let file_path = Utf8Path :: new ( "file.ts" ) ;
467+ fs. insert (
468+ file_path. into ( ) ,
469+ * b"
470+ // biome-ignore-start lint: explanation
471+ const foo = 1;
472+ // biome-ignore-end lint: explanation" ,
473+ ) ;
474+
475+ let ( fs, result) = run_cli (
476+ fs,
477+ & mut console,
478+ Args :: from ( [ "lint" , file_path. as_str ( ) ] . as_slice ( ) ) ,
479+ ) ;
480+
481+ assert ! ( result. is_ok( ) , "run_cli returned {result:?}" ) ;
482+
483+ assert_cli_snapshot ( SnapshotPayload :: new (
484+ module_path ! ( ) ,
485+ "syntax_rule_range_suppression_category_only" ,
486+ fs,
487+ console,
488+ result,
489+ ) ) ;
490+ }
491+
461492#[ test]
462493fn syntax_rule_top_suppression ( ) {
463494 let fs = MemoryFileSystem :: default ( ) ;
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / biome_cli / tests / snap_test .rs
3+ expression : redactor (content )
4+ -- -
5+ ## ` file.ts`
6+
7+ ` ` ` ts
8+
9+ // biome-ignore-start lint: explanation
10+ const foo = 1;
11+ // biome-ignore-end lint: explanation
12+ ` ` `
13+
14+ # Emitted Messages
15+
16+ ` ` ` block
17+ Checked 1 file in <TIME >. No fixes applied.
18+ ```
You can’t perform that action at this time.
0 commit comments