File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
crates/oxc_linter/src/rules/eslint Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,20 @@ impl Rule for NoUnassignedVars {
6060 if declarator. init . is_some ( ) || declarator. kind . is_const ( ) {
6161 return ;
6262 }
63- let AstKind :: VariableDeclaration ( parent) = ctx. nodes ( ) . parent_kind ( node. id ( ) ) else {
63+ let parent_node = ctx. nodes ( ) . parent_node ( node. id ( ) ) ;
64+ let AstKind :: VariableDeclaration ( parent) = parent_node. kind ( ) else {
6465 return ;
6566 } ;
6667 if parent. declare {
6768 return ;
6869 }
70+ let grand_parent = ctx. nodes ( ) . parent_node ( parent_node. id ( ) ) ;
71+ if matches ! (
72+ grand_parent. kind( ) ,
73+ AstKind :: ForStatement ( _) | AstKind :: ForInStatement ( _) | AstKind :: ForOfStatement ( _)
74+ ) {
75+ return ;
76+ }
6977 if ctx
7078 . nodes ( )
7179 . ancestors ( node. id ( ) )
@@ -123,6 +131,7 @@ fn test() {
123131 export = x;
124132 }
125133 " ,
134+ "for (let p of pathToRemove) { p.remove() }" ,
126135 ] ;
127136
128137 let fail = vec ! [
You can’t perform that action at this time.
0 commit comments