Skip newlines around inline #__PURE__ annotations (#11133)

* Skip newlines around #__PURE__ annotations

* Update tests
This commit is contained in:
Nicolò Ribaudo
2020-02-13 19:16:33 +01:00
committed by GitHub
parent 3c6a8ae200
commit d21e2217d5
274 changed files with 382 additions and 1072 deletions

View File

@@ -1,14 +1,10 @@
var _ref =
/*#__PURE__*/
<div>child</div>;
var _ref = /*#__PURE__*/<div>child</div>;
const AppItem = () => {
return _ref;
};
var _ref2 =
/*#__PURE__*/
<div>
var _ref2 = /*#__PURE__*/<div>
<p>Parent</p>
<AppItem />
</div>;

View File

@@ -1,10 +1,6 @@
var _ref2 =
/*#__PURE__*/
<div>child</div>;
var _ref2 = /*#__PURE__*/<div>child</div>;
var _ref3 =
/*#__PURE__*/
<p>Parent</p>;
var _ref3 = /*#__PURE__*/<p>Parent</p>;
(function () {
class App extends React.Component {
@@ -17,9 +13,7 @@ var _ref3 =
const AppItem = () => {
return _ref2;
},
_ref =
/*#__PURE__*/
<div>
_ref = /*#__PURE__*/<div>
{_ref3}
<AppItem />
</div>;

View File

@@ -1,19 +1,13 @@
var _ref =
/*#__PURE__*/
<div>child</div>;
var _ref = /*#__PURE__*/<div>child</div>;
var _ref3 =
/*#__PURE__*/
<p>Parent</p>;
var _ref3 = /*#__PURE__*/<p>Parent</p>;
(function () {
const AppItem = () => {
return _ref;
};
var _ref2 =
/*#__PURE__*/
<div>
var _ref2 = /*#__PURE__*/<div>
{_ref3}
<AppItem />
</div>;

View File

@@ -5,16 +5,12 @@ export default class App extends React.Component {
}
var _ref2 =
/*#__PURE__*/
<div>child</div>;
var _ref2 = /*#__PURE__*/<div>child</div>;
const AppItem = () => {
return _ref2;
},
_ref =
/*#__PURE__*/
<div>
_ref = /*#__PURE__*/<div>
<p>Parent</p>
<AppItem />
</div>;

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<span />;
var _ref = /*#__PURE__*/<span />;
var Foo = React.createClass({
render: function () {

View File

@@ -1,8 +1,6 @@
import React from 'react'; // Regression test for https://github.com/babel/babel/issues/5552
var _ref =
/*#__PURE__*/
<div />;
var _ref = /*#__PURE__*/<div />;
class BugReport extends React.Component {
constructor(...args) {

View File

@@ -1,13 +1,9 @@
import React from 'react';
import Loader from 'loader';
var _ref =
/*#__PURE__*/
<Loader className="full-height" />;
var _ref = /*#__PURE__*/<Loader className="full-height" />;
var _ref2 =
/*#__PURE__*/
<Loader className="p-y-5" />;
var _ref2 = /*#__PURE__*/<Loader className="p-y-5" />;
const errorComesHere = () => _ref,
thisWorksFine = () => _ref2;

View File

@@ -1,8 +1,6 @@
var Foo = require("Foo");
var _ref =
/*#__PURE__*/
<Foo />;
var _ref = /*#__PURE__*/<Foo />;
function render() {
return _ref;

View File

@@ -1,10 +1,6 @@
var _ref =
/*#__PURE__*/
<b></b>;
var _ref = /*#__PURE__*/<b></b>;
var _ref2 =
/*#__PURE__*/
<span></span>;
var _ref2 = /*#__PURE__*/<span></span>;
function render() {
var children = _ref;

View File

@@ -4,15 +4,11 @@ const Parent = ({}) => _ref;
export default Parent;
var _ref2 =
/*#__PURE__*/
<div className="child">
var _ref2 = /*#__PURE__*/<div className="child">
ChildTextContent
</div>;
let Child = () => _ref2,
_ref =
/*#__PURE__*/
<div className="parent">
_ref = /*#__PURE__*/<div className="parent">
<Child />
</div>;

View File

@@ -1,8 +1,6 @@
function render() {
const bar = "bar",
_ref =
/*#__PURE__*/
<foo bar={bar} />,
_ref = /*#__PURE__*/<foo bar={bar} />,
renderFoo = () => _ref;
return renderFoo();
@@ -12,9 +10,7 @@ function render() {
const bar = "bar",
renderFoo = () => _ref2,
baz = "baz",
_ref2 =
/*#__PURE__*/
<foo bar={bar} baz={baz} />;
_ref2 = /*#__PURE__*/<foo bar={bar} baz={baz} />;
return renderFoo();
}

View File

@@ -1,9 +1,7 @@
function render() {
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var _ref =
/*#__PURE__*/
<Component title={title} />;
var _ref = /*#__PURE__*/<Component title={title} />;
return () => _ref;
}

View File

@@ -1,8 +1,6 @@
function render(Component) {
var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '',
_ref =
/*#__PURE__*/
<Component text={text} />;
_ref = /*#__PURE__*/<Component text={text} />;
return function () {
return _ref;

View File

@@ -6,9 +6,7 @@ const Parent = ({}) => _ref;
export default Parent;
var _ref2 =
/*#__PURE__*/
<div className="child">
var _ref2 = /*#__PURE__*/<div className="child">
ChildTextContent
</div>;
@@ -16,8 +14,6 @@ let Child = () => _ref2;
Child = HOC(Child);
var _ref =
/*#__PURE__*/
<div className="parent">
var _ref = /*#__PURE__*/<div className="parent">
<Child />
</div>;

View File

@@ -1,7 +1,5 @@
function render(text) {
var _ref =
/*#__PURE__*/
<foo>{text}</foo>;
var _ref = /*#__PURE__*/<foo>{text}</foo>;
return function () {
return _ref;
@@ -11,9 +9,7 @@ function render(text) {
var Foo2 = require("Foo");
function createComponent(text) {
var _ref2 =
/*#__PURE__*/
<Foo2>{text}</Foo2>;
var _ref2 = /*#__PURE__*/<Foo2>{text}</Foo2>;
return function render() {
return _ref2;

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<div foo={notDeclared}></div>;
var _ref = /*#__PURE__*/<div foo={notDeclared}></div>;
var Foo = React.createClass({
render: function render() {

View File

@@ -1,14 +1,10 @@
var _ref =
/*#__PURE__*/
<foo />;
var _ref = /*#__PURE__*/<foo />;
function render() {
return _ref;
}
var _ref2 =
/*#__PURE__*/
<div className="foo"><input type="checkbox" checked={true} /></div>;
var _ref2 = /*#__PURE__*/<div className="foo"><input type="checkbox" checked={true} /></div>;
function render() {
return _ref2;

View File

@@ -2,9 +2,7 @@ var REACT_ELEMENT_TYPE;
function _jsx(type, props, key, children) { if (!REACT_ELEMENT_TYPE) { REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; } var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = { children: void 0 }; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = new Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }
var _ref =
/*#__PURE__*/
_jsx("foo", {});
var _ref = /*#__PURE__*/_jsx("foo", {});
function render() {
return _ref;
@@ -13,9 +11,7 @@ function render() {
function render() {
var text = getText();
var _ref2 =
/*#__PURE__*/
_jsx("foo", {}, void 0, text);
var _ref2 = /*#__PURE__*/_jsx("foo", {}, void 0, text);
return function () {
return _ref2;

View File

@@ -1,9 +1,7 @@
function render() {
var text = getText();
var _ref =
/*#__PURE__*/
<foo>{text}</foo>;
var _ref = /*#__PURE__*/<foo>{text}</foo>;
return function () {
return _ref;

View File

@@ -1,9 +1,7 @@
function render() {
this.component = "div";
var _ref =
/*#__PURE__*/
<this.component />;
var _ref = /*#__PURE__*/<this.component />;
return () => _ref;
}

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<span>Sub Component</span>;
var _ref = /*#__PURE__*/<span>Sub Component</span>;
class Component extends React.Component {
constructor(...args) {
@@ -8,9 +6,7 @@ class Component extends React.Component {
this.subComponent = () => _ref;
var _ref2 =
/*#__PURE__*/
<this.subComponent />;
var _ref2 = /*#__PURE__*/<this.subComponent />;
this.render = () => _ref2;
}

View File

@@ -1,14 +1,10 @@
var _ref =
/*#__PURE__*/
<span>Sub Component</span>;
var _ref = /*#__PURE__*/<span>Sub Component</span>;
const els = {
subComponent: () => _ref
};
var _ref2 =
/*#__PURE__*/
<els.subComponent />;
var _ref2 = /*#__PURE__*/<els.subComponent />;
class Component extends React.Component {
constructor(...args) {

View File

@@ -1,8 +1,6 @@
function fn(Component, obj) {
var data = obj.data,
_ref =
/*#__PURE__*/
<Component prop={data} />;
_ref = /*#__PURE__*/<Component prop={data} />;
return () => _ref;
}

View File

@@ -3,9 +3,7 @@ function render(_ref) {
className = _ref.className,
id = _ref.id;
var _ref2 =
/*#__PURE__*/
<Component text={text} className={className} id={id} />;
var _ref2 = /*#__PURE__*/<Component text={text} className={className} id={id} />;
return () => _ref2;
}

View File

@@ -4,9 +4,7 @@ function render(_ref) {
id = _ref.id,
props = babelHelpers.objectWithoutProperties(_ref, ["text", "className", "id"]);
var _ref2 =
/*#__PURE__*/
<Component text={text} className={className} id={id} />;
var _ref2 = /*#__PURE__*/<Component text={text} className={className} id={id} />;
// intentionally ignoring props
return () => _ref2;

View File

@@ -1,9 +1,7 @@
function render(_ref) {
let text = _ref.text;
var _ref2 =
/*#__PURE__*/
<Component text={text} />;
var _ref2 = /*#__PURE__*/<Component text={text} />;
return () => _ref2;
}

View File

@@ -1,7 +1,5 @@
function render(text) {
var _ref =
/*#__PURE__*/
<div>{text}</div>;
var _ref = /*#__PURE__*/<div>{text}</div>;
return function () {
return _ref;

View File

@@ -1,7 +1,5 @@
function render(offset) {
var _ref =
/*#__PURE__*/
<div tabIndex={offset + 1} />;
var _ref = /*#__PURE__*/<div tabIndex={offset + 1} />;
return function () {
return _ref;

View File

@@ -1,8 +1,6 @@
const OFFSET = 3;
var _ref =
/*#__PURE__*/
<div tabIndex={OFFSET + 1} />;
var _ref = /*#__PURE__*/<div tabIndex={OFFSET + 1} />;
var Foo = React.createClass({
render: function () {

View File

@@ -1,8 +1,6 @@
import Intl from 'react-intl';
var _ref =
/*#__PURE__*/
<Intl.FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
var _ref = /*#__PURE__*/<Intl.FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
someValue: "A value."
}} />;

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
var _ref = /*#__PURE__*/<FormattedMessage id="someMessage.foo" defaultMessage={"Some text, " + "and some more too. {someValue}"} description="A test message for babel." values={{
someValue: "A value."
}} />;

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<div data-text={"Some text, " + "and some more too."} />;
var _ref = /*#__PURE__*/<div data-text={"Some text, " + "and some more too."} />;
var Foo = React.createClass({
render: function () {

View File

@@ -1,9 +1,7 @@
function render(text) {
text += "yes";
var _ref =
/*#__PURE__*/
<div>{text}</div>;
var _ref = /*#__PURE__*/<div>{text}</div>;
return function () {
return _ref;

View File

@@ -7,6 +7,4 @@ class A {
export default class B {}
var _ref =
/*#__PURE__*/
React.createElement(B, null);
var _ref = /*#__PURE__*/React.createElement(B, null);

View File

@@ -7,6 +7,4 @@ class A {
export class B {}
var _ref =
/*#__PURE__*/
React.createElement(B, null);
var _ref = /*#__PURE__*/React.createElement(B, null);

View File

@@ -1,6 +1,4 @@
var _ref =
/*#__PURE__*/
<div className="class-name">
var _ref = /*#__PURE__*/<div className="class-name">
Text
</div>;

View File

@@ -1,8 +1,6 @@
function fn(Component) {
var data = "prop",
_ref =
/*#__PURE__*/
<Component prop={data} />;
_ref = /*#__PURE__*/<Component prop={data} />;
return () => _ref;
}