diff --git a/crates/oxc_linter/src/rules/react/no_children_prop.rs b/crates/oxc_linter/src/rules/react/no_children_prop.rs
index 955e9fb1e..1e16d9cdc 100644
--- a/crates/oxc_linter/src/rules/react/no_children_prop.rs
+++ b/crates/oxc_linter/src/rules/react/no_children_prop.rs
@@ -7,7 +7,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, utils::is_create_element_call, AstNode};
@@ -65,7 +65,7 @@ impl Rule for NoChildrenProp {
AstKind::JSXAttributeItem(JSXAttributeItem::Attribute(attr)) => {
let JSXAttributeName::Identifier(attr_ident) = &attr.name else { return };
if attr_ident.name == "children" {
- ctx.diagnostic(NoChildrenPropDiagnostic(attr.span));
+ ctx.diagnostic(NoChildrenPropDiagnostic(attr_ident.span));
}
}
AstKind::CallExpression(call_expr) => {
@@ -76,7 +76,7 @@ impl Rule for NoChildrenProp {
if let Some(span) = obj_expr.properties.iter().find_map(|prop| {
if let ObjectPropertyKind::ObjectProperty(prop) = prop {
if prop.key.is_specific_static_name("children") {
- return Some(prop.span);
+ return Some(prop.key.span());
}
}
diff --git a/crates/oxc_linter/src/snapshots/no_children_prop.snap b/crates/oxc_linter/src/snapshots/no_children_prop.snap
index d9a43bddb..a4c2b9246 100644
--- a/crates/oxc_linter/src/snapshots/no_children_prop.snap
+++ b/crates/oxc_linter/src/snapshots/no_children_prop.snap
@@ -12,98 +12,98 @@ expression: no_children_prop
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │
;
- · ───────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ } />;
- · ──────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ , ]} />;
- · ─────────────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ Children
;
- · ───────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement("div", {children: "Children"});
- · ────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement("div", {children: "Children"}, "Children");
- · ────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement("div", {children: React.createElement("div")});
- · ────────────────────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement("div", {children: [React.createElement("div"), React.createElement("div")]});
- · ──────────────────────────────────────────────────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │
- · ───────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement(MyComponent, {children: "Children"});
- · ────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ ;
- · ───────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement(MyComponent, {children: "Children", className: "class-name"});
- · ────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ ;
- · ───────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements
⚠ eslint-plugin-react(no-children-prop): Avoid passing children using a prop.
╭─[no_children_prop.tsx:1:1]
1 │ React.createElement(MyComponent, {...props, children: "Children"})
- · ────────────────────
+ · ────────
╰────
help: The canonical way to pass children in React is to use JSX elements