diff --git a/.typos.toml b/.typos.toml index 9b9e54f3129df..3342e35562872 100644 --- a/.typos.toml +++ b/.typos.toml @@ -22,6 +22,7 @@ extend-exclude = [ "tasks/coverage/snapshots", "tasks/prettier_conformance/prettier", "tasks/prettier_conformance/snapshots", + "tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/input.jsx", "tasks/transform_conformance/tests/**/output.js", "tasks/transform_conformance/overrides", "tasks/transform_conformance/snapshots", diff --git a/tasks/transform_conformance/snapshots/oxc.snap.md b/tasks/transform_conformance/snapshots/oxc.snap.md index 7916a5386a0dd..5e25ea079cb53 100644 --- a/tasks/transform_conformance/snapshots/oxc.snap.md +++ b/tasks/transform_conformance/snapshots/oxc.snap.md @@ -1,6 +1,6 @@ commit: 578ac4df -Passed: 143/235 +Passed: 148/240 # All Passed: * babel-plugin-transform-class-static-block @@ -336,7 +336,7 @@ rebuilt : SymbolId(2): [] x Output mismatch -# babel-plugin-transform-react-jsx (37/40) +# babel-plugin-transform-react-jsx (42/45) * refresh/does-not-transform-it-because-it-is-not-used-in-the-AST/input.jsx x Output mismatch diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/input.jsx new file mode 100644 index 0000000000000..4639feb2751b7 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/input.jsx @@ -0,0 +1,12 @@ +// Valid escapes +; +; +; + +// Invalid escapes +; + +// Unterminated escapes +; +; +; diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/options.json b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/options.json similarity index 100% rename from tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/options.json rename to tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/options.json diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/output.js new file mode 100644 index 0000000000000..b10eef23995af --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/attribute-escapes/output.js @@ -0,0 +1,14 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +// Valid escapes +/* @__PURE__ */ _jsx(Foo, { bar: "È € \"" }); +/* @__PURE__ */ _jsx(Foo, { bar: "\f A" }); +/* @__PURE__ */ _jsx(Foo, { bar: "\f A" }); + +// Invalid escapes +/* @__PURE__ */ _jsx(Foo, { bar: "&donkey; � � &#xG; � � &#C;" }); + +// Unterminated escapes +/* @__PURE__ */ _jsx(Foo, { bar: "&euro xxx" }); +/* @__PURE__ */ _jsx(Foo, { bar: "{ xxx" }); +/* @__PURE__ */ _jsx(Foo, { bar: "ģ xxx" }); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/input.jsx new file mode 100644 index 0000000000000..7fc19802d1fc6 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/input.jsx @@ -0,0 +1,308 @@ +// Valid +
+   + ¡ + ¢ + £ + ¤ + ¥ + ¦ + § + ¨ + © +
; +
+ ª + « + ¬ + ­ + ® + ¯ + ° + ± + ² + ³ +
; +
+ ´ + µ + ¶ + · + ¸ + ¹ + º + » + ¼ + ½ +
; +
+ ¾ + ¿ + À + Á + Â + Ã + Ä + Å + Æ + Ç +
; +
+ È + É + Ê + Ë + Ì + Í + Î + Ï + Ð + Ñ +
; +
+ Ò + Ó + Ô + Õ + Ö + × + Ø + Ù + Ú + Û +
; +
+ Ü + Ý + Þ + ß + à + á + â + ã + ä + å +
; +
+ æ + ç + è + é + ê + ë + ì + í + î + ï +
; +
+ ð + ñ + ò + ó + ô + õ + ö + ÷ + ø + ù +
; +
+ ú + û + ü + ý + þ + ÿ + ƒ + Α + Β + Γ +
; +
+ Δ + Ε + Ζ + Η + Θ + Ι + Κ + Λ + Μ + Ν +
; +
+ Ξ + Ο + Π + Ρ + Σ + Τ + Υ + Φ + Χ + Ψ +
; +
+ Ω + α + β + γ + δ + ε + ζ + η + θ + ι +
; +
+ κ + λ + μ + ν + ξ + ο + π + ρ + ς + σ +
; +
+ τ + υ + φ + χ + ψ + ω + ϑ + ϒ + ϖ + • +
; +
+ … + ′ + ″ + ‾ + ⁄ + ℘ + ℑ + ℜ + ™ + ℵ +
; +
+ ← + ↑ + → + ↓ + ↔ + ↵ + ⇐ + ⇑ + ⇒ + ⇓ +
; +
+ ⇔ + ∀ + ∂ + ∃ + ∅ + ∇ + ∈ + ∉ + ∋ + ∏ +
; +
+ ∑ + − + ∗ + √ + ∝ + ∞ + ∠ + ∧ + ∨ + ∩ +
; +
+ ∪ + ∫ + ∴ + ∼ + ≅ + ≈ + ≠ + ≡ + ≤ + ≥ +
; +
+ ⊂ + ⊃ + ⊄ + ⊆ + ⊇ + ⊕ + ⊗ + ⊥ + ⋅ + ⌈ +
; +
+ ⌉ + ⌊ + ⌋ + ⟨ + ⟩ + ◊ + ♠ + ♣ + ♥ + ♦ +
; +
+ " + & + < + > + Œ + œ + Š + š + Ÿ + ˆ +
; +
+ ˜ +   +   +   + ‌ + ‍ + ‎ + ‏ + – + — +
; +
+ ‘ + ’ + ‚ + “ + ” + „ + † + ‡ + ‰ + ‹ +
; +
+ › + € +
; + +// Invalid +
&donkey;
diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/output.js new file mode 100644 index 0000000000000..d5997e6c197c4 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/escapes/output.js @@ -0,0 +1,32 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +// Valid +/* @__PURE__ */ _jsx("div", { children: "\xA0 ¡ ¢ £ ¤ ¥ ¦ § ¨ ©" }); +/* @__PURE__ */ _jsx("div", { children: "ª « ¬ ­ ® ¯ ° ± ² ³" }); +/* @__PURE__ */ _jsx("div", { children: "´ µ ¶ · ¸ ¹ º » ¼ ½" }); +/* @__PURE__ */ _jsx("div", { children: "¾ ¿ À Á Â Ã Ä Å Æ Ç" }); +/* @__PURE__ */ _jsx("div", { children: "È É Ê Ë Ì Í Î Ï Ð Ñ" }); +/* @__PURE__ */ _jsx("div", { children: "Ò Ó Ô Õ Ö × Ø Ù Ú Û" }); +/* @__PURE__ */ _jsx("div", { children: "Ü Ý Þ ß à á â ã ä å" }); +/* @__PURE__ */ _jsx("div", { children: "æ ç è é ê ë ì í î ï" }); +/* @__PURE__ */ _jsx("div", { children: "ð ñ ò ó ô õ ö ÷ ø ù" }); +/* @__PURE__ */ _jsx("div", { children: "ú û ü ý þ ÿ ƒ Α Β Γ" }); +/* @__PURE__ */ _jsx("div", { children: "Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν" }); +/* @__PURE__ */ _jsx("div", { children: "Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ" }); +/* @__PURE__ */ _jsx("div", { children: "Ω α β γ δ ε ζ η θ ι" }); +/* @__PURE__ */ _jsx("div", { children: "κ λ μ ν ξ ο π ρ ς σ" }); +/* @__PURE__ */ _jsx("div", { children: "τ υ φ χ ψ ω ϑ ϒ ϖ •" }); +/* @__PURE__ */ _jsx("div", { children: "… ′ ″ ‾ ⁄ ℘ ℑ ℜ ™ ℵ" }); +/* @__PURE__ */ _jsx("div", { children: "← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓" }); +/* @__PURE__ */ _jsx("div", { children: "⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉ ∋ ∏" }); +/* @__PURE__ */ _jsx("div", { children: "∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩" }); +/* @__PURE__ */ _jsx("div", { children: "∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥" }); +/* @__PURE__ */ _jsx("div", { children: "⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈" }); +/* @__PURE__ */ _jsx("div", { children: "⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦" }); +/* @__PURE__ */ _jsx("div", { children: "\" & < > Œ œ Š š Ÿ ˆ" }); +/* @__PURE__ */ _jsx("div", { children: "˜       ‌ ‍ ‎ ‏ – —" }); +/* @__PURE__ */ _jsx("div", { children: "‘ ’ ‚ “ ” „ † ‡ ‰ ‹" }); +/* @__PURE__ */ _jsx("div", { children: "› €" }); + +// Invalid +/* @__PURE__ */ _jsx("div", { children: "&donkey;" }); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/input.jsx new file mode 100644 index 0000000000000..e25efe545df85 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/input.jsx @@ -0,0 +1,33 @@ +// Valid hex +
+ + A + ģ + ሴ + 𐀀 + 􏿿 +
; + +// Invalid hex +
+ � + � + &#xG; +
; + +// Valid decimal (same characters as valid hex above) +
+ + A + ģ + ሴ + 𐀀 + 􏿿 +
; + +// Invalid decimal +
+ � + � + &#C; +
; diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/output.js new file mode 100644 index 0000000000000..a9d9dbfc45157 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/numeric-escapes/output.js @@ -0,0 +1,13 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +// Valid hex +/* @__PURE__ */ _jsx("div", { children: "\f A ģ ሴ 𐀀 􏿿" }); + +// Invalid hex +/* @__PURE__ */ _jsx("div", { children: "� � &#xG;" }); + +// Valid decimal (same characters as valid hex above) +/* @__PURE__ */ _jsx("div", { children: "\f A ģ ሴ 𐀀 􏿿" }); + +// Invalid decimal +/* @__PURE__ */ _jsx("div", { children: "� � &#C;" }); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/options.json b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/options.json new file mode 100644 index 0000000000000..e3c59a596fd59 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["transform-react-jsx"]], + "sourceType": "module" +} diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unicode/input.jsx similarity index 100% rename from tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/input.jsx rename to tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unicode/input.jsx diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unicode/output.js similarity index 100% rename from tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/unicode/output.js rename to tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unicode/output.js diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/input.jsx new file mode 100644 index 0000000000000..0985ad8e00828 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/input.jsx @@ -0,0 +1,8 @@ +
È
; +
È xxx
; +
&euro
; +
&euro xxx
; +
{
; +
{ xxx
; +
ģ
; +
ģ xxx
; diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/output.js new file mode 100644 index 0000000000000..5ffa31f518ca0 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/unterminated-escapes/output.js @@ -0,0 +1,10 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/* @__PURE__ */ _jsx("div", { children: "È" }); +/* @__PURE__ */ _jsx("div", { children: "È xxx" }); +/* @__PURE__ */ _jsx("div", { children: "&euro" }); +/* @__PURE__ */ _jsx("div", { children: "&euro xxx" }); +/* @__PURE__ */ _jsx("div", { children: "{" }); +/* @__PURE__ */ _jsx("div", { children: "{ xxx" }); +/* @__PURE__ */ _jsx("div", { children: "ģ" }); +/* @__PURE__ */ _jsx("div", { children: "ģ xxx" }); diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/input.jsx b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/input.jsx new file mode 100644 index 0000000000000..49ca0ba3cfb89 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/input.jsx @@ -0,0 +1,128 @@ +// Note: Whitespace here is always + +// No whitespace +
angus
; + +// Whitespace before + after +
angry
; +
brick chocs digger
; +
egg fry greek
; + +// No whitespace +
+alternative +
; +
bert +cack +doobie
; +
+erstwhile +flaps +goober +
; +
+ + + +hippy + + + +igloo + + + +jumper + + + +
; + +// Whitespace before + after text +
+ able +
; +
+ bark club devil +
; +
edge + fart + guppy
; +
+ help + island + jug +
; +
+ + kaos + + + lmao + + + moon + +
; +
+ noob + + ogre patrick quiz + + roger slash toaster +
; + +// Whitespace after opening + before closing tags +
+aging +
; +
boris +cod +dante
; +
+elephant +fuzz +gerald +
; +
herbert + + +ice + + +jump
; +
klan lover mango +nolan opus pavel +queen road shovel
; + +// Whitespace before + after text, and after opening + before closing tags +
+ antler +
; +
bus + cudgel + dance
; +
+ elton + flip + granny +
; +
hoover + idol + jack
; +
+ + kermit + + + lemur + + + mangle + +
; +
+ nascent oats panda + quotation rug sloth + tundra uber veggie +
; diff --git a/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/output.js b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/output.js new file mode 100644 index 0000000000000..7aedf8c9f3327 --- /dev/null +++ b/tasks/transform_conformance/tests/babel-plugin-transform-react-jsx/test/fixtures/text/whitespace/output.js @@ -0,0 +1,38 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +// No whitespace +/* @__PURE__ */ _jsx("div", { children: "angus" }); + +// Single line with whitespace +/* @__PURE__ */ _jsx("div", { children: " angry " }); +/* @__PURE__ */ _jsx("div", { children: " brick chocs digger " }); +/* @__PURE__ */ _jsx("div", { children: " egg fry greek " }); + +// No whitespace +/* @__PURE__ */ _jsx("div", { children: "alternative" }); +/* @__PURE__ */ _jsx("div", { children: "bert cack doobie" }); +/* @__PURE__ */ _jsx("div", { children: "erstwhile flaps goober" }); +/* @__PURE__ */ _jsx("div", { children: "hippy igloo jumper" }); + +// Whitespace before + after text +/* @__PURE__ */ _jsx("div", { children: "able" }); +/* @__PURE__ */ _jsx("div", { children: "bark club devil" }); +/* @__PURE__ */ _jsx("div", { children: "edge fart guppy" }); +/* @__PURE__ */ _jsx("div", { children: "help island jug" }); +/* @__PURE__ */ _jsx("div", { children: "kaos lmao moon" }); +/* @__PURE__ */ _jsx("div", { children: "noob ogre patrick quiz roger slash toaster" }); + +// Whitespace after opening and before closing tags +/* @__PURE__ */ _jsx("div", { children: "aging" }); +/* @__PURE__ */ _jsx("div", { children: " boris cod dante " }); +/* @__PURE__ */ _jsx("div", { children: "elephant fuzz gerald" }); +/* @__PURE__ */ _jsx("div", { children: " herbert ice jump " }); +/* @__PURE__ */ _jsx("div", { children: " klan lover mango nolan opus pavel queen road shovel " }); + +// Whitespace before + after text, and after opening + before closing tags +/* @__PURE__ */ _jsx("div", { children: "antler" }); +/* @__PURE__ */ _jsx("div", { children: " bus cudgel dance " }); +/* @__PURE__ */ _jsx("div", { children: "elton flip granny" }); +/* @__PURE__ */ _jsx("div", { children: " hoover idol jack " }); +/* @__PURE__ */ _jsx("div", { children: "kermit lemur mangle" }); +/* @__PURE__ */ _jsx("div", { children: "nascent oats panda quotation rug sloth tundra uber veggie" });