File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
crates/oxc_linter/src/rules/eslint Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -84,22 +84,26 @@ impl Rule for NoInnerDeclarations {
8484
8585 let mut parent = ctx. nodes ( ) . parent_node ( node. id ( ) ) ;
8686 if let Some ( parent_node) = parent {
87- match parent_node. kind ( ) {
88- AstKind :: FunctionBody ( _) => {
89- if let Some ( grandparent) = ctx. nodes ( ) . parent_node ( parent_node. id ( ) ) {
90- if grandparent. kind ( ) . is_function_like ( ) {
91- return ;
92- }
87+ let parent_kind = parent_node. kind ( ) ;
88+ if let AstKind :: FunctionBody ( _) = parent_kind {
89+ if let Some ( grandparent) = ctx. nodes ( ) . parent_node ( parent_node. id ( ) ) {
90+ if grandparent. kind ( ) . is_function_like ( ) {
91+ return ;
9392 }
9493 }
94+ }
95+
96+ if matches ! (
97+ parent_kind,
9598 AstKind :: Program ( _)
96- | AstKind :: StaticBlock ( _)
97- | AstKind :: ExportNamedDeclaration ( _)
98- | AstKind :: ExportDefaultDeclaration ( _)
99- | AstKind :: ForStatement ( _)
100- | AstKind :: ForInStatement ( _)
101- | AstKind :: ForOfStatement ( _) => return ,
102- _ => { }
99+ | AstKind :: StaticBlock ( _)
100+ | AstKind :: ExportNamedDeclaration ( _)
101+ | AstKind :: ExportDefaultDeclaration ( _)
102+ | AstKind :: ForStatement ( _)
103+ | AstKind :: ForInStatement ( _)
104+ | AstKind :: ForOfStatement ( _)
105+ ) {
106+ return ;
103107 }
104108 }
105109
You can’t perform that action at this time.
0 commit comments