Skip to content

Commit 398eed7

Browse files
committed
fix(transformer/jsx): do not report duplicate __source/__self prop found error when development is disabled
1 parent e4c80b4 commit 398eed7

File tree

8 files changed

+29
-3
lines changed

8 files changed

+29
-3
lines changed

crates/oxc_transformer/src/jsx/jsx_impl.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,18 @@ impl<'a> JsxImpl<'a, '_> {
582582
JSXAttributeItem::Attribute(attr) => {
583583
let JSXAttribute { span, name, value } = attr.unbox();
584584
match &name {
585-
JSXAttributeName::Identifier(ident) if ident.name == "__self" => {
585+
JSXAttributeName::Identifier(ident)
586+
if self.options.development
587+
&& self.options.jsx_self_plugin
588+
&& ident.name == "__self" =>
589+
{
586590
self.jsx_self.report_error(ident.span);
587591
}
588-
JSXAttributeName::Identifier(ident) if ident.name == "__source" => {
592+
JSXAttributeName::Identifier(ident)
593+
if self.options.development
594+
&& self.options.jsx_source_plugin
595+
&& ident.name == "__source" =>
596+
{
589597
self.jsx_source.report_error(ident.span);
590598
}
591599
JSXAttributeName::Identifier(ident) if ident.name == "key" => {

tasks/transform_conformance/snapshots/oxc.snap.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
commit: 578ac4df
22

3-
Passed: 148/240
3+
Passed: 150/242
44

55
# All Passed:
66
* babel-plugin-transform-class-static-block
@@ -15,6 +15,7 @@ Passed: 148/240
1515
* babel-plugin-transform-exponentiation-operator
1616
* babel-plugin-transform-arrow-functions
1717
* babel-preset-typescript
18+
* babel-plugin-transform-react-jsx-self
1819
* babel-plugin-transform-react-jsx-source
1920
* regexp
2021

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div __self={this} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["transform-react-jsx", "transform-react-jsx-self"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var _reactJsxRuntime = require("react/jsx-runtime");
2+
/* @__PURE__ */ _reactJsxRuntime.jsx("div", { __self: this }, this);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div __source="custom" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["transform-react-jsx", "transform-react-jsx-source"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var _reactJsxRuntime = require("react/jsx-runtime");
2+
var _jsxFileName = "<CWD>/tests/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/duplicate-source-prop/input.jsx";
3+
/* @__PURE__ */ _reactJsxRuntime.jsx("div", { __source: "custom" }, {
4+
fileName: _jsxFileName,
5+
lineNumber: 1,
6+
columnNumber: 1
7+
});

0 commit comments

Comments
 (0)