Remove whitespace generation (#5833)

* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
This commit is contained in:
Daniel Tschinder
2017-06-27 19:57:02 -07:00
committed by Brian Ng
parent bc29145465
commit b3372a572d
379 changed files with 1974 additions and 1109 deletions

View File

@@ -1,9 +1,13 @@
var _c2;
({ a1 } = c1);
({
a1
} = c1);
var _c = c2;
({ a2 } = _c);
({
a2
} = _c);
b2 = babelHelpers.objectWithoutProperties(_c, ["a2"]);
console.log((_c2 = c3, ({ a3 } = _c2), b3 = babelHelpers.objectWithoutProperties(_c2, ["a3"]), _c2));
console.log((_c2 = c3, ({
a3
} = _c2), b3 = babelHelpers.objectWithoutProperties(_c2, ["a3"]), _c2));

View File

@@ -1,19 +1,36 @@
try {} catch (_ref) {
let a34 = babelHelpers.objectWithoutProperties(_ref, []);
}
try {} catch (_ref2) {
let { a1 } = _ref2,
let {
a1
} = _ref2,
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
}
try {} catch (_ref3) {
let { a2, b2 } = _ref3,
let {
a2,
b2
} = _ref3,
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
}
try {} catch (_ref4) {
let { a2, b2, c2: { c3 } } = _ref4,
c4 = babelHelpers.objectWithoutProperties(_ref4.c2, ["c3"]);
}
// Unchanged
try {} catch (_ref4) {
let {
a2,
b2,
c2: {
c3
}
} = _ref4,
c4 = babelHelpers.objectWithoutProperties(_ref4.c2, ["c3"]);
} // Unchanged
try {} catch (a) {}
try {} catch ({ b }) {}
try {} catch ({
b
}) {}

View File

@@ -1,7 +1,12 @@
// ExportNamedDeclaration
var { b } = asdf2,
c = babelHelpers.objectWithoutProperties(asdf2, ["b"]);
// Skip
var {
b
} = asdf2,
c = babelHelpers.objectWithoutProperties(asdf2, ["b"]); // Skip
export { b, c };
export var { bb, cc } = ads;
export var [dd, ee] = ads;
export var {
bb,
cc
} = ads;
export var [dd, ee] = ads;

View File

@@ -1,28 +1,46 @@
// ForXStatement
for (var _ref of []) {
var { a } = _ref,
var {
a
} = _ref,
b = babelHelpers.objectWithoutProperties(_ref, ["a"]);
}
for (var _ref2 of []) {
var { a } = _ref2,
var {
a
} = _ref2,
b = babelHelpers.objectWithoutProperties(_ref2, ["a"]);
}
async function a() {
for await (var _ref3 of []) {
var { a } = _ref3,
var {
a
} = _ref3,
b = babelHelpers.objectWithoutProperties(_ref3, ["a"]);
}
}
} // skip
for ({
a
} in {}) {}
for ({
a
} of []) {}
// skip
for ({ a } in {}) {}
for ({ a } of []) {}
async function a() {
for await ({ a } of []) {}
for await ({
a
} of []) {}
}
for (a in {}) {}
for (a of []) {}
async function a() {
for await (a of []) {}
}
}

View File

@@ -11,6 +11,15 @@ const test = {
}
}
};
const { foo: { bar: { baz: { a: { x } } } } } = test,
other = babelHelpers.objectWithoutProperties(test.foo.bar.baz.a, ["x"]);
const {
foo: {
bar: {
baz: {
a: {
x
}
}
}
}
} = test,
other = babelHelpers.objectWithoutProperties(test.foo.bar.baz.a, ["x"]);

View File

@@ -6,6 +6,11 @@ const defunct = {
}
}
};
const { outer: { inner: { three } } } = defunct,
other = babelHelpers.objectWithoutProperties(defunct.outer.inner, ["three"]);
const {
outer: {
inner: {
three
}
}
} = defunct,
other = babelHelpers.objectWithoutProperties(defunct.outer.inner, ["three"]);

View File

@@ -1,44 +1,81 @@
function a(_ref) {
let a34 = babelHelpers.objectWithoutProperties(_ref, []);
}
function a2(_ref2) {
let { a1 } = _ref2,
let {
a1
} = _ref2,
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
}
function a3(_ref3) {
let { a2, b2 } = _ref3,
let {
a2,
b2
} = _ref3,
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
}
function a4(_ref4, _ref5) {
let { a5 } = _ref5,
let {
a5
} = _ref5,
c5 = babelHelpers.objectWithoutProperties(_ref5, ["a5"]);
let { a3 } = _ref4,
let {
a3
} = _ref4,
c3 = babelHelpers.objectWithoutProperties(_ref4, ["a3"]);
}
function a5(_ref6) {
let { a3, b2: { ba1 } } = _ref6,
let {
a3,
b2: {
ba1
}
} = _ref6,
ba2 = babelHelpers.objectWithoutProperties(_ref6.b2, ["ba1"]),
c3 = babelHelpers.objectWithoutProperties(_ref6, ["a3", "b2"]);
}
function a6(_ref7) {
let { a3, b2: { ba1 } } = _ref7,
let {
a3,
b2: {
ba1
}
} = _ref7,
ba2 = babelHelpers.objectWithoutProperties(_ref7.b2, ["ba1"]);
}
function a7(_ref8 = {}) {
let { a1 = 1 } = _ref8,
let {
a1 = 1
} = _ref8,
b1 = babelHelpers.objectWithoutProperties(_ref8, ["a1"]);
}
function a8([_ref9]) {
let a1 = babelHelpers.objectWithoutProperties(_ref9, []);
}
function a9([_ref10]) {
let { a1 } = _ref10,
let {
a1
} = _ref10,
a2 = babelHelpers.objectWithoutProperties(_ref10, ["a1"]);
}
function a10([a1, _ref11]) {
let a2 = babelHelpers.objectWithoutProperties(_ref11, []);
}
// Unchanged
} // Unchanged
function b(a) {}
function b2(a, ...b) {}
function b3({ b }) {}
function b3({
b
}) {}

View File

@@ -1,29 +1,52 @@
var z = {};
var x = babelHelpers.objectWithoutProperties(z, []);
var a = babelHelpers.objectWithoutProperties({ a: 1 }, []);
var a = babelHelpers.objectWithoutProperties({
a: 1
}, []);
var x = babelHelpers.objectWithoutProperties(a.b, []);
var x = babelHelpers.objectWithoutProperties(a(), []);
var { x1 } = z,
var {
x1
} = z,
y1 = babelHelpers.objectWithoutProperties(z, ["x1"]);
x1++;
var { [a]: b } = z,
var {
[a]: b
} = z,
c = babelHelpers.objectWithoutProperties(z, [a]);
var { x1 } = z,
var {
x1
} = z,
y1 = babelHelpers.objectWithoutProperties(z, ["x1"]);
let { x2, y2 } = z,
z2 = babelHelpers.objectWithoutProperties(z, ["x2", "y2"]);
const { w3, x3, y3 } = z,
z4 = babelHelpers.objectWithoutProperties(z, ["w3", "x3", "y3"]);
let {
x: { a: xa, [d]: f }
x2,
y2
} = z,
z2 = babelHelpers.objectWithoutProperties(z, ["x2", "y2"]);
const {
w3,
x3,
y3
} = z,
z4 = babelHelpers.objectWithoutProperties(z, ["w3", "x3", "y3"]);
let {
x: {
a: xa,
[d]: f
}
} = complex,
asdf = babelHelpers.objectWithoutProperties(complex.x, ["a", d]),
d = babelHelpers.objectWithoutProperties(complex.y, []),
g = babelHelpers.objectWithoutProperties(complex, ["x"]);
let {} = z,
y4 = babelHelpers.objectWithoutProperties(z.x4, []);
var { z } = babelHelpers.objectWithoutProperties({ z: 1 }, []);
var { x = 5 } = babelHelpers.objectWithoutProperties({ x: 1 }, []);
var {
z
} = babelHelpers.objectWithoutProperties({
z: 1
}, []);
var {
x = 5
} = babelHelpers.objectWithoutProperties({
x: 1
}, []);

View File

@@ -1,5 +1,9 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
z = _extends({ x }, y);
z = { x, w: _extends({}, y) };
z = _extends({
x
}, y);
z = {
x,
w: _extends({}, y)
};

View File

@@ -1,3 +1,9 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
_extends({ x }, y, { a }, b, { c });
_extends({
x
}, y, {
a
}, b, {
c
});

View File

@@ -1,15 +1,24 @@
const _foo = foo(),
{ s } = _foo,
{
s
} = _foo,
t = babelHelpers.objectWithoutProperties(_foo, ["s"]);
const _bar = bar(),
{ s: { q1 } } = _bar,
{
s: {
q1
}
} = _bar,
q2 = babelHelpers.objectWithoutProperties(_bar.s, ["q1"]),
q3 = babelHelpers.objectWithoutProperties(_bar, ["s"]);
const { a } = foo((_ref) => {
let { b } = _ref,
const {
a
} = foo((_ref) => {
let {
b
} = _ref,
c = babelHelpers.objectWithoutProperties(_ref, ["b"]);
console.log(b, c);
});
});

View File

@@ -1,14 +1,18 @@
const { x } = a,
const {
x
} = a,
y = babelHelpers.objectWithoutProperties(a, ["x"]),
z = foo(y);
const s = babelHelpers.objectWithoutProperties(r, []),
t = foo(s);
t = foo(s); // ordering is preserved
// ordering is preserved
var l = foo(),
_bar = bar(),
{ m: { n } } = _bar,
{
m: {
n
}
} = _bar,
o = babelHelpers.objectWithoutProperties(_bar.m, ["n"]),
p = babelHelpers.objectWithoutProperties(_bar, ["m"]),
q = baz();
q = baz();

View File

@@ -1 +1,3 @@
z = Object.assign({ x }, y);
z = Object.assign({
x
}, y);