diff --git a/crates/oxc_linter/src/rules/eslint/guard_for_in.rs b/crates/oxc_linter/src/rules/eslint/guard_for_in.rs index 526709178..34ddcf2fc 100644 --- a/crates/oxc_linter/src/rules/eslint/guard_for_in.rs +++ b/crates/oxc_linter/src/rules/eslint/guard_for_in.rs @@ -5,7 +5,7 @@ use oxc_diagnostics::{ thiserror::Error, }; use oxc_macros::declare_oxc_lint; -use oxc_span::Span; +use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -68,7 +68,7 @@ impl Rule for GuardForIn { } ctx.diagnostic(GuardForInDiagnostic(Span::new( for_in_statement.span.start, - for_in_statement.span.end, + for_in_statement.right.span().end + 1, ))); } } diff --git a/crates/oxc_linter/src/snapshots/guard_for_in.snap b/crates/oxc_linter/src/snapshots/guard_for_in.snap index 6743d969c..8ec591f3d 100644 --- a/crates/oxc_linter/src/snapshots/guard_for_in.snap +++ b/crates/oxc_linter/src/snapshots/guard_for_in.snap @@ -5,41 +5,41 @@ expression: guard_for_in ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) { if (x) { f(); continue; } g(); } - · ─────────────────────────────────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype. ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) { if (x) { continue; f(); } g(); } - · ─────────────────────────────────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype. ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) { if (x) { f(); } g(); } - · ───────────────────────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype. ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) { if (x) f(); g(); } - · ───────────────────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype. ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) { foo() } - · ────────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype. ⚠ eslint(guard-for-in): Require `for-in` loops to include an `if` statement ╭─[guard_for_in.tsx:1:1] 1 │ for (var x in o) foo(); - · ─────────────────────── + · ──────────────── ╰──── help: The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.