mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): fix guard_for_in span error (#2755)
As talked here https://github.com/oxc-project/oxc/pull/2746#discussion_r1528145418 errors in guard_for_in could be improved so I attempted to improve it. If anyone have a suggestion for the span element positions say me! --------- Co-authored-by: j.buendia <j.buendia>
This commit is contained in:
parent
86d006e171
commit
a671d754df
2 changed files with 8 additions and 8 deletions
|
|
@ -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,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue