From 54f072991d1ba5ecfabe5fa61b7a6b483306729c Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Sat, 5 Jan 2019 22:22:49 -0800 Subject: [PATCH] Revert "Revert babel-helper-builder-react-jsx change from #4988" (#9119) This reverts commit dbc07220ae9188a3fb2bdea3d826ff7f48532a2e. # Conflicts: # packages/babel-helper-builder-react-jsx/src/index.js --- packages/babel-helper-builder-react-jsx/src/index.js | 7 +++++++ .../react/should-disallow-spread-children/input.js | 1 + .../react/should-disallow-spread-children/options.json | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/input.js create mode 100644 packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/options.json diff --git a/packages/babel-helper-builder-react-jsx/src/index.js b/packages/babel-helper-builder-react-jsx/src/index.js index 4f2473ae50..3602ecb849 100644 --- a/packages/babel-helper-builder-react-jsx/src/index.js +++ b/packages/babel-helper-builder-react-jsx/src/index.js @@ -19,6 +19,13 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`, ); } }; + + visitor.JSXSpreadChild = function(path) { + throw path.buildCodeFrameError( + "Spread children are not supported in React.", + ); + }; + visitor.JSXElement = { exit(path, file) { const callExpr = buildElementCall(path, file); diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/input.js new file mode 100644 index 0000000000..6a05e108dc --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/input.js @@ -0,0 +1 @@ +
{...children}
; diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/options.json new file mode 100644 index 0000000000..bcb773e343 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-disallow-spread-children/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Spread children are not supported in React." +}