Skip to content

Commit 813f581

Browse files
committed
run prettier on generated files to make them whitespace insensitive
1 parent 19e60f0 commit 813f581

File tree

17 files changed

+167
-140
lines changed

17 files changed

+167
-140
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"json-diff": "^0.5.4",
4242
"mocha": "^8.2.1",
4343
"npm-run-all": "^4.1.5",
44+
"prettier": "^2.2.1",
4445
"release-util-fnd": "^2.0.1"
4546
}
4647
}

test/cli/run

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,86 @@ root=`node -r fs -p "fs.realpathSync(process.argv[1]);" "$root"`
99

1010
begin "$root/test_basic"
1111
faucet
12+
prettier --write --loglevel error ./dist
1213
assert_identical "./dist/bundle.js" "./expected.js"
1314
end
1415

1516
begin "$root/test_basic" # once more with fingerprinting
1617
faucet --fingerprint
18+
prettier --write --loglevel error ./dist
1719
assert_identical "./dist/bundle-3930f63318329292cd52218fdbd7a70d.js" "./expected.js"
1820
end
1921

2022
begin "$root/test_transpilation"
2123
faucet
24+
prettier --write --loglevel error ./dist
2225
assert_identical "./dist/bundle.js" "./expected.js"
2326
end
2427

2528
begin "$root/test_sourcemap"
2629
faucet --sourcemaps
30+
prettier --write --loglevel error ./dist
2731
assert_identical_sourcemap "./dist/bundle.js" "./expected.js" "./expected.js.map"
2832
assert_identical_sourcemap "./dist/bundle_esnext.js" "./expected_esnext.js" "./expected_esnext.js.map"
2933
end
3034

3135
begin "$root/test_jsx"
3236
faucet
37+
prettier --write --loglevel error ./dist
3338
assert_identical "./dist/bundle.js" "./expected.js"
3439
end
3540

3641
begin "$root/test_typescript"
3742
faucet
43+
prettier --write --loglevel error ./dist
3844
assert_identical "./dist/bundle.js" "./expected.js"
3945
end
4046

4147
begin "$root/test_browserslist"
4248
faucet
49+
prettier --write --loglevel error ./dist
4350
assert_identical "./dist/bundle.js" "./expected.js"
4451
assert_identical "./dist/bundle_alt.js" "./expected_legacy.js"
4552
assert_identical "./dist/bundle_legacy.js" "./expected_legacy.js"
4653
end
4754

4855
begin "$root/test_multi"
4956
faucet
57+
prettier --write --loglevel error ./dist
5058
assert_identical "./dist/foo.js" "./expected_foo.js"
5159
assert_identical "./dist/bar.js" "./expected_bar.js"
5260
assert_json "./dist/manifest.json" "./expected.json"
5361
end
5462

5563
begin "$root/test_manifest"
5664
faucet --fingerprint
65+
prettier --write --loglevel error ./dist
5766
assert_identical "./dist/manifest.json" "./expected.json"
5867
end
5968

6069
begin "$root/test_manifest_uris"
6170
faucet --fingerprint
71+
prettier --write --loglevel error ./dist
6272
assert_json "./dist/manifest.json" "./expected.json"
6373
end
6474

6575
begin "$root/test_fingerprinting"
6676
faucet --fingerprint
77+
prettier --write --loglevel error ./dist
6778
assert_identical "./dist/bundle-3930f63318329292cd52218fdbd7a70d.js" "./expected.js"
6879
assert_identical "./dist/bundle_alt.js" "./expected.js"
6980
end
7081

7182
begin "$root/test_bundle_customization"
7283
faucet
84+
prettier --write --loglevel error ./dist
7385
assert_identical "./dist/bundle.js" "./expected.js"
7486
assert_identical "./dist/bundle_cjs.js" "./expected_cjs.js"
7587
end
7688

7789
begin "$root/test_custom_config"
7890
faucet -c assets.js
91+
prettier --write --loglevel error ./dist
7992
assert_identical "./dist/bundle.js" "./expected.js"
8093
end
8194

test/cli/test_basic/expected.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
var util = "UTIL";
4+
var util = "UTIL";
55

6-
console.log(`[…] ${util}`);
7-
8-
}());
6+
console.log(`[…] ${util}`);
7+
})();
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
class Util {}
5-
const FOO = "lorem ipsum";
6-
const BAR = "dolor sit amet";
4+
class Util {}
5+
const FOO = "lorem ipsum";
6+
const BAR = "dolor sit amet";
77

8-
console.log(`~~ ${Util} ~~ ${FOO} ~~ ${BAR} ~~`);
9-
10-
}());
8+
console.log(`~~ ${Util} ~~ ${FOO} ~~ ${BAR} ~~`);
9+
})();
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
function _classCallCheck(instance, Constructor) {
5-
if (!(instance instanceof Constructor)) {
6-
throw new TypeError("Cannot call a class as a function");
7-
}
8-
}
4+
function _classCallCheck(instance, Constructor) {
5+
if (!(instance instanceof Constructor)) {
6+
throw new TypeError("Cannot call a class as a function");
7+
}
8+
}
99

10-
var Util = function Util() {
11-
_classCallCheck(this, Util);
12-
};
13-
var FOO = "lorem ipsum";
14-
var BAR = "dolor sit amet";
10+
var Util = function Util() {
11+
_classCallCheck(this, Util);
12+
};
13+
var FOO = "lorem ipsum";
14+
var BAR = "dolor sit amet";
1515

16-
console.log("~~ ".concat(Util, " ~~ ").concat(FOO, " ~~ ").concat(BAR, " ~~"));
17-
18-
}());
16+
console.log(
17+
"~~ ".concat(Util, " ~~ ").concat(FOO, " ~~ ").concat(BAR, " ~~")
18+
);
19+
})();
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
(function (global, factory) {
2-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3-
typeof define === 'function' && define.amd ? define(factory) :
4-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MYLIB = factory());
5-
}(this, (function () { 'use strict';
2+
typeof exports === "object" && typeof module !== "undefined"
3+
? (module.exports = factory())
4+
: typeof define === "function" && define.amd
5+
? define(factory)
6+
: ((global =
7+
typeof globalThis !== "undefined"
8+
? globalThis
9+
: global || self),
10+
(global.MYLIB = factory()));
11+
})(this, function () {
12+
"use strict";
613

7-
var index = _ => {
8-
console.log("lipsum");
9-
};
14+
var index = (_) => {
15+
console.log("lipsum");
16+
};
1017

11-
return index;
12-
13-
})));
18+
return index;
19+
});

test/cli/test_bundle_customization/expected_cjs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'use strict';
1+
"use strict";
22

3-
var index = _ => {
3+
var index = (_) => {
44
console.log("lipsum");
55
};
66

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
5-
6-
}());
4+
})();
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
var util = "UTIL";
4+
var util = "UTIL";
55

6-
console.log(`[…] ${util}`);
7-
8-
}());
6+
console.log(`[…] ${util}`);
7+
})();

test/cli/test_jsx/expected.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
(function () {
2-
'use strict';
2+
"use strict";
33

4-
function _classCallCheck(instance, Constructor) {
5-
if (!(instance instanceof Constructor)) {
6-
throw new TypeError("Cannot call a class as a function");
7-
}
8-
}
4+
function _classCallCheck(instance, Constructor) {
5+
if (!(instance instanceof Constructor)) {
6+
throw new TypeError("Cannot call a class as a function");
7+
}
8+
}
99

10-
var MyComponent = function MyComponent() {
11-
_classCallCheck(this, MyComponent);
12-
};
10+
var MyComponent = function MyComponent() {
11+
_classCallCheck(this, MyComponent);
12+
};
1313

14-
var el = createElement(MyComponent, {
15-
type: "dummy"
16-
}, createElement("my-element", null, "lorem ipsum", createElement(Fragment, null, createElement("mark", null, "666"), "dolor sit amet")));
17-
console.log(el);
18-
19-
}());
14+
var el = createElement(
15+
MyComponent,
16+
{
17+
type: "dummy",
18+
},
19+
createElement(
20+
"my-element",
21+
null,
22+
"lorem ipsum",
23+
createElement(
24+
Fragment,
25+
null,
26+
createElement("mark", null, "666"),
27+
"dolor sit amet"
28+
)
29+
)
30+
);
31+
console.log(el);
32+
})();

0 commit comments

Comments
 (0)