Removed the deprecated jsx pragma detection code (#6145)

* Removed the deprecated jsx pragma detection code and the concerned tests that included jsx-pragma

* Removed extra tests

* Restored packages/babel-plugin-transform-react-jsx/test/fixtures/react/honor-custom-jsx-pragma-option/
This commit is contained in:
Astha Sharma
2017-08-23 00:59:06 +05:30
committed by Henry Zhu
parent 63baaa7148
commit 62c22c7b5d
15 changed files with 39 additions and 168 deletions

View File

@@ -2,8 +2,6 @@ import jsx from "babel-plugin-syntax-jsx";
import helper from "babel-helper-builder-react-jsx";
export default function({ types: t }) {
const JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/;
const visitor = helper({
pre(state) {
const tagName = state.tagName;
@@ -21,23 +19,7 @@ export default function({ types: t }) {
});
visitor.Program = function(path, state) {
const { file } = state;
let id = state.opts.pragma || "React.createElement";
for (const comment of (file.ast.comments: Array<Object>)) {
const matches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (matches) {
id = matches[1];
if (id === "React.DOM") {
throw file.buildCodeFrameError(
comment,
"The @jsx React.DOM pragma has been deprecated as of React 0.12",
);
} else {
break;
}
}
}
const id = state.opts.pragma || "React.createElement";
state.set("jsxIdentifier", () =>
id