diff --git a/crates/oxc_transformer/src/jsx/jsx_impl.rs b/crates/oxc_transformer/src/jsx/jsx_impl.rs index b17d00b4edfda..c5477f9bb4d9f 100644 --- a/crates/oxc_transformer/src/jsx/jsx_impl.rs +++ b/crates/oxc_transformer/src/jsx/jsx_impl.rs @@ -582,10 +582,18 @@ impl<'a> JsxImpl<'a, '_> { JSXAttributeItem::Attribute(attr) => { let JSXAttribute { span, name, value } = attr.unbox(); match &name { - JSXAttributeName::Identifier(ident) if ident.name == "__self" => { + JSXAttributeName::Identifier(ident) + if self.options.development + && self.options.jsx_self_plugin + && ident.name == "__self" => + { self.jsx_self.report_error(ident.span); } - JSXAttributeName::Identifier(ident) if ident.name == "__source" => { + JSXAttributeName::Identifier(ident) + if self.options.development + && self.options.jsx_source_plugin + && ident.name == "__source" => + { self.jsx_source.report_error(ident.span); } JSXAttributeName::Identifier(ident) if ident.name == "key" => { diff --git a/tasks/transform_conformance/snapshots/oxc.snap.md b/tasks/transform_conformance/snapshots/oxc.snap.md index 4bf6828114b8c..318112adf6ed5 100644 --- a/tasks/transform_conformance/snapshots/oxc.snap.md +++ b/tasks/transform_conformance/snapshots/oxc.snap.md @@ -1,6 +1,6 @@ commit: 578ac4df -Passed: 148/241 +Passed: 150/243 # All Passed: * babel-plugin-transform-class-static-block @@ -15,6 +15,7 @@ Passed: 148/241 * babel-plugin-transform-exponentiation-operator * babel-plugin-transform-arrow-functions * babel-preset-typescript +* babel-plugin-transform-react-jsx-self * babel-plugin-transform-react-jsx-source * regexp diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/input.jsx new file mode 100644 index 0000000000000..650a26f82e321 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/input.jsx @@ -0,0 +1 @@ +
diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/options.json b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/options.json new file mode 100644 index 0000000000000..b86e178de5aa9 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-react-jsx", "transform-react-jsx-self"] +} diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/output.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/output.jsx new file mode 100644 index 0000000000000..f84227d67bb2b --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-self/test/fixtures/react-source/duplicate-self-prop/output.jsx @@ -0,0 +1,2 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); +/* @__PURE__ */ _reactJsxRuntime.jsx("div", { __self: this }, this); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/input.jsx new file mode 100644 index 0000000000000..ba4655987cb86 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/input.jsx @@ -0,0 +1 @@ + diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/options.json b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/options.json new file mode 100644 index 0000000000000..f3abf9dde0b66 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-react-jsx", "transform-react-jsx-source"] +} diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/output.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/output.jsx new file mode 100644 index 0000000000000..2322dbf58e5f5 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/output.jsx @@ -0,0 +1,7 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); +var _jsxFileName = "