[go: nahoru, domu]

Skip to content

Commit

Permalink
Consider jsxFrag as set when it's set to the default value (#11295)
Browse files Browse the repository at this point in the history
* Consider jsxFrag as set when it's set to the default value

* Test #11294
  • Loading branch information
nicolo-ribaudo committed Mar 20, 2020
1 parent bb6a158 commit 87b2781
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,29 @@ export default declare((api, options) => {

let pragma = PRAGMA_DEFAULT;
let pragmaFrag = PRAGMA_FRAG_DEFAULT;
let pragmaSet = !!options.pragma;
let pragmaFragSet = !!options.pragma;

if (file.ast.comments) {
for (const comment of (file.ast.comments: Array<Object>)) {
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (jsxMatches) {
pragma = jsxMatches[1];
pragmaSet = true;
}
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
if (jsxFragMatches) {
pragmaFrag = jsxFragMatches[1];
pragmaFragSet = true;
}
}
}

state.set("jsxIdentifier", createIdentifierParser(pragma));
state.set("jsxFragIdentifier", createIdentifierParser(pragmaFrag));
state.set("usedFragment", false);
state.set("pragmaSet", pragma !== DEFAULT.pragma);
state.set("pragmaFragSet", pragmaFrag !== DEFAULT.pragmaFrag);
state.set("pragmaSet", pragmaSet);
state.set("pragmaFragSet", pragmaFragSet);
},
exit(path, state) {
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* @jsxFrag React.Fragment */
/* @jsx h */
<>Test</>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"transform-react-jsx"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* @jsxFrag React.Fragment */

/* @jsx h */
h(React.Fragment, null, "Test");
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import React from 'react';
const D = <></>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [
["react", { "pragma": "__jsx" }]]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import React from 'react';

const D = __jsx(React.Fragment, null);

0 comments on commit 87b2781

Please sign in to comment.