File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
crates/oxc_linter/src/rules/unicorn Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,9 @@ impl Rule for SwitchCaseBraces {
9696 }
9797
9898 fn run < ' a > ( & self , node : & AstNode < ' a > , ctx : & LintContext < ' a > ) {
99+ let switch_clause_regex =
100+ Regex :: new ( r#"(case|default)\s*(`.+`|'.+'|".+"|[^:]*):"# ) . unwrap ( ) ;
101+
99102 let AstKind :: SwitchStatement ( switch) = node. kind ( ) else {
100103 return ;
101104 } ;
@@ -143,9 +146,10 @@ impl Rule for SwitchCaseBraces {
143146 } ;
144147
145148 if self . always_braces && missing_braces {
146- let regex = Regex :: new ( r#"(case|default)\s*(`.+`|'.+'|".+"|[^:]*):"# ) . unwrap ( ) ;
147- let colon_end =
148- u32:: try_from ( regex. find ( ctx. source_range ( case. span ) ) . unwrap ( ) . end ( ) ) . unwrap ( ) ;
149+ let colon_end = u32:: try_from (
150+ switch_clause_regex. find ( ctx. source_range ( case. span ) ) . unwrap ( ) . end ( ) ,
151+ )
152+ . unwrap ( ) ;
149153 let span = Span :: sized ( case. span . start , colon_end) ;
150154 ctx. diagnostic_with_fix (
151155 switch_case_braces_diagnostic_missing_braces ( span) ,
You can’t perform that action at this time.
0 commit comments