diff --git a/crates/oxc_linter/src/rules.rs b/crates/oxc_linter/src/rules.rs
index bdb511c26881..a0ffe90b63cb 100644
--- a/crates/oxc_linter/src/rules.rs
+++ b/crates/oxc_linter/src/rules.rs
@@ -170,7 +170,7 @@ mod react {
mod react_perf {
pub mod jsx_no_jsx_as_prop;
pub mod jsx_no_new_array_as_prop;
- pub mod jsx_no_new_function_as_props;
+ pub mod jsx_no_new_function_as_prop;
pub mod jsx_no_new_object_as_prop;
}
@@ -524,7 +524,7 @@ oxc_macros::declare_all_lint_rules! {
react::require_render_return,
react_perf::jsx_no_jsx_as_prop,
react_perf::jsx_no_new_array_as_prop,
- react_perf::jsx_no_new_function_as_props,
+ react_perf::jsx_no_new_function_as_prop,
react_perf::jsx_no_new_object_as_prop,
import::default,
import::no_named_as_default_member,
diff --git a/crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_props.rs b/crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_prop.rs
similarity index 90%
rename from crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_props.rs
rename to crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_prop.rs
index ebc1ef38c088..085ebe331e59 100644
--- a/crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_props.rs
+++ b/crates/oxc_linter/src/rules/react_perf/jsx_no_new_function_as_prop.rs
@@ -20,12 +20,12 @@ use crate::{
};
#[derive(Debug, Error, Diagnostic)]
-#[error("eslint-plugin-react-perf(jsx-no-new-function-as-props): JSX attribute values should not contain functions created in the same scope.")]
+#[error("eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.")]
#[diagnostic(severity(warning), help(r"simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array)."))]
-struct JsxNoNewFunctionAsPropsDiagnostic(#[label] pub Span);
+struct JsxNoNewFunctionAsPropDiagnostic(#[label] pub Span);
#[derive(Debug, Default, Clone)]
-pub struct JsxNoNewFunctionAsProps;
+pub struct JsxNoNewFunctionAsProp;
declare_oxc_lint!(
/// ### What it does
@@ -40,11 +40,11 @@ declare_oxc_lint!(
/// // Good
///
/// ```
- JsxNoNewFunctionAsProps,
+ JsxNoNewFunctionAsProp,
correctness
);
-impl Rule for JsxNoNewFunctionAsProps {
+impl Rule for JsxNoNewFunctionAsProp {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if let AstKind::JSXElement(jsx_elem) = node.kind() {
check_jsx_element(jsx_elem, ctx);
@@ -61,7 +61,7 @@ fn check_jsx_element<'a>(jsx_elem: &JSXElement<'a>, ctx: &LintContext<'a>) {
..
})) => {
if let Some(span) = check_expression(expr) {
- ctx.diagnostic(JsxNoNewFunctionAsPropsDiagnostic(span));
+ ctx.diagnostic(JsxNoNewFunctionAsPropDiagnostic(span));
}
}
_ => {}
@@ -139,7 +139,7 @@ fn test() {
r" ",
];
- Tester::new(JsxNoNewFunctionAsProps::NAME, pass, fail)
+ Tester::new(JsxNoNewFunctionAsProp::NAME, pass, fail)
.with_react_perf_plugin(true)
.test_and_snapshot();
}
diff --git a/crates/oxc_linter/src/snapshots/jsx_no_new_function_as_prop.snap b/crates/oxc_linter/src/snapshots/jsx_no_new_function_as_prop.snap
new file mode 100644
index 000000000000..4e54a4e71a0e
--- /dev/null
+++ b/crates/oxc_linter/src/snapshots/jsx_no_new_function_as_prop.snap
@@ -0,0 +1,68 @@
+---
+source: crates/oxc_linter/src/tester.rs
+expression: jsx_no_new_function_as_prop
+---
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ───────────────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │ - true} />
+ · ──────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ─────────────────────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │ -
+ · ──────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ────────────────────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ─────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ─────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+ ⚠ eslint-plugin-react-perf(jsx-no-new-function-as-prop): JSX attribute values should not contain functions created in the same scope.
+ ╭─[jsx_no_new_function_as_prop.tsx:1:1]
+ 1 │
+ · ────────────
+ ╰────
+ help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
+
+