From b25ff237bb77171ee05585e5178247c62b11cd01 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 5 Feb 2019 10:06:32 +0100 Subject: [PATCH] Prettify source code --- benchmark/benchmark.js | 4 ++-- declarations.d.ts | 4 ++-- declarations/WebpackOptions.d.ts | 2 +- declarations/plugins/BannerPlugin.d.ts | 16 ++++++------- declarations/plugins/IgnorePlugin.d.ts | 4 ++-- declarations/plugins/ProgressPlugin.d.ts | 4 ++-- lib/AmdMainTemplatePlugin.js | 4 ++-- lib/JsonGenerator.js | 5 ++-- lib/Parser.js | 4 ++-- lib/Stats.js | 4 ++-- lib/UmdMainTemplatePlugin.js | 12 +++++----- lib/WatchIgnorePlugin.js | 4 ++-- lib/WebpackOptionsApply.js | 16 ++++++------- lib/WebpackOptionsDefaulter.js | 12 ++++------ lib/optimize/SideEffectsFlagPlugin.js | 2 +- lib/optimize/SplitChunksPlugin.js | 30 ++++++++++++------------ lib/util/StackedSetMap.js | 10 ++++---- lib/util/deterministicGrouping.js | 4 ++-- lib/util/identifier.js | 9 ++++--- 19 files changed, 70 insertions(+), 80 deletions(-) diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js index 4bd74f5e5..7df5f9707 100644 --- a/benchmark/benchmark.js +++ b/benchmark/benchmark.js @@ -206,8 +206,8 @@ const tests = { const suite = new Benchmark.Suite(); Object.keys(tests) - .filter( - name => (process.argv.length > 2 ? name.includes(process.argv[2]) : true) + .filter(name => + process.argv.length > 2 ? name.includes(process.argv[2]) : true ) .forEach(name => { const test = tests[name]; diff --git a/declarations.d.ts b/declarations.d.ts index 8e07f54e2..dc63ee6b9 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -234,8 +234,8 @@ interface RuleSetConditionsRecursive extends Array {} interface RuleSetConditionsAbsoluteRecursive extends Array< - import("./declarations/WebpackOptions").RuleSetConditionAbsolute - > {} + import("./declarations/WebpackOptions").RuleSetConditionAbsolute + > {} /** * Global variable declarations diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 05521817a..6b99ff692 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -15,7 +15,7 @@ export type Entry = EntryDynamic | EntryStatic; * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "EntryDynamic". */ -export type EntryDynamic = (() => EntryStatic | Promise); +export type EntryDynamic = () => EntryStatic | Promise; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "EntryStatic". diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts index 4b3810596..f2e5d96a2 100644 --- a/declarations/plugins/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -11,15 +11,13 @@ export type BannerPluginArgument = /** * The banner as function, it will be wrapped in a comment */ -export type BannerFunction = ( - data: { - hash: string; - chunk: import("../../lib/Chunk"); - filename: string; - basename: string; - query: string; - } -) => string; +export type BannerFunction = (data: { + hash: string; + chunk: import("../../lib/Chunk"); + filename: string; + basename: string; + query: string; +}) => string; export type Rules = Rule[] | Rule; export type Rule = RegExp | string; diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts index 416b8bb0b..323535d76 100644 --- a/declarations/plugins/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -19,9 +19,9 @@ export type IgnorePluginOptions = /** * A filter function for context */ - checkContext?: ((context: string) => boolean); + checkContext?: (context: string) => boolean; /** * A filter function for resource and context */ - checkResource?: ((resource: string, context: string) => boolean); + checkResource?: (resource: string, context: string) => boolean; }; diff --git a/declarations/plugins/ProgressPlugin.d.ts b/declarations/plugins/ProgressPlugin.d.ts index 78d4f74a2..d0fa1b45b 100644 --- a/declarations/plugins/ProgressPlugin.d.ts +++ b/declarations/plugins/ProgressPlugin.d.ts @@ -8,11 +8,11 @@ export type ProgressPluginArgument = ProgressPluginOptions | HandlerFunction; /** * Function that executes for every progress step */ -export type HandlerFunction = (( +export type HandlerFunction = ( percentage: number, msg: string, ...args: string[] -) => void); +) => void; export interface ProgressPluginOptions { /** diff --git a/lib/AmdMainTemplatePlugin.js b/lib/AmdMainTemplatePlugin.js index 5e2c0bd7d..705f88d52 100644 --- a/lib/AmdMainTemplatePlugin.js +++ b/lib/AmdMainTemplatePlugin.js @@ -40,8 +40,8 @@ class AmdMainTemplatePlugin { const onRenderWithEntry = (source, chunk, hash) => { const externals = chunk.getModules().filter(m => m.external); const externalsDepsArray = JSON.stringify( - externals.map( - m => (typeof m.request === "object" ? m.request.amd : m.request) + externals.map(m => + typeof m.request === "object" ? m.request.amd : m.request ) ); const externalsArguments = externals diff --git a/lib/JsonGenerator.js b/lib/JsonGenerator.js index 5b4c73953..232603831 100644 --- a/lib/JsonGenerator.js +++ b/lib/JsonGenerator.js @@ -12,9 +12,8 @@ const stringifySafe = data => { return undefined; // Invalid JSON } - return stringified.replace( - /\u2028|\u2029/g, - str => (str === "\u2029" ? "\\u2029" : "\\u2028") + return stringified.replace(/\u2028|\u2029/g, str => + str === "\u2029" ? "\\u2029" : "\\u2028" ); // invalid in JavaScript but valid JSON }; diff --git a/lib/Parser.js b/lib/Parser.js index 7a83c983c..9d9cf2e5b 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -1335,8 +1335,8 @@ class Parser extends Tapable { statement.kind === "const" ? this.hooks.varDeclarationConst : statement.kind === "let" - ? this.hooks.varDeclarationLet - : this.hooks.varDeclarationVar; + ? this.hooks.varDeclarationLet + : this.hooks.varDeclarationVar; for (const declarator of statement.declarations) { switch (declarator.type) { case "VariableDeclarator": { diff --git a/lib/Stats.js b/lib/Stats.js index 6d338342f..039ed5169 100644 --- a/lib/Stats.js +++ b/lib/Stats.js @@ -288,8 +288,8 @@ class Stats { e.chunk.hasRuntime() ? " [entry]" : e.chunk.canBeInitial() - ? " [initial]" - : "" + ? " [initial]" + : "" }\n`; } if (e.file) { diff --git a/lib/UmdMainTemplatePlugin.js b/lib/UmdMainTemplatePlugin.js index ba5d24a2b..7843c78ff 100644 --- a/lib/UmdMainTemplatePlugin.js +++ b/lib/UmdMainTemplatePlugin.js @@ -236,12 +236,12 @@ class UmdMainTemplatePlugin { amdFactory + ");\n" : this.names.amd && this.namedDefine === true - ? " define(" + - libraryName(this.names.amd) + - ", [], " + - amdFactory + - ");\n" - : " define([], " + amdFactory + ");\n") + + ? " define(" + + libraryName(this.names.amd) + + ", [], " + + amdFactory + + ");\n" + : " define([], " + amdFactory + ");\n") + (this.names.root || this.names.commonjs ? getAuxilaryComment("commonjs") + " else if(typeof exports === 'object')\n" + diff --git a/lib/WatchIgnorePlugin.js b/lib/WatchIgnorePlugin.js index dc00cf5fd..5ba9cd056 100644 --- a/lib/WatchIgnorePlugin.js +++ b/lib/WatchIgnorePlugin.js @@ -17,8 +17,8 @@ class IgnoringWatchFileSystem { watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) { const ignored = path => - this.paths.some( - p => (p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0) + this.paths.some(p => + p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0 ); const notIgnored = path => !ignored(path); diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 6afa3314d..0dc3ed59c 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -260,10 +260,10 @@ class WebpackOptionsApply extends OptionsApply { "MappingURL=[url]\n//# source" + "MappingURL=[url]\n*/" : legacy - ? "\n/*\n//@ source" + "MappingURL=[url]\n*/" - : modern - ? "\n//# source" + "MappingURL=[url]" - : null; + ? "\n/*\n//@ source" + "MappingURL=[url]\n*/" + : modern + ? "\n//# source" + "MappingURL=[url]" + : null; const Plugin = evalWrapped ? EvalSourceMapDevToolPlugin : SourceMapDevToolPlugin; @@ -286,10 +286,10 @@ class WebpackOptionsApply extends OptionsApply { legacy && modern ? "\n//@ sourceURL=[url]\n//# sourceURL=[url]" : legacy - ? "\n//@ sourceURL=[url]" - : modern - ? "\n//# sourceURL=[url]" - : null; + ? "\n//@ sourceURL=[url]" + : modern + ? "\n//# sourceURL=[url]" + : null; new EvalDevToolModulePlugin({ sourceUrlComment: comment, moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate, diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index b6e69ef98..822134c1f 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -33,10 +33,8 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("entry", "./src"); - this.set( - "devtool", - "make", - options => (options.mode === "development" ? "eval" : false) + this.set("devtool", "make", options => + options.mode === "development" ? "eval" : false ); this.set("cache", "make", options => options.mode === "development"); @@ -193,10 +191,8 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { }); this.set("performance.maxAssetSize", 250000); this.set("performance.maxEntrypointSize", 250000); - this.set( - "performance.hints", - "make", - options => (isProductionLikeMode(options) ? "warning" : false) + this.set("performance.hints", "make", options => + isProductionLikeMode(options) ? "warning" : false ); this.set("optimization", "call", value => Object.assign({}, value)); diff --git a/lib/optimize/SideEffectsFlagPlugin.js b/lib/optimize/SideEffectsFlagPlugin.js index 4b618c299..e2a706a7f 100644 --- a/lib/optimize/SideEffectsFlagPlugin.js +++ b/lib/optimize/SideEffectsFlagPlugin.js @@ -123,7 +123,7 @@ class SideEffectsFlagPlugin { dep, reason.explanation ? reason.explanation + - " (skipped side-effect-free modules)" + " (skipped side-effect-free modules)" : "(skipped side-effect-free modules)" ); // removing the currect reason, by not adding it to the newReasons array diff --git a/lib/optimize/SplitChunksPlugin.js b/lib/optimize/SplitChunksPlugin.js index 729c4eaa2..2811d9b4b 100644 --- a/lib/optimize/SplitChunksPlugin.js +++ b/lib/optimize/SplitChunksPlugin.js @@ -534,8 +534,8 @@ module.exports = class SplitChunksPlugin { cacheGroupSource.minSize !== undefined ? cacheGroupSource.minSize : cacheGroupSource.enforce - ? 0 - : this.options.minSize, + ? 0 + : this.options.minSize, minSizeForMaxSize: cacheGroupSource.minSize !== undefined ? cacheGroupSource.minSize @@ -544,26 +544,26 @@ module.exports = class SplitChunksPlugin { cacheGroupSource.maxSize !== undefined ? cacheGroupSource.maxSize : cacheGroupSource.enforce - ? 0 - : this.options.maxSize, + ? 0 + : this.options.maxSize, minChunks: cacheGroupSource.minChunks !== undefined ? cacheGroupSource.minChunks : cacheGroupSource.enforce - ? 1 - : this.options.minChunks, + ? 1 + : this.options.minChunks, maxAsyncRequests: cacheGroupSource.maxAsyncRequests !== undefined ? cacheGroupSource.maxAsyncRequests : cacheGroupSource.enforce - ? Infinity - : this.options.maxAsyncRequests, + ? Infinity + : this.options.maxAsyncRequests, maxInitialRequests: cacheGroupSource.maxInitialRequests !== undefined ? cacheGroupSource.maxInitialRequests : cacheGroupSource.enforce - ? Infinity - : this.options.maxInitialRequests, + ? Infinity + : this.options.maxInitialRequests, getName: cacheGroupSource.getName !== undefined ? cacheGroupSource.getName @@ -683,11 +683,11 @@ module.exports = class SplitChunksPlugin { const maxRequests = chunk.isOnlyInitial() ? item.cacheGroup.maxInitialRequests : chunk.canBeInitial() - ? Math.min( - item.cacheGroup.maxInitialRequests, - item.cacheGroup.maxAsyncRequests - ) - : item.cacheGroup.maxAsyncRequests; + ? Math.min( + item.cacheGroup.maxInitialRequests, + item.cacheGroup.maxAsyncRequests + ) + : item.cacheGroup.maxAsyncRequests; return ( !isFinite(maxRequests) || getRequests(chunk) < maxRequests ); diff --git a/lib/util/StackedSetMap.js b/lib/util/StackedSetMap.js index fcf628b0d..1805155b4 100644 --- a/lib/util/StackedSetMap.js +++ b/lib/util/StackedSetMap.js @@ -96,12 +96,10 @@ class StackedSetMap { asPairArray() { this._compress(); - return Array.from( - this.map.entries(), - pair => - /** @type {[TODO, TODO]} */ (pair[1] === UNDEFINED_MARKER - ? [pair[0], undefined] - : pair) + return Array.from(this.map.entries(), pair => + /** @type {[TODO, TODO]} */ (pair[1] === UNDEFINED_MARKER + ? [pair[0], undefined] + : pair) ); } diff --git a/lib/util/deterministicGrouping.js b/lib/util/deterministicGrouping.js index 4fc6859cf..825e4bc51 100644 --- a/lib/util/deterministicGrouping.js +++ b/lib/util/deterministicGrouping.js @@ -156,8 +156,8 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => { // We hit an edgecase where the working set is already smaller than minSize // We merge it with the smallest result node to keep minSize intact if (result.length > 0) { - const smallestGroup = result.reduce( - (min, group) => (min.size > group.size ? group : min) + const smallestGroup = result.reduce((min, group) => + min.size > group.size ? group : min ); for (const node of initialGroup.nodes) smallestGroup.nodes.push(node); smallestGroup.nodes.sort((a, b) => { diff --git a/lib/util/identifier.js b/lib/util/identifier.js index 186bc064e..88a7b0f4a 100644 --- a/lib/util/identifier.js +++ b/lib/util/identifier.js @@ -36,11 +36,10 @@ const normalizePathSeparator = p => p.replace(/\\/g, "/"); const _makePathsRelative = (context, identifier) => { return identifier .split(/([|! ])/) - .map( - str => - looksLikeAbsolutePath(str) - ? normalizePathSeparator(path.relative(context, str)) - : str + .map(str => + looksLikeAbsolutePath(str) + ? normalizePathSeparator(path.relative(context, str)) + : str ) .join(""); };