diff --git a/packages/babel-plugin-transform-react-jsx/src/index.js b/packages/babel-plugin-transform-react-jsx/src/index.js index 2bc882b013..d19e07a8a5 100644 --- a/packages/babel-plugin-transform-react-jsx/src/index.js +++ b/packages/babel-plugin-transform-react-jsx/src/index.js @@ -1,5 +1,5 @@ export default function ({ types: t }) { - let JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/; + let JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/; let visitor = require("babel-helper-builder-react-jsx")({ pre(state) { diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/actual.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/actual.js new file mode 100644 index 0000000000..d8d5e03b67 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/actual.js @@ -0,0 +1,10 @@ +/** + * @jsx React.DOM + */ + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/options.json new file mode 100644 index 0000000000..ce93ded1fe --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-multiline/options.json @@ -0,0 +1,3 @@ +{ + "throws": "The @jsx React.DOM pragma has been deprecated as of React 0.12" +} diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/actual.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/actual.js new file mode 100644 index 0000000000..7454c292d6 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/actual.js @@ -0,0 +1,8 @@ +/* @jsx React.DOM */ + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/options.json new file mode 100644 index 0000000000..ce93ded1fe --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-simple/options.json @@ -0,0 +1,3 @@ +{ + "throws": "The @jsx React.DOM pragma has been deprecated as of React 0.12" +} diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/actual.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/actual.js new file mode 100644 index 0000000000..1d050d5f12 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/actual.js @@ -0,0 +1,8 @@ +// @jsx React.DOM + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/options.json new file mode 100644 index 0000000000..ce93ded1fe --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom-singleline/options.json @@ -0,0 +1,3 @@ +{ + "throws": "The @jsx React.DOM pragma has been deprecated as of React 0.12" +} diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/actual.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/actual.js new file mode 100644 index 0000000000..ca21da88e2 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/actual.js @@ -0,0 +1,8 @@ +/** @jsx React.DOM */ + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/options.json new file mode 100644 index 0000000000..ce93ded1fe --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/throw-if-custom-jsx-comment-sets-react-dom/options.json @@ -0,0 +1,3 @@ +{ + "throws": "The @jsx React.DOM pragma has been deprecated as of React 0.12" +}