File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -64,15 +64,18 @@ impl Rule for NoCaseDeclarations {
64
64
}
65
65
Statement :: VariableDeclaration ( var) if var. kind . is_lexical ( ) => {
66
66
let start = var. span . start ;
67
- let end = match var. kind {
67
+ let len = match var. kind {
68
68
VariableDeclarationKind :: Const | VariableDeclarationKind :: Using => 5 ,
69
69
VariableDeclarationKind :: Let => 3 ,
70
+ #[ expect( clippy:: cast_possible_truncation) ]
70
71
VariableDeclarationKind :: AwaitUsing => {
71
- var. declarations [ 0 ] . span . start - start
72
+ ctx. source_range ( Span :: new ( start, var. declarations [ 0 ] . span . start ) )
73
+ . trim_end ( )
74
+ . len ( ) as u32
72
75
}
73
76
VariableDeclarationKind :: Var => unreachable ! ( ) ,
74
77
} ;
75
- let end = start + end ;
78
+ let end = start + len ;
76
79
ctx. diagnostic ( no_case_declarations_diagnostic ( Span :: new ( start, end) ) ) ;
77
80
}
78
81
_ => { }
Original file line number Diff line number Diff line change @@ -58,5 +58,5 @@ source: crates/oxc_linter/src/tester.rs
58
58
⚠ eslint (no - case - declarations ): Unexpected lexical declaration in case block .
59
59
╭─[no_case_declarations .tsx :1 :23 ]
60
60
1 │ switch (a ) { default : await using x = {}; break ; }
61
- · ────────────
61
+ · ───────────
62
62
╰────
You can’t perform that action at this time.
0 commit comments