|
1 | 1 | use oxc_ast::AstKind; |
2 | 2 | use oxc_diagnostics::OxcDiagnostic; |
3 | 3 | use oxc_macros::declare_oxc_lint; |
4 | | -use oxc_span::{GetSpan, Span}; |
| 4 | +use oxc_span::Span; |
5 | 5 |
|
6 | 6 | use crate::{AstNode, context::LintContext, rule::Rule}; |
7 | 7 |
|
@@ -90,17 +90,6 @@ impl Rule for NoInnerDeclarations { |
90 | 90 | | AstKind::StaticBlock(_) |
91 | 91 | | AstKind::ExportNamedDeclaration(_) |
92 | 92 | | AstKind::ExportDefaultDeclaration(_) => return, |
93 | | - AstKind::ForStatement(for_stmt) => { |
94 | | - if for_stmt.init.as_ref().is_some_and(|init| init.span() == kind.span()) { |
95 | | - return; |
96 | | - } |
97 | | - } |
98 | | - AstKind::ForInStatement(for_stmt) if for_stmt.left.span() == kind.span() => { |
99 | | - return; |
100 | | - } |
101 | | - AstKind::ForOfStatement(for_stmt) if for_stmt.left.span() == kind.span() => { |
102 | | - return; |
103 | | - } |
104 | 93 | _ => {} |
105 | 94 | } |
106 | 95 |
|
@@ -167,9 +156,6 @@ fn test() { |
167 | 156 | ("class C { method() { var x; } }", Some(serde_json::json!(["both"]))), |
168 | 157 | ("class C { static { function foo() {} } }", Some(serde_json::json!(["both"]))), |
169 | 158 | ("class C { static { var x; } }", Some(serde_json::json!(["both"]))), |
170 | | - ("for (var x in {}) {}", Some(serde_json::json!(["both"]))), |
171 | | - ("for (var x of []) {}", Some(serde_json::json!(["both"]))), |
172 | | - ("for (var x = 1; a < 10; a++) {}", Some(serde_json::json!(["both"]))), |
173 | 159 | ("for (const x in {}) { let y = 5; }", Some(serde_json::json!(["both"]))), |
174 | 160 | ("for (const x of []) { let y = 5; }", Some(serde_json::json!(["both"]))), |
175 | 161 | ("for (const x = 1; a < 10; a++) { let y = 5; }", Some(serde_json::json!(["both"]))), |
@@ -214,6 +200,9 @@ fn test() { |
214 | 200 | ("for (const x in {}) var y = 5;", Some(serde_json::json!(["both"]))), |
215 | 201 | ("for (const x of []) var y = 5;", Some(serde_json::json!(["both"]))), |
216 | 202 | ("for (const x = 1; a < 10; a++) var y = 5;", Some(serde_json::json!(["both"]))), |
| 203 | + ("for (var x in {}) {}", Some(serde_json::json!(["both"]))), |
| 204 | + ("for (var x of []) {}", Some(serde_json::json!(["both"]))), |
| 205 | + ("for (var x = 1; a < 10; a++) {}", Some(serde_json::json!(["both"]))), |
217 | 206 | ]; |
218 | 207 |
|
219 | 208 | Tester::new(NoInnerDeclarations::NAME, NoInnerDeclarations::PLUGIN, pass, fail) |
|
0 commit comments