Skip to content

Commit 2a9452e

Browse files
committed
Add brackets for multiline if/for statements
1 parent b80296f commit 2a9452e

File tree

84 files changed

+1208
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1208
-549
lines changed

lib/AmdMainTemplatePlugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class AmdMainTemplatePlugin {
7171
}
7272

7373
mainTemplate.hooks.globalHashPaths.tap("AmdMainTemplatePlugin", paths => {
74-
if (this.name) paths.push(this.name);
74+
if (this.name) {
75+
paths.push(this.name);
76+
}
7577
return paths;
7678
});
7779

lib/BannerPlugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const validateOptions = require("schema-utils");
1313
const schema = require("../schemas/plugins/BannerPlugin.json");
1414

1515
const wrapComment = str => {
16-
if (!str.includes("\n")) return Template.toComment(str);
16+
if (!str.includes("\n")) {
17+
return Template.toComment(str);
18+
}
1719
return `/*!\n * ${str
1820
.replace(/\*\//g, "* /")
1921
.split("\n")

lib/BasicEvaluatedExpression.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,21 @@ class BasicEvaluatedExpression {
9090

9191
asBool() {
9292
if (this.truthy) return true;
93-
else if (this.falsy) return false;
94-
else if (this.isBoolean()) return this.bool;
95-
else if (this.isNull()) return false;
96-
else if (this.isString()) return this.string !== "";
97-
else if (this.isNumber()) return this.number !== 0;
98-
else if (this.isRegExp()) return true;
99-
else if (this.isArray()) return true;
100-
else if (this.isConstArray()) return true;
101-
else if (this.isWrapped())
93+
if (this.falsy) return false;
94+
if (this.isBoolean()) return this.bool;
95+
if (this.isNull()) return false;
96+
if (this.isString()) return this.string !== "";
97+
if (this.isNumber()) return this.number !== 0;
98+
if (this.isRegExp()) return true;
99+
if (this.isArray()) return true;
100+
if (this.isConstArray()) return true;
101+
if (this.isWrapped()) {
102102
return (this.prefix && this.prefix.asBool()) ||
103103
(this.postfix && this.postfix.asBool())
104104
? true
105105
: undefined;
106-
else if (this.isTemplateString()) {
106+
}
107+
if (this.isTemplateString()) {
107108
for (const quasi of this.quasis) {
108109
if (quasi.asBool()) return true;
109110
}
@@ -165,7 +166,9 @@ class BasicEvaluatedExpression {
165166
this.type = TypeConditional;
166167
this.options = [];
167168
}
168-
for (const item of options) this.options.push(item);
169+
for (const item of options) {
170+
this.options.push(item);
171+
}
169172
return this;
170173
}
171174

lib/CachePlugin.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ class CachePlugin {
2626
(childCompiler, compilerName, compilerIndex) => {
2727
if (cache) {
2828
let childCache;
29-
if (!cache.children) cache.children = {};
30-
if (!cache.children[compilerName])
29+
if (!cache.children) {
30+
cache.children = {};
31+
}
32+
if (!cache.children[compilerName]) {
3133
cache.children[compilerName] = [];
32-
if (cache.children[compilerName][compilerIndex])
34+
}
35+
if (cache.children[compilerName][compilerIndex]) {
3336
childCache = cache.children[compilerName][compilerIndex];
34-
else cache.children[compilerName].push((childCache = {}));
37+
} else {
38+
cache.children[compilerName].push((childCache = {}));
39+
}
3540
registerCacheToCompiler(childCompiler, childCache);
3641
}
3742
}
@@ -43,7 +48,9 @@ class CachePlugin {
4348
this.watching = true;
4449
});
4550
compiler.hooks.run.tapAsync("CachePlugin", (compiler, callback) => {
46-
if (!compiler._lastCompilationFileDependencies) return callback();
51+
if (!compiler._lastCompilationFileDependencies) {
52+
return callback();
53+
}
4754
const fs = compiler.inputFileSystem;
4855
const fileTs = (compiler.fileTimestamps = new Map());
4956
asyncLib.forEach(

lib/Chunk.js

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,14 @@ class Chunk {
378378
otherChunk._groups.clear();
379379

380380
if (this.name && otherChunk.name) {
381-
if (this.name.length !== otherChunk.name.length)
381+
if (this.name.length !== otherChunk.name.length) {
382382
this.name =
383383
this.name.length < otherChunk.name.length
384384
? this.name
385385
: otherChunk.name;
386-
else
386+
} else {
387387
this.name = this.name < otherChunk.name ? this.name : otherChunk.name;
388+
}
388389
}
389390

390391
return true;
@@ -420,12 +421,16 @@ class Chunk {
420421
for (const chunkGroup of queue) {
421422
if (a.isInGroup(chunkGroup)) continue;
422423
if (chunkGroup.isInitial()) return false;
423-
for (const parent of chunkGroup.parentsIterable) queue.add(parent);
424+
for (const parent of chunkGroup.parentsIterable) {
425+
queue.add(parent);
426+
}
424427
}
425428
return true;
426429
};
427430

428-
if (this.preventIntegration || otherChunk.preventIntegration) return false;
431+
if (this.preventIntegration || otherChunk.preventIntegration) {
432+
return false;
433+
}
429434

430435
if (this.hasRuntime() !== otherChunk.hasRuntime()) {
431436
if (this.hasRuntime()) {
@@ -436,7 +441,11 @@ class Chunk {
436441
return false;
437442
}
438443
}
439-
if (this.hasEntryModule() || otherChunk.hasEntryModule()) return false;
444+
445+
if (this.hasEntryModule() || otherChunk.hasEntryModule()) {
446+
return false;
447+
}
448+
440449
return true;
441450
}
442451

@@ -509,14 +518,20 @@ class Chunk {
509518
);
510519

511520
for (const chunkGroup of this.groupsIterable) {
512-
for (const child of chunkGroup.childrenIterable) queue.add(child);
521+
for (const child of chunkGroup.childrenIterable) {
522+
queue.add(child);
523+
}
513524
}
514525

515526
for (const chunkGroup of queue) {
516527
for (const chunk of chunkGroup.chunks) {
517-
if (!initialChunks.has(chunk)) chunks.add(chunk);
528+
if (!initialChunks.has(chunk)) {
529+
chunks.add(chunk);
530+
}
531+
}
532+
for (const child of chunkGroup.childrenIterable) {
533+
queue.add(child);
518534
}
519-
for (const child of chunkGroup.childrenIterable) queue.add(child);
520535
}
521536

522537
return chunks;
@@ -530,11 +545,14 @@ class Chunk {
530545
for (const chunk of this.getAllAsyncChunks()) {
531546
chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash;
532547
for (const key of Object.keys(chunk.contentHash)) {
533-
if (!chunkContentHashMap[key])
548+
if (!chunkContentHashMap[key]) {
534549
chunkContentHashMap[key] = Object.create(null);
550+
}
535551
chunkContentHashMap[key][chunk.id] = chunk.contentHash[key];
536552
}
537-
if (chunk.name) chunkNameMap[chunk.id] = chunk.name;
553+
if (chunk.name) {
554+
chunkNameMap[chunk.id] = chunk.name;
555+
}
538556
}
539557

540558
return {
@@ -572,12 +590,16 @@ class Chunk {
572590
const cmp = b.order - a.order;
573591
if (cmp !== 0) return cmp;
574592
// TOOD webpack 5 remove this check of compareTo
575-
if (a.group.compareTo) return a.group.compareTo(b.group);
593+
if (a.group.compareTo) {
594+
return a.group.compareTo(b.group);
595+
}
576596
return 0;
577597
});
578598
result[name] = Array.from(
579599
list.reduce((set, item) => {
580-
for (const chunk of item.group.chunks) set.add(chunk.id);
600+
for (const chunk of item.group.chunks) {
601+
set.add(chunk.id);
602+
}
581603
return set;
582604
}, new Set())
583605
);
@@ -592,8 +614,9 @@ class Chunk {
592614
const data = chunk.getChildIdsByOrders();
593615
for (const key of Object.keys(data)) {
594616
let chunkMap = chunkMaps[key];
595-
if (chunkMap === undefined)
617+
if (chunkMap === undefined) {
596618
chunkMaps[key] = chunkMap = Object.create(null);
619+
}
597620
chunkMap[chunk.id] = data[key];
598621
}
599622
}
@@ -642,12 +665,17 @@ class Chunk {
642665
if (!chunksProcessed.has(chunk)) {
643666
chunksProcessed.add(chunk);
644667
if (!filterChunkFn || filterChunkFn(chunk)) {
645-
for (const module of chunk.modulesIterable)
646-
if (filterFn(module)) return true;
668+
for (const module of chunk.modulesIterable) {
669+
if (filterFn(module)) {
670+
return true;
671+
}
672+
}
647673
}
648674
}
649675
}
650-
for (const child of chunkGroup.childrenIterable) queue.add(child);
676+
for (const child of chunkGroup.childrenIterable) {
677+
queue.add(child);
678+
}
651679
}
652680
return false;
653681
}

lib/ChunkGroup.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ class ChunkGroup {
259259

260260
setParents(newParents) {
261261
this._parents.clear();
262-
for (const p of newParents) this._parents.add(p);
262+
for (const p of newParents) {
263+
this._parents.add(p);
264+
}
263265
}
264266

265267
getNumberOfParents() {
@@ -418,7 +420,9 @@ class ChunkGroup {
418420
if (key.endsWith("Order")) {
419421
const name = key.substr(0, key.length - "Order".length);
420422
let list = lists.get(name);
421-
if (list === undefined) lists.set(name, (list = []));
423+
if (list === undefined) {
424+
lists.set(name, (list = []));
425+
}
422426
list.push({
423427
order: childGroup.options[key],
424428
group: childGroup
@@ -433,7 +437,9 @@ class ChunkGroup {
433437
const cmp = b.order - a.order;
434438
if (cmp !== 0) return cmp;
435439
// TOOD webpack 5 remove this check of compareTo
436-
if (a.group.compareTo) return a.group.compareTo(b.group);
440+
if (a.group.compareTo) {
441+
return a.group.compareTo(b.group);
442+
}
437443
return 0;
438444
});
439445
result[name] = list.map(i => i.group);
@@ -444,20 +450,22 @@ class ChunkGroup {
444450
checkConstraints() {
445451
const chunk = this;
446452
for (const child of chunk._children) {
447-
if (!child._parents.has(chunk))
453+
if (!child._parents.has(chunk)) {
448454
throw new Error(
449455
`checkConstraints: child missing parent ${chunk.debugId} -> ${
450456
child.debugId
451457
}`
452458
);
459+
}
453460
}
454461
for (const parentChunk of chunk._parents) {
455-
if (!parentChunk._children.has(chunk))
462+
if (!parentChunk._children.has(chunk)) {
456463
throw new Error(
457464
`checkConstraints: parent missing child ${parentChunk.debugId} <- ${
458465
chunk.debugId
459466
}`
460467
);
468+
}
461469
}
462470
}
463471
}

0 commit comments

Comments
 (0)