diff --git a/.prettierrc.js b/.prettierrc.js index cc7e3b513..9e0d1ed1e 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -2,6 +2,8 @@ module.exports = { printWidth: 80, useTabs: true, tabWidth: 2, + trailingComma: "none", + arrowParens: "avoid", overrides: [ { files: "*.json", diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js index 7df5f9707..7e246b072 100644 --- a/benchmark/benchmark.js +++ b/benchmark/benchmark.js @@ -7,7 +7,7 @@ const outputPath = path.join(__dirname, "js"); const benchmarkOptions = { defer: true, - onCycle: function() { + onCycle: function () { process.stderr.write("."); }, minSamples: 10 diff --git a/hot/dev-server.js b/hot/dev-server.js index 2e440d5fb..a93ab3700 100644 --- a/hot/dev-server.js +++ b/hot/dev-server.js @@ -12,7 +12,7 @@ if (module.hot) { var check = function check() { module.hot .check(true) - .then(function(updatedModules) { + .then(function (updatedModules) { if (!updatedModules) { log("warning", "[HMR] Cannot find update. Need to do a full reload!"); log( @@ -33,7 +33,7 @@ if (module.hot) { log("info", "[HMR] App is up to date."); } }) - .catch(function(err) { + .catch(function (err) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log( @@ -48,7 +48,7 @@ if (module.hot) { }); }; var hotEmitter = require("./emitter"); - hotEmitter.on("webpackHotUpdate", function(currentHash) { + hotEmitter.on("webpackHotUpdate", function (currentHash) { lastHash = currentHash; if (!upToDate() && module.hot.status() === "idle") { log("info", "[HMR] Checking for updates on the server..."); diff --git a/hot/log-apply-result.js b/hot/log-apply-result.js index aa6ee60c1..d4452f930 100644 --- a/hot/log-apply-result.js +++ b/hot/log-apply-result.js @@ -2,8 +2,8 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -module.exports = function(updatedModules, renewedModules) { - var unacceptedModules = updatedModules.filter(function(moduleId) { +module.exports = function (updatedModules, renewedModules) { + var unacceptedModules = updatedModules.filter(function (moduleId) { return renewedModules && renewedModules.indexOf(moduleId) < 0; }); var log = require("./log"); @@ -13,7 +13,7 @@ module.exports = function(updatedModules, renewedModules) { "warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)" ); - unacceptedModules.forEach(function(moduleId) { + unacceptedModules.forEach(function (moduleId) { log("warning", "[HMR] - " + moduleId); }); } @@ -22,7 +22,7 @@ module.exports = function(updatedModules, renewedModules) { log("info", "[HMR] Nothing hot updated."); } else { log("info", "[HMR] Updated modules:"); - renewedModules.forEach(function(moduleId) { + renewedModules.forEach(function (moduleId) { if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) { var parts = moduleId.split("!"); log.groupCollapsed("info", "[HMR] - " + parts.pop()); @@ -32,7 +32,7 @@ module.exports = function(updatedModules, renewedModules) { log("info", "[HMR] - " + moduleId); } }); - var numberIds = renewedModules.every(function(moduleId) { + var numberIds = renewedModules.every(function (moduleId) { return typeof moduleId === "number"; }); if (numberIds) diff --git a/hot/log.js b/hot/log.js index 32a1c69b1..483ab4080 100644 --- a/hot/log.js +++ b/hot/log.js @@ -11,14 +11,14 @@ function shouldLog(level) { } function logGroup(logFn) { - return function(level, msg) { + return function (level, msg) { if (shouldLog(level)) { logFn(msg); } }; } -module.exports = function(level, msg) { +module.exports = function (level, msg) { if (shouldLog(level)) { if (level === "info") { console.log(msg); @@ -42,11 +42,11 @@ module.exports.groupCollapsed = logGroup(groupCollapsed); module.exports.groupEnd = logGroup(groupEnd); -module.exports.setLogLevel = function(level) { +module.exports.setLogLevel = function (level) { logLevel = level; }; -module.exports.formatError = function(err) { +module.exports.formatError = function (err) { var message = err.message; var stack = err.stack; if (!stack) { diff --git a/hot/only-dev-server.js b/hot/only-dev-server.js index 12df4687e..7312beb82 100644 --- a/hot/only-dev-server.js +++ b/hot/only-dev-server.js @@ -12,7 +12,7 @@ if (module.hot) { var check = function check() { module.hot .check() - .then(function(updatedModules) { + .then(function (updatedModules) { if (!updatedModules) { log("warning", "[HMR] Cannot find update. Need to do a full reload!"); log( @@ -27,21 +27,21 @@ if (module.hot) { ignoreUnaccepted: true, ignoreDeclined: true, ignoreErrored: true, - onUnaccepted: function(data) { + onUnaccepted: function (data) { log( "warning", "Ignored an update to unaccepted module " + data.chain.join(" -> ") ); }, - onDeclined: function(data) { + onDeclined: function (data) { log( "warning", "Ignored an update to declined module " + data.chain.join(" -> ") ); }, - onErrored: function(data) { + onErrored: function (data) { log("error", data.error); log( "warning", @@ -53,7 +53,7 @@ if (module.hot) { ); } }) - .then(function(renewedModules) { + .then(function (renewedModules) { if (!upToDate()) { check(); } @@ -65,7 +65,7 @@ if (module.hot) { } }); }) - .catch(function(err) { + .catch(function (err) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log( @@ -79,7 +79,7 @@ if (module.hot) { }); }; var hotEmitter = require("./emitter"); - hotEmitter.on("webpackHotUpdate", function(currentHash) { + hotEmitter.on("webpackHotUpdate", function (currentHash) { lastHash = currentHash; if (!upToDate()) { var status = module.hot.status(); diff --git a/hot/poll.js b/hot/poll.js index 81d33e7c7..dab215a42 100644 --- a/hot/poll.js +++ b/hot/poll.js @@ -11,7 +11,7 @@ if (module.hot) { if (module.hot.status() === "idle") { module.hot .check(true) - .then(function(updatedModules) { + .then(function (updatedModules) { if (!updatedModules) { if (fromUpdate) log("info", "[HMR] Update applied."); return; @@ -19,7 +19,7 @@ if (module.hot) { require("./log-apply-result")(updatedModules, updatedModules); checkForUpdate(true); }) - .catch(function(err) { + .catch(function (err) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log("warning", "[HMR] Cannot apply update."); diff --git a/hot/signal.js b/hot/signal.js index 63bfdd650..ef949521f 100644 --- a/hot/signal.js +++ b/hot/signal.js @@ -8,7 +8,7 @@ if (module.hot) { var checkForUpdate = function checkForUpdate(fromUpdate) { module.hot .check() - .then(function(updatedModules) { + .then(function (updatedModules) { if (!updatedModules) { if (fromUpdate) log("info", "[HMR] Update applied."); else log("warning", "[HMR] Cannot find update."); @@ -18,7 +18,7 @@ if (module.hot) { return module.hot .apply({ ignoreUnaccepted: true, - onUnaccepted: function(data) { + onUnaccepted: function (data) { log( "warning", "Ignored an update to unaccepted module " + @@ -26,14 +26,14 @@ if (module.hot) { ); } }) - .then(function(renewedModules) { + .then(function (renewedModules) { require("./log-apply-result")(updatedModules, renewedModules); checkForUpdate(true); return null; }); }) - .catch(function(err) { + .catch(function (err) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log("warning", "[HMR] Cannot apply update."); @@ -45,7 +45,7 @@ if (module.hot) { }); }; - process.on(__resourceQuery.substr(1) || "SIGUSR2", function() { + process.on(__resourceQuery.substr(1) || "SIGUSR2", function () { if (module.hot.status() !== "idle") { log( "warning", diff --git a/lib/ChunkTemplate.js b/lib/ChunkTemplate.js index 420ce44e3..5a1cda849 100644 --- a/lib/ChunkTemplate.js +++ b/lib/ChunkTemplate.js @@ -126,7 +126,7 @@ Object.defineProperty(ChunkTemplate.prototype, "outputOptions", { * @this {ChunkTemplate} * @returns {TODO} output options */ - function() { + function () { return this._outputOptions; }, "ChunkTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)", diff --git a/lib/ContextModule.js b/lib/ContextModule.js index 151ba13f6..75129c676 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -104,7 +104,7 @@ class ContextModule extends Module { // Info from Factory this.resolveDependencies = resolveDependencies; /** @type {ContextModuleOptions} */ - this.options = ({ + this.options = { resource: resource, resourceQuery: resourceQuery, mode: options.mode, @@ -116,7 +116,7 @@ class ContextModule extends Module { chunkName: options.chunkName, groupOptions: options.groupOptions, namespaceObject: options.namespaceObject - }); + }; if (options.resolveOptions !== undefined) { this.resolveOptions = options.resolveOptions; } diff --git a/lib/EvalSourceMapDevToolPlugin.js b/lib/EvalSourceMapDevToolPlugin.js index dc6a74edd..09fb5cda8 100644 --- a/lib/EvalSourceMapDevToolPlugin.js +++ b/lib/EvalSourceMapDevToolPlugin.js @@ -79,8 +79,7 @@ class EvalSourceMapDevToolPlugin { } else if (m instanceof ConcatenatedModule) { const concatModule = /** @type {ConcatenatedModule} */ (m); if (concatModule.rootModule instanceof NormalModule) { - const module = - /** @type {NormalModule} */ (concatModule.rootModule); + const module = /** @type {NormalModule} */ (concatModule.rootModule); if (!matchModule(module.resource)) { return source; } diff --git a/lib/MainTemplate.js b/lib/MainTemplate.js index ad0fd5046..5fbd07119 100644 --- a/lib/MainTemplate.js +++ b/lib/MainTemplate.js @@ -298,7 +298,7 @@ Object.defineProperty(MainTemplate.prototype, "outputOptions", { * @this {MainTemplate} * @returns {TODO} output options */ - function() { + function () { return this._outputOptions; }, "MainTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)", diff --git a/lib/Module.js b/lib/Module.js index 28a319c14..c12ec4b03 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -703,11 +703,7 @@ class Module extends DependenciesBlock { const sources = this.codeGeneration(sourceContext).sources; return sourceContext.type ? sources.get(sourceContext.type) - : sources.get( - this.getSourceTypes() - .values() - .next().value - ); + : sources.get(this.getSourceTypes().values().next().value); } /** @@ -868,7 +864,7 @@ Object.defineProperty(Module.prototype, "errors", { * @this {Module} * @returns {WebpackError[]} array */ - function() { + function () { if (this._errors === undefined) { this._errors = []; } @@ -886,7 +882,7 @@ Object.defineProperty(Module.prototype, "warnings", { * @this {Module} * @returns {WebpackError[]} array */ - function() { + function () { if (this._warnings === undefined) { this._warnings = []; } diff --git a/lib/ModuleDependencyError.js b/lib/ModuleDependencyError.js index b3c8e1114..dfa2cdbfd 100644 --- a/lib/ModuleDependencyError.js +++ b/lib/ModuleDependencyError.js @@ -20,10 +20,7 @@ class ModuleDependencyError extends WebpackError { super(err.message); this.name = "ModuleDependencyError"; - this.details = err.stack - .split("\n") - .slice(1) - .join("\n"); + this.details = err.stack.split("\n").slice(1).join("\n"); this.module = module; this.loc = loc; this.error = err; diff --git a/lib/ModuleDependencyWarning.js b/lib/ModuleDependencyWarning.js index 11b23f22d..4f57d9856 100644 --- a/lib/ModuleDependencyWarning.js +++ b/lib/ModuleDependencyWarning.js @@ -19,10 +19,7 @@ module.exports = class ModuleDependencyWarning extends WebpackError { super(err.message); this.name = "ModuleDependencyWarning"; - this.details = err.stack - .split("\n") - .slice(1) - .join("\n"); + this.details = err.stack.split("\n").slice(1).join("\n"); this.module = module; this.loc = loc; this.error = err; diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 0aade3b30..c3230602b 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -88,10 +88,7 @@ ModuleFilenameHelpers.createFilename = ( shortIdentifier = module.readableIdentifier(requestShortener); identifier = requestShortener.shorten(module.identifier()); moduleId = chunkGraph.getModuleId(module); - absoluteResourcePath = module - .identifier() - .split("!") - .pop(); + absoluteResourcePath = module.identifier().split("!").pop(); hash = getHash(identifier); } const resource = shortIdentifier.split("!").pop(); diff --git a/lib/ModuleTemplate.js b/lib/ModuleTemplate.js index b10bb6434..a6791e408 100644 --- a/lib/ModuleTemplate.js +++ b/lib/ModuleTemplate.js @@ -140,7 +140,7 @@ Object.defineProperty(ModuleTemplate.prototype, "runtimeTemplate", { * @this {ModuleTemplate} * @returns {TODO} output options */ - function() { + function () { return this._runtimeTemplate; }, "ModuleTemplate.runtimeTemplate is deprecated (use Compilation.runtimeTemplate instead)", diff --git a/lib/config/normalization.js b/lib/config/normalization.js index f10f0a360..57fff15a3 100644 --- a/lib/config/normalization.js +++ b/lib/config/normalization.js @@ -117,9 +117,7 @@ const getNormalizedWebpackOptions = config => { entry: nestedConfig(config.entry, entry => { if (typeof entry === "function") { return () => - Promise.resolve() - .then(entry) - .then(getNormalizedEntryStatic); + Promise.resolve().then(entry).then(getNormalizedEntryStatic); } return getNormalizedEntryStatic(entry); }), diff --git a/lib/hmr/HotModuleReplacement.runtime.js b/lib/hmr/HotModuleReplacement.runtime.js index a66c8173b..bee7650b7 100644 --- a/lib/hmr/HotModuleReplacement.runtime.js +++ b/lib/hmr/HotModuleReplacement.runtime.js @@ -14,7 +14,7 @@ var $hmrDownloadManifest$ = undefined; var $hmrDownloadUpdateHandlers$ = undefined; var __webpack_require__ = undefined; -module.exports = function() { +module.exports = function () { var currentHash = $getFullHash$(); var currentModuleData = {}; var installedModules = $moduleCache$; @@ -36,11 +36,11 @@ module.exports = function() { $hmrModuleData$ = currentModuleData; - $getFullHash$ = function() { + $getFullHash$ = function () { return currentHash; }; - $interceptModuleExecution$.push(function(options) { + $interceptModuleExecution$.push(function (options) { var module = options.module; var require = createRequire(options.require, options.id); module.hot = createModuleHotObject(options.id, module); @@ -55,7 +55,7 @@ module.exports = function() { function createRequire(require, moduleId) { var me = installedModules[moduleId]; if (!me) return require; - var fn = function(request) { + var fn = function (request) { if (me.hot.active) { if (installedModules[request]) { var parents = installedModules[request].parents; @@ -80,14 +80,14 @@ module.exports = function() { } return require(request); }; - var createPropertyDescriptor = function(name) { + var createPropertyDescriptor = function (name) { return { configurable: true, enumerable: true, - get: function() { + get: function () { return require[name]; }, - set: function(value) { + set: function (value) { require[name] = value; } }; @@ -97,7 +97,7 @@ module.exports = function() { Object.defineProperty(fn, name, createPropertyDescriptor(name)); } } - fn.e = function(chunkId) { + fn.e = function (chunkId) { return trackBlockingPromise(require.e(chunkId)); }; return fn; @@ -112,7 +112,7 @@ module.exports = function() { _selfDeclined: false, _disposeHandlers: [], _main: currentChildModule !== moduleId, - _requireSelf: function() { + _requireSelf: function () { currentParents = me.parents.slice(); currentChildModule = moduleId; __webpack_require__(moduleId); @@ -120,28 +120,28 @@ module.exports = function() { // Module API active: true, - accept: function(dep, callback) { + accept: function (dep, callback) { if (dep === undefined) hot._selfAccepted = true; else if (typeof dep === "function") hot._selfAccepted = dep; else if (typeof dep === "object" && dep !== null) for (var i = 0; i < dep.length; i++) - hot._acceptedDependencies[dep[i]] = callback || function() {}; - else hot._acceptedDependencies[dep] = callback || function() {}; + hot._acceptedDependencies[dep[i]] = callback || function () {}; + else hot._acceptedDependencies[dep] = callback || function () {}; }, - decline: function(dep) { + decline: function (dep) { if (dep === undefined) hot._selfDeclined = true; else if (typeof dep === "object" && dep !== null) for (var i = 0; i < dep.length; i++) hot._declinedDependencies[dep[i]] = true; else hot._declinedDependencies[dep] = true; }, - dispose: function(callback) { + dispose: function (callback) { hot._disposeHandlers.push(callback); }, - addDisposeHandler: function(callback) { + addDisposeHandler: function (callback) { hot._disposeHandlers.push(callback); }, - removeDisposeHandler: function(callback) { + removeDisposeHandler: function (callback) { var idx = hot._disposeHandlers.indexOf(callback); if (idx >= 0) hot._disposeHandlers.splice(idx, 1); }, @@ -149,14 +149,14 @@ module.exports = function() { // Management API check: hotCheck, apply: hotApply, - status: function(l) { + status: function (l) { if (!l) return currentStatus; registeredStatusHandlers.push(l); }, - addStatusHandler: function(l) { + addStatusHandler: function (l) { registeredStatusHandlers.push(l); }, - removeStatusHandler: function(l) { + removeStatusHandler: function (l) { var idx = registeredStatusHandlers.indexOf(l); if (idx >= 0) registeredStatusHandlers.splice(idx, 1); }, @@ -179,7 +179,7 @@ module.exports = function() { case "ready": setStatus("prepare"); blockingPromises.push(promise); - waitForBlockingPromises(function() { + waitForBlockingPromises(function () { setStatus("ready"); }); return promise; @@ -195,7 +195,7 @@ module.exports = function() { if (blockingPromises.length === 0) return fn(); var blocker = blockingPromises; blockingPromises = []; - return Promise.all(blocker).then(function() { + return Promise.all(blocker).then(function () { return waitForBlockingPromises(fn); }); } @@ -205,7 +205,7 @@ module.exports = function() { throw new Error("check() is only allowed in idle status"); } setStatus("check"); - return $hmrDownloadManifest$().then(function(update) { + return $hmrDownloadManifest$().then(function (update) { if (!update) { setStatus("idle"); return null; @@ -219,7 +219,7 @@ module.exports = function() { currentUpdateApplyHandlers = []; return Promise.all( - Object.keys($hmrDownloadUpdateHandlers$).reduce(function( + Object.keys($hmrDownloadUpdateHandlers$).reduce(function ( promises, key ) { @@ -234,8 +234,8 @@ module.exports = function() { return promises; }, []) - ).then(function() { - return waitForBlockingPromises(function() { + ).then(function () { + return waitForBlockingPromises(function () { if (applyOnUpdate) { return internalApply(applyOnUpdate); } else { @@ -250,7 +250,7 @@ module.exports = function() { function hotApply(options) { if (currentStatus !== "ready") { - return Promise.resolve().then(function() { + return Promise.resolve().then(function () { throw new Error("apply() is only allowed in ready status"); }); } @@ -260,19 +260,19 @@ module.exports = function() { function internalApply(options) { options = options || {}; - var results = currentUpdateApplyHandlers.map(function(handler) { + var results = currentUpdateApplyHandlers.map(function (handler) { return handler(options); }); var errors = results - .map(function(r) { + .map(function (r) { return r.error; }) .filter(Boolean); if (errors.length > 0) { setStatus("abort"); - return Promise.resolve().then(function() { + return Promise.resolve().then(function () { throw errors[0]; }); } @@ -280,7 +280,7 @@ module.exports = function() { // Now in "dispose" phase setStatus("dispose"); - results.forEach(function(result) { + results.forEach(function (result) { if (result.dispose) result.dispose(); }); @@ -290,12 +290,12 @@ module.exports = function() { currentHash = currentUpdateNewHash; var error; - var reportError = function(err) { + var reportError = function (err) { if (!error) error = err; }; var outdatedModules = []; - results.forEach(function(result) { + results.forEach(function (result) { if (result.apply) { var modules = result.apply(reportError); if (modules) { @@ -309,7 +309,7 @@ module.exports = function() { // handle errors in accept handlers and self accepted module load if (error) { setStatus("fail"); - return Promise.resolve().then(function() { + return Promise.resolve().then(function () { throw error; }); } diff --git a/lib/hmr/JavascriptHotModuleReplacement.runtime.js b/lib/hmr/JavascriptHotModuleReplacement.runtime.js index af1cd5aa6..42a0fdaa9 100644 --- a/lib/hmr/JavascriptHotModuleReplacement.runtime.js +++ b/lib/hmr/JavascriptHotModuleReplacement.runtime.js @@ -13,12 +13,12 @@ var $moduleFactories$ = undefined; var $hmrModuleData$ = undefined; var __webpack_require__ = undefined; -module.exports = function() { +module.exports = function () { function getAffectedModuleEffects(updateModuleId) { var outdatedModules = [updateModuleId]; var outdatedDependencies = {}; - var queue = outdatedModules.map(function(id) { + var queue = outdatedModules.map(function (id) { return { chain: [id], id: id @@ -211,7 +211,7 @@ module.exports = function() { var moduleOutdatedDependencies; return { - dispose: function() { + dispose: function () { // $dispose$ var idx; @@ -271,7 +271,7 @@ module.exports = function() { } } }, - apply: function(reportError) { + apply: function (reportError) { // insert new code for (var updateModuleId in appliedUpdate) { if ( diff --git a/lib/javascript/JavascriptGenerator.js b/lib/javascript/JavascriptGenerator.js index efaa50b27..413b7c622 100644 --- a/lib/javascript/JavascriptGenerator.js +++ b/lib/javascript/JavascriptGenerator.js @@ -152,8 +152,7 @@ class JavascriptGenerator extends Generator { * @returns {void} */ sourceDependency(module, dependency, initFragments, source, generateContext) { - const constructor = - /** @type {new (...args: any[]) => Dependency} */ (dependency.constructor); + const constructor = /** @type {new (...args: any[]) => Dependency} */ (dependency.constructor); const template = generateContext.dependencyTemplates.get(constructor); if (!template) { throw new Error( diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index fdb29a183..7cdd6eb3d 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -907,9 +907,8 @@ class ConcatenatedModule extends Module { }) .map(connection => ({ connection, - sourceOrder: - /** @type {HarmonyImportDependency} */ (connection.dependency) - .sourceOrder + sourceOrder: /** @type {HarmonyImportDependency} */ (connection.dependency) + .sourceOrder })); references.sort( concatComparators(bySourceOrder, keepOriginalOrder(references)) diff --git a/lib/optimize/InnerGraphPlugin.js b/lib/optimize/InnerGraphPlugin.js index d06ef16af..23b9d2908 100644 --- a/lib/optimize/InnerGraphPlugin.js +++ b/lib/optimize/InnerGraphPlugin.js @@ -234,8 +234,7 @@ class InnerGraphPlugin { parser.hooks.expression .for(topLevelSymbolTag) .tap("InnerGraphPlugin", () => { - const topLevelSymbol = - /** @type {TopLevelSymbol} */ (parser.currentTagData); + const topLevelSymbol = /** @type {TopLevelSymbol} */ (parser.currentTagData); const currentTopLevelSymbol = InnerGraph.getTopLevelSymbol( parser.state ); diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index bafcd3a97..21b3adf64 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -185,15 +185,16 @@ class ModuleConcatenationPlugin { ); const importingModuleTypes = new Map( Array.from(importingModules).map( - m => /** @type {[Module, Set]} */ ([ - m, - new Set( - nonHarmonyConnections - .filter(c => c.originModule === m) - .map(c => c.dependency.type) - .sort() - ) - ]) + m => + /** @type {[Module, Set]} */ ([ + m, + new Set( + nonHarmonyConnections + .filter(c => c.originModule === m) + .map(c => c.dependency.type) + .sort() + ) + ]) ) ); const names = Array.from(importingModules) diff --git a/lib/optimize/SplitChunksPlugin.js b/lib/optimize/SplitChunksPlugin.js index 3b9174254..b5fb0e0dd 100644 --- a/lib/optimize/SplitChunksPlugin.js +++ b/lib/optimize/SplitChunksPlugin.js @@ -1213,8 +1213,9 @@ module.exports = class SplitChunksPlugin { minSizeValue > maxSizeValue ) { const keys = chunkConfig && chunkConfig.keys; - const warningKey = `${keys && - keys.join()} ${minSizeValue} ${maxSizeValue}`; + const warningKey = `${ + keys && keys.join() + } ${minSizeValue} ${maxSizeValue}`; if (!incorrectMinMaxSizeSet.has(warningKey)) { incorrectMinMaxSizeSet.add(warningKey); compilation.warnings.push( diff --git a/lib/stats/DefaultStatsFactoryPlugin.js b/lib/stats/DefaultStatsFactoryPlugin.js index 9d6e7698e..2898561b3 100644 --- a/lib/stats/DefaultStatsFactoryPlugin.js +++ b/lib/stats/DefaultStatsFactoryPlugin.js @@ -435,8 +435,9 @@ const SIMPLE_EXTRACTORS = { } let message = undefined; if (entry.type === LogType.time) { - message = `${entry.args[0]}: ${entry.args[1] * 1000 + - entry.args[2] / 1000000}ms`; + message = `${entry.args[0]}: ${ + entry.args[1] * 1000 + entry.args[2] / 1000000 + }ms`; } else if (entry.args && entry.args.length > 0) { message = util.format(entry.args[0], ...entry.args.slice(1)); } @@ -500,22 +501,22 @@ const SIMPLE_EXTRACTORS = { compilationAuxiliaryFileToChunks.get(asset.name) || []; object.chunkNames = uniqueOrderedArray( chunks, - c => ((c.name ? [c.name] : [])), + c => (c.name ? [c.name] : []), compareIds ); object.chunkIdHints = uniqueOrderedArray( chunks, - c => (Array.from(c.idNameHints)), + c => Array.from(c.idNameHints), compareIds ); object.auxiliaryChunkNames = uniqueOrderedArray( auxiliaryChunks, - c => ((c.name ? [c.name] : [])), + c => (c.name ? [c.name] : []), compareIds ); object.auxiliaryChunkIdHints = uniqueOrderedArray( auxiliaryChunks, - c => (Array.from(c.idNameHints)), + c => Array.from(c.idNameHints), compareIds ); object.emitted = compilation.emittedAssets.has(asset.name); @@ -986,25 +987,25 @@ const FILTER = { } } }, - "compilation.modules": ({ + "compilation.modules": { excludeModules: EXCLUDE_MODULES_FILTER("module"), "!orphanModules": (module, { compilation: { chunkGraph } }) => { if (chunkGraph.getNumberOfModuleChunks(module) === 0) return false; }, ...BASE_MODULES_FILTER - }), - "module.modules": ({ + }, + "module.modules": { excludeModules: EXCLUDE_MODULES_FILTER("nested"), ...BASE_MODULES_FILTER - }), - "chunk.modules": ({ + }, + "chunk.modules": { excludeModules: EXCLUDE_MODULES_FILTER("chunk"), ...BASE_MODULES_FILTER - }), - "chunk.rootModules": ({ + }, + "chunk.rootModules": { excludeModules: EXCLUDE_MODULES_FILTER("root-of-chunk"), ...BASE_MODULES_FILTER - }) + } }; /** @type {Record boolean | undefined>} */ diff --git a/lib/stats/DefaultStatsPresetPlugin.js b/lib/stats/DefaultStatsPresetPlugin.js index 7fb8152ae..858aa8fd7 100644 --- a/lib/stats/DefaultStatsPresetPlugin.js +++ b/lib/stats/DefaultStatsPresetPlugin.js @@ -152,12 +152,12 @@ const DEFAULTS = { warnings: NORMAL_ON, publicPath: OFF_FOR_TO_STRING, logging: ({ all }, { forToString }) => - (forToString && all !== false ? "info" : false), + forToString && all !== false ? "info" : false, loggingDebug: () => [], loggingTrace: OFF_FOR_TO_STRING, excludeModules: () => [], excludeAssets: () => [], - maxModules: (o, { forToString }) => ((forToString ? 15 : Infinity)), + maxModules: (o, { forToString }) => (forToString ? 15 : Infinity), modulesSort: () => "depth", chunkModulesSort: () => "name", chunkRootModulesSort: () => "name", diff --git a/lib/stats/DefaultStatsPrinterPlugin.js b/lib/stats/DefaultStatsPrinterPlugin.js index efb187cf7..a0691b30d 100644 --- a/lib/stats/DefaultStatsPrinterPlugin.js +++ b/lib/stats/DefaultStatsPrinterPlugin.js @@ -43,11 +43,7 @@ const printSizes = (sizes, { formatSize }) => { } }; -const mapLines = (str, fn) => - str - .split("\n") - .map(fn) - .join("\n"); +const mapLines = (str, fn) => str.split("\n").map(fn).join("\n"); /** * @param {number} n a number @@ -84,10 +80,10 @@ const SIMPLE_PRINTERS = { "compilation.entrypoints": (entrypoints, context, printer) => Array.isArray(entrypoints) ? undefined - : printer.print(context.type, Object.values(entrypoints), ({ + : printer.print(context.type, Object.values(entrypoints), { ...context, chunkGroupKind: "Entrypoint" - })), + }), "compilation.namedChunkGroups": (namedChunkGroups, context, printer) => { if (!Array.isArray(namedChunkGroups)) { const { @@ -100,10 +96,10 @@ const SIMPLE_PRINTERS = { !Object.prototype.hasOwnProperty.call(entrypoints, group.name) ); } - return printer.print(context.type, chunkGroups, ({ + return printer.print(context.type, chunkGroups, { ...context, chunkGroupKind: "Chunk Group" - })); + }); } }, "compilation.assetsByChunkName": () => "", @@ -152,7 +148,7 @@ const SIMPLE_PRINTERS = { "asset.size": ( size, { asset: { isOverSizeLimit }, yellow, green, formatSize } - ) => ((isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size))), + ) => (isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size)), "asset.emitted": (emitted, { green, formatFlag }) => emitted ? green(formatFlag("emitted")) : undefined, "asset.comparedForEmit": (comparedForEmit, { yellow, formatFlag }) => @@ -167,7 +163,7 @@ const SIMPLE_PRINTERS = { "asset.info.hotModuleReplacement": ( hotModuleReplacement, { green, formatFlag } - ) => ((hotModuleReplacement ? green(formatFlag("hmr")) : undefined)), + ) => (hotModuleReplacement ? green(formatFlag("hmr")) : undefined), assetChunk: (id, { formatChunkId }) => formatChunkId(id), @@ -350,8 +346,7 @@ const SIMPLE_PRINTERS = { rendered ? green(formatFlag("rendered")) : undefined, "chunk.recorded": (recorded, { formatFlag, green }) => recorded ? green(formatFlag("recorded")) : undefined, - "chunk.reason": (reason, { yellow }) => - (reason ? yellow(reason) : undefined), + "chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined), "chunk.rootModules": (modules, context) => { let maxModuleId = 0; for (const module of modules) { @@ -462,7 +457,7 @@ const SIMPLE_PRINTERS = { loggingGroup: loggingGroup => loggingGroup.entries.length === 0 ? "" : undefined, - "loggingGroup.debug": (flag, { red }) => ((flag ? red("DEBUG") : undefined)), + "loggingGroup.debug": (flag, { red }) => (flag ? red("DEBUG") : undefined), "loggingGroup.name": (name, { bold }) => bold(`LOG from ${name}`), "loggingGroup.separator!": () => "\n", "loggingGroup.filteredEntries": filteredEntries => @@ -830,7 +825,7 @@ const SIMPLE_ELEMENT_JOINERS = { if (maxModuleId >= 10) prefix += " "; } return ( - (prefix + + prefix + joinExplicitNewLine( items.filter(item => { switch (item.element) { @@ -846,13 +841,13 @@ const SIMPLE_ELEMENT_JOINERS = { return true; }), indenter - )) + ) ); }, chunk: items => { let hasEntry = false; return ( - ("chunk " + + "chunk " + joinExplicitNewLine( items.filter(item => { switch (item.element) { @@ -866,7 +861,7 @@ const SIMPLE_ELEMENT_JOINERS = { return true; }), " " - )) + ) ); }, "chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`, @@ -886,8 +881,8 @@ const SIMPLE_ELEMENT_JOINERS = { break; case "resolvedModule": return ( - (moduleReason.module !== moduleReason.resolvedModule && - item.content) + moduleReason.module !== moduleReason.resolvedModule && + item.content ); } return true; diff --git a/lib/util/deprecation.js b/lib/util/deprecation.js index 55aa884c7..4b1e6a6ca 100644 --- a/lib/util/deprecation.js +++ b/lib/util/deprecation.js @@ -74,7 +74,7 @@ exports.arrayToSetDeprecation = (set, name) => { * @this {Set} * @returns {number} count */ - set[method] = function() { + set[method] = function () { d(); const array = Array.from(this); return Array.prototype[method].apply(array, arguments); @@ -97,7 +97,7 @@ exports.arrayToSetDeprecation = (set, name) => { * @this {Set} * @returns {number} count */ - set.push = function() { + set.push = function () { dPush(); for (const item of Array.from(arguments)) { this.add(item); @@ -117,7 +117,7 @@ exports.arrayToSetDeprecation = (set, name) => { * @this {Set} a Set * @returns {any} the value at this location */ - const fn = function() { + const fn = function () { dIndexer(); let i = 0; for (const item of this) { diff --git a/lib/validateSchema.js b/lib/validateSchema.js index a6b168cc1..af3a2d4d6 100644 --- a/lib/validateSchema.js +++ b/lib/validateSchema.js @@ -64,8 +64,7 @@ const validateSchema = (schema, options) => { } if (error.keyword === "additionalProperties") { - const params = - /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params); + const params = /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params); if ( Object.prototype.hasOwnProperty.call( DID_YOU_MEAN, diff --git a/package.json b/package.json index f85448075..a5e278120 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "mini-css-extract-plugin": "^0.8.0", "mini-svg-data-uri": "^1.1.3", "open-cli": "^5.0.0", - "prettier": "^1.14.3", + "prettier": "2", "pretty-format": "^25.1.0", "pug": "^2.0.4", "pug-loader": "^2.4.0", diff --git a/setup/setup.js b/setup/setup.js index 3e214fb72..a3952230c 100644 --- a/setup/setup.js +++ b/setup/setup.js @@ -96,11 +96,7 @@ function execGetOutput(command, args, description) { if (exitCode) { reject(`${description} failed with exit code ${exitCode}`); } else { - resolve( - Buffer.concat(buffers) - .toString("utf-8") - .trim() - ); + resolve(Buffer.concat(buffers).toString("utf-8").trim()); } }); const buffers = []; diff --git a/test/BenchmarkTestCases.benchmark.js b/test/BenchmarkTestCases.benchmark.js index 4ee36a3aa..69a9f3225 100644 --- a/test/BenchmarkTestCases.benchmark.js +++ b/test/BenchmarkTestCases.benchmark.js @@ -6,9 +6,9 @@ const asyncLib = require("neo-async"); const Benchmark = require("benchmark"); const { remove } = require("./helpers/remove"); -describe("BenchmarkTestCases", function() { +describe("BenchmarkTestCases", function () { const casesPath = path.join(__dirname, "benchmarkCases"); - const tests = fs.readdirSync(casesPath).filter(function(folder) { + const tests = fs.readdirSync(casesPath).filter(function (folder) { return ( folder.indexOf("_") < 0 && fs.existsSync(path.resolve(casesPath, folder, "webpack.config.js")) @@ -25,7 +25,7 @@ describe("BenchmarkTestCases", function() { fs.mkdirSync(baselinesPath); } catch (e) {} // eslint-disable-line no-empty - beforeAll(function(done) { + beforeAll(function (done) { const git = require("simple-git"); const rootPath = path.join(__dirname, ".."); getBaselineRevs(rootPath, (err, baselineRevisions) => { @@ -231,7 +231,7 @@ describe("BenchmarkTestCases", function() { const warmupCompiler = webpack(config, (err, stats) => { warmupCompiler.purgeInputFileSystem(); const bench = new Benchmark( - function(deferred) { + function (deferred) { const compiler = webpack(config, (err, stats) => { compiler.purgeInputFileSystem(); if (err) { @@ -249,7 +249,7 @@ describe("BenchmarkTestCases", function() { maxTime: 30, defer: true, initCount: 1, - onComplete: function() { + onComplete: function () { const stats = bench.stats; const n = stats.sample.length; const nSqrt = Math.sqrt(n); @@ -276,10 +276,10 @@ describe("BenchmarkTestCases", function() { tests.forEach(testName => { const testDirectory = path.join(casesPath, testName); let headStats = null; - describe(`${testName} create benchmarks`, function() { + describe(`${testName} create benchmarks`, function () { baselines.forEach(baseline => { let baselineStats = null; - it(`should benchmark ${baseline.name} (${baseline.rev})`, function(done) { + it(`should benchmark ${baseline.name} (${baseline.rev})`, function (done) { const outputDirectory = path.join( __dirname, "js", @@ -330,7 +330,7 @@ describe("BenchmarkTestCases", function() { }, 180000); if (baseline.name !== "HEAD") { - it(`HEAD should not be slower than ${baseline.name} (${baseline.rev})`, function() { + it(`HEAD should not be slower than ${baseline.name} (${baseline.rev})`, function () { if (baselineStats.maxConfidence < headStats.minConfidence) { throw new Error( `HEAD (${headStats.text}) is slower than ${baseline.name} (${baselineStats.text}) (90% confidence)` diff --git a/test/Compiler.test.js b/test/Compiler.test.js index 46d656dfb..0d535ab13 100644 --- a/test/Compiler.test.js +++ b/test/Compiler.test.js @@ -366,7 +366,7 @@ describe("Compiler", () => { done(); }); }); - it("should not be run twice at a time (run)", function(done) { + it("should not be run twice at a time (run)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -384,7 +384,7 @@ describe("Compiler", () => { if (err) return done(); }); }); - it("should not be run twice at a time (watch)", function(done) { + it("should not be run twice at a time (watch)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -402,7 +402,7 @@ describe("Compiler", () => { if (err) return done(); }); }); - it("should not be run twice at a time (run - watch)", function(done) { + it("should not be run twice at a time (run - watch)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -420,7 +420,7 @@ describe("Compiler", () => { if (err) return done(); }); }); - it("should not be run twice at a time (watch - run)", function(done) { + it("should not be run twice at a time (watch - run)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -438,7 +438,7 @@ describe("Compiler", () => { if (err) return done(); }); }); - it("should not be run twice at a time (instance cb)", function(done) { + it("should not be run twice at a time (instance cb)", function (done) { const compiler = webpack( { context: __dirname, @@ -456,7 +456,7 @@ describe("Compiler", () => { if (err) return done(); }); }); - it("should run again correctly after first compilation", function(done) { + it("should run again correctly after first compilation", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -476,7 +476,7 @@ describe("Compiler", () => { }); }); }); - it("should watch again correctly after first compilation", function(done) { + it("should watch again correctly after first compilation", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -496,7 +496,7 @@ describe("Compiler", () => { }); }); }); - it("should run again correctly after first closed watch", function(done) { + it("should run again correctly after first closed watch", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -517,7 +517,7 @@ describe("Compiler", () => { }); }); }); - it("should watch again correctly after first closed watch", function(done) { + it("should watch again correctly after first closed watch", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -538,7 +538,7 @@ describe("Compiler", () => { }); }); }); - it("should run again correctly inside afterDone hook", function(done) { + it("should run again correctly inside afterDone hook", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -562,7 +562,7 @@ describe("Compiler", () => { if (err) return done(err); }); }); - it("should call afterDone hook after other callbacks (run)", function(done) { + it("should call afterDone hook after other callbacks (run)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -586,7 +586,7 @@ describe("Compiler", () => { runCb(); }); }); - it("should call afterDone hook after other callbacks (instance cb)", function(done) { + it("should call afterDone hook after other callbacks (instance cb)", function (done) { const instanceCb = jest.fn(); const compiler = webpack( { @@ -612,7 +612,7 @@ describe("Compiler", () => { done(); }); }); - it("should call afterDone hook after other callbacks (watch)", function(done) { + it("should call afterDone hook after other callbacks (watch)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -639,7 +639,7 @@ describe("Compiler", () => { }); watch.invalidate(invalidateCb); }); - it("should call afterDone hook after other callbacks (watch close)", function(done) { + it("should call afterDone hook after other callbacks (watch close)", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -666,7 +666,7 @@ describe("Compiler", () => { }); watch.invalidate(invalidateCb); }); - it("should flag watchMode as true in watch", function(done) { + it("should flag watchMode as true in watch", function (done) { const compiler = webpack({ context: __dirname, mode: "production", @@ -688,7 +688,7 @@ describe("Compiler", () => { }); }); }); - it("should use cache on second run call", function(done) { + it("should use cache on second run call", function (done) { const compiler = webpack({ context: __dirname, mode: "development", diff --git a/test/ConfigTestCases.test.js b/test/ConfigTestCases.test.js index 02984a127..defb2b4fa 100644 --- a/test/ConfigTestCases.test.js +++ b/test/ConfigTestCases.test.js @@ -43,7 +43,7 @@ describe("ConfigTestCases", () => { categories.forEach(category => { describe(category.name, () => { category.tests.forEach(testName => { - describe(testName, function() { + describe(testName, function () { const testDirectory = path.join(casesPath, category.name, testName); const outputDirectory = path.join( __dirname, @@ -84,7 +84,7 @@ describe("ConfigTestCases", () => { options.output.filename = "bundle" + idx + ".js"; }); let testConfig = { - findBundle: function(i, options) { + findBundle: function (i, options) { const ext = path.extname(options.output.filename); if ( fs.existsSync( diff --git a/test/Examples.test.js b/test/Examples.test.js index 0aa44aa95..cf1cef7c7 100644 --- a/test/Examples.test.js +++ b/test/Examples.test.js @@ -18,7 +18,7 @@ describe("Examples", () => { } it( "should compile " + relativePath, - function(done) { + function (done) { let options = {}; let webpackConfigPath = path.join(examplePath, "webpack.config.js"); webpackConfigPath = diff --git a/test/JavascriptParser.unittest.js b/test/JavascriptParser.unittest.js index 6e0243ac1..88d4dec34 100644 --- a/test/JavascriptParser.unittest.js +++ b/test/JavascriptParser.unittest.js @@ -9,7 +9,7 @@ describe("JavascriptParser", () => { /* eslint-disable no-inner-declarations */ const testCases = { "call ident": [ - function() { + function () { abc("test"); }, { @@ -17,7 +17,7 @@ describe("JavascriptParser", () => { } ], "call member": [ - function() { + function () { cde.abc("membertest"); }, { @@ -25,7 +25,7 @@ describe("JavascriptParser", () => { } ], "call member using bracket notation": [ - function() { + function () { cde["abc"]("membertest"); }, { @@ -33,7 +33,7 @@ describe("JavascriptParser", () => { } ], "call inner member": [ - function() { + function () { cde.ddd.abc("inner"); }, { @@ -41,7 +41,7 @@ describe("JavascriptParser", () => { } ], "call inner member using bracket notation": [ - function() { + function () { cde.ddd["abc"]("inner"); }, { @@ -49,7 +49,7 @@ describe("JavascriptParser", () => { } ], expression: [ - function() { + function () { fgh; }, { @@ -57,7 +57,7 @@ describe("JavascriptParser", () => { } ], "expression sub": [ - function() { + function () { fgh.sub; }, { @@ -65,7 +65,7 @@ describe("JavascriptParser", () => { } ], "member expression": [ - function() { + function () { test[memberExpr]; test[+memberExpr]; }, @@ -74,8 +74,8 @@ describe("JavascriptParser", () => { } ], "in function definition": [ - function() { - (function(abc, cde, fgh) { + function () { + (function (abc, cde, fgh) { abc("test"); cde.abc("test"); cde.ddd.abc("test"); @@ -86,7 +86,7 @@ describe("JavascriptParser", () => { {} ], "const definition": [ - function() { + function () { let abc, cde, fgh; abc("test"); cde.abc("test"); @@ -97,7 +97,7 @@ describe("JavascriptParser", () => { {} ], "var definition": [ - function() { + function () { var abc, cde, fgh; abc("test"); cde.abc("test"); @@ -108,7 +108,7 @@ describe("JavascriptParser", () => { {} ], "function definition": [ - function() { + function () { function abc() {} function cde() {} @@ -123,7 +123,7 @@ describe("JavascriptParser", () => { {} ], "class definition": [ - function() { + function () { class memberExpr { cde() { abc("cde"); @@ -140,7 +140,7 @@ describe("JavascriptParser", () => { } ], "in try": [ - function() { + function () { try { fgh.sub; fgh; @@ -160,7 +160,7 @@ describe("JavascriptParser", () => { } ], "renaming with const": [ - function() { + function () { const xyz = abc; xyz("test"); }, @@ -169,7 +169,7 @@ describe("JavascriptParser", () => { } ], "renaming with var": [ - function() { + function () { var xyz = abc; xyz("test"); }, @@ -178,7 +178,7 @@ describe("JavascriptParser", () => { } ], "renaming with assignment": [ - function() { + function () { const xyz = abc; xyz("test"); }, @@ -187,8 +187,8 @@ describe("JavascriptParser", () => { } ], "renaming with IIFE": [ - function() { - !(function(xyz) { + function () { + !(function (xyz) { xyz("test"); })(abc); }, @@ -197,8 +197,8 @@ describe("JavascriptParser", () => { } ], "renaming arguments with IIFE (called)": [ - function() { - !function(xyz) { + function () { + !function (xyz) { xyz("test"); }.call(fgh, abc); }, @@ -208,8 +208,8 @@ describe("JavascriptParser", () => { } ], "renaming this's properties with IIFE (called)": [ - function() { - !function() { + function () { + !function () { this.sub; }.call(ijk); }, @@ -218,9 +218,9 @@ describe("JavascriptParser", () => { } ], "renaming this's properties with nested IIFE (called)": [ - function() { - !function() { - !function() { + function () { + !function () { + !function () { this.sub; }.call(this); }.call(ijk); @@ -230,7 +230,7 @@ describe("JavascriptParser", () => { } ], "new Foo(...)": [ - function() { + function () { new xyz("membertest"); }, { @@ -238,7 +238,7 @@ describe("JavascriptParser", () => { } ], "spread calls/literals": [ - function() { + function () { var xyz = [...abc("xyz"), cde]; Math.max(...fgh); }, diff --git a/test/MultiCompiler.test.js b/test/MultiCompiler.test.js index 0650bd29f..d55548134 100644 --- a/test/MultiCompiler.test.js +++ b/test/MultiCompiler.test.js @@ -19,7 +19,7 @@ const createMultiCompiler = () => { return compiler; }; -describe("MultiCompiler", function() { +describe("MultiCompiler", function () { jest.setTimeout(20000); it("should trigger 'run' for each child compiler", done => { @@ -53,7 +53,7 @@ describe("MultiCompiler", function() { }); }); - it("should not be run twice at a time (run)", function(done) { + it("should not be run twice at a time (run)", function (done) { const compiler = createMultiCompiler(); compiler.run((err, stats) => { if (err) return done(err); @@ -62,7 +62,7 @@ describe("MultiCompiler", function() { if (err) return done(); }); }); - it("should not be run twice at a time (watch)", function(done) { + it("should not be run twice at a time (watch)", function (done) { const compiler = createMultiCompiler(); const watcher = compiler.watch({}, (err, stats) => { if (err) return done(err); @@ -71,7 +71,7 @@ describe("MultiCompiler", function() { if (err) return watcher.close(done); }); }); - it("should not be run twice at a time (run - watch)", function(done) { + it("should not be run twice at a time (run - watch)", function (done) { const compiler = createMultiCompiler(); compiler.run((err, stats) => { if (err) return done(err); @@ -80,7 +80,7 @@ describe("MultiCompiler", function() { if (err) return done(); }); }); - it("should not be run twice at a time (watch - run)", function(done) { + it("should not be run twice at a time (watch - run)", function (done) { const compiler = createMultiCompiler(); let watcher; watcher = compiler.watch({}, (err, stats) => { @@ -90,7 +90,7 @@ describe("MultiCompiler", function() { if (err) return watcher.close(done); }); }); - it("should not be run twice at a time (instance cb)", function(done) { + it("should not be run twice at a time (instance cb)", function (done) { const compiler = webpack( { context: __dirname, @@ -108,7 +108,7 @@ describe("MultiCompiler", function() { if (err) return done(); }); }); - it("should run again correctly after first compilation", function(done) { + it("should run again correctly after first compilation", function (done) { const compiler = createMultiCompiler(); compiler.run((err, stats) => { if (err) return done(err); @@ -119,7 +119,7 @@ describe("MultiCompiler", function() { }); }); }); - it("should watch again correctly after first compilation", function(done) { + it("should watch again correctly after first compilation", function (done) { const compiler = createMultiCompiler(); compiler.run((err, stats) => { if (err) return done(err); @@ -131,7 +131,7 @@ describe("MultiCompiler", function() { }); }); }); - it("should run again correctly after first closed watch", function(done) { + it("should run again correctly after first closed watch", function (done) { const compiler = createMultiCompiler(); const watching = compiler.watch({}, (err, stats) => { if (err) return done(err); @@ -143,7 +143,7 @@ describe("MultiCompiler", function() { }); }); }); - it("should watch again correctly after first closed watch", function(done) { + it("should watch again correctly after first closed watch", function (done) { const compiler = createMultiCompiler(); const watching = compiler.watch({}, (err, stats) => { if (err) return done(err); diff --git a/test/ProfilingPlugin.test.js b/test/ProfilingPlugin.test.js index 00f2ded02..1089fd882 100644 --- a/test/ProfilingPlugin.test.js +++ b/test/ProfilingPlugin.test.js @@ -5,7 +5,7 @@ const fs = require("graceful-fs"); const webpack = require("../"); const rimraf = require("rimraf"); -describe("Profiling Plugin", function() { +describe("Profiling Plugin", function () { jest.setTimeout(15000); it("should handle output path with folder creation", done => { diff --git a/test/ProgressPlugin.test.js b/test/ProgressPlugin.test.js index a80e1fc0e..eac800506 100644 --- a/test/ProgressPlugin.test.js +++ b/test/ProgressPlugin.test.js @@ -7,7 +7,7 @@ const captureStdio = require("./helpers/captureStdio"); let webpack; -describe("ProgressPlugin", function() { +describe("ProgressPlugin", function () { let stderr; beforeEach(() => { diff --git a/test/StatsTestCases.test.js b/test/StatsTestCases.test.js index 11b95273e..13255141a 100644 --- a/test/StatsTestCases.test.js +++ b/test/StatsTestCases.test.js @@ -85,7 +85,7 @@ describe("StatsTestCases", () => { compilers.forEach(c => { const ifs = c.inputFileSystem; c.inputFileSystem = Object.create(ifs); - c.inputFileSystem.readFile = function() { + c.inputFileSystem.readFile = function () { const args = Array.prototype.slice.call(arguments); const callback = args.pop(); ifs.readFile.apply( diff --git a/test/TestCases.template.js b/test/TestCases.template.js index f3a906259..5648eb820 100644 --- a/test/TestCases.template.js +++ b/test/TestCases.template.js @@ -51,7 +51,7 @@ categories = categories.map(cat => { const describeCases = config => { describe(config.name, () => { categories.forEach(category => { - describe(category.name, function() { + describe(category.name, function () { jest.setTimeout(20000); category.tests @@ -160,7 +160,7 @@ const describeCases = config => { } ] }, - plugins: (config.plugins || []).concat(function() { + plugins: (config.plugins || []).concat(function () { this.hooks.compilation.tap("TestCasesTest", compilation => { [ "optimize", diff --git a/test/benchmarkCases/many-modules/webpack.config.js b/test/benchmarkCases/many-modules/webpack.config.js index 8c31ec4d7..fb8ee4844 100644 --- a/test/benchmarkCases/many-modules/webpack.config.js +++ b/test/benchmarkCases/many-modules/webpack.config.js @@ -1,3 +1,3 @@ module.exports = { - entry: "./index" + entry: "./index", }; diff --git a/test/configCases/additional-pass/simple/webpack.config.js b/test/configCases/additional-pass/simple/webpack.config.js index 398236f46..4cd7ee753 100644 --- a/test/configCases/additional-pass/simple/webpack.config.js +++ b/test/configCases/additional-pass/simple/webpack.config.js @@ -1,8 +1,8 @@ -var testPlugin = function() { +var testPlugin = function () { var counter = 1; this.hooks.compilation.tap("TestPlugin", compilation => { var nr = counter++; - compilation.hooks.needAdditionalPass.tap("TestPlugin", function() { + compilation.hooks.needAdditionalPass.tap("TestPlugin", function () { if (nr < 5) return true; }); }); diff --git a/test/configCases/chunk-index/order-multiple-entries/webpack.config.js b/test/configCases/chunk-index/order-multiple-entries/webpack.config.js index a8a63db9b..625dccf25 100644 --- a/test/configCases/chunk-index/order-multiple-entries/webpack.config.js +++ b/test/configCases/chunk-index/order-multiple-entries/webpack.config.js @@ -10,7 +10,7 @@ module.exports = { filename: "[name].js" }, plugins: [ - function() { + function () { /** * @param {Compilation} compilation compilation * @returns {void} diff --git a/test/configCases/deep-scope-analysis/remove-export-scope-hoisting/webpack.config.js b/test/configCases/deep-scope-analysis/remove-export-scope-hoisting/webpack.config.js index b187abdd1..59c95f6e3 100644 --- a/test/configCases/deep-scope-analysis/remove-export-scope-hoisting/webpack.config.js +++ b/test/configCases/deep-scope-analysis/remove-export-scope-hoisting/webpack.config.js @@ -6,7 +6,7 @@ module.exports = { concatenateModules: true }, plugins: [ - function() { + function () { this.hooks.compilation.tap( "Test", /** diff --git a/test/configCases/deep-scope-analysis/remove-export/webpack.config.js b/test/configCases/deep-scope-analysis/remove-export/webpack.config.js index 4ecb3a2e2..973fbcdc6 100644 --- a/test/configCases/deep-scope-analysis/remove-export/webpack.config.js +++ b/test/configCases/deep-scope-analysis/remove-export/webpack.config.js @@ -6,7 +6,7 @@ module.exports = { concatenateModules: false }, plugins: [ - function() { + function () { this.hooks.compilation.tap("Test", compilation => { compilation.hooks.dependencyReferencedExports.tap( "Test", diff --git a/test/configCases/entry/depend-on-advanced/webpack.config.js b/test/configCases/entry/depend-on-advanced/webpack.config.js index f821fda7d..6f304e92c 100644 --- a/test/configCases/entry/depend-on-advanced/webpack.config.js +++ b/test/configCases/entry/depend-on-advanced/webpack.config.js @@ -15,7 +15,7 @@ module.exports = { filename: "[name].js" }, plugins: [ - function() { + function () { /** * @param {Compilation} compilation compilation * @returns {void} diff --git a/test/configCases/entry/depend-on-simple/webpack.config.js b/test/configCases/entry/depend-on-simple/webpack.config.js index 566f5ec7d..81a62c28c 100644 --- a/test/configCases/entry/depend-on-simple/webpack.config.js +++ b/test/configCases/entry/depend-on-simple/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { filename: "[name].js" }, plugins: [ - function() { + function () { /** * @param {Compilation} compilation compilation * @returns {void} diff --git a/test/configCases/filename-template/module-filename-template/webpack.config.js b/test/configCases/filename-template/module-filename-template/webpack.config.js index f9cee529f..735502fc3 100644 --- a/test/configCases/filename-template/module-filename-template/webpack.config.js +++ b/test/configCases/filename-template/module-filename-template/webpack.config.js @@ -1,7 +1,7 @@ module.exports = { mode: "development", output: { - devtoolModuleFilenameTemplate: function(info) { + devtoolModuleFilenameTemplate: function (info) { return "dummy:///" + info.resourcePath; } }, diff --git a/test/configCases/finish-modules/simple/webpack.config.js b/test/configCases/finish-modules/simple/webpack.config.js index 948f2f1a6..1da810870 100644 --- a/test/configCases/finish-modules/simple/webpack.config.js +++ b/test/configCases/finish-modules/simple/webpack.config.js @@ -1,6 +1,6 @@ -var testPlugin = function() { +var testPlugin = function () { this.hooks.compilation.tap("TestPlugin", compilation => { - compilation.hooks.finishModules.tapAsync("TestPlugin", function( + compilation.hooks.finishModules.tapAsync("TestPlugin", function ( _modules, callback ) { diff --git a/test/configCases/hash-length/output-filename/webpack.config.js b/test/configCases/hash-length/output-filename/webpack.config.js index 0e4c159ff..f7130eec7 100644 --- a/test/configCases/hash-length/output-filename/webpack.config.js +++ b/test/configCases/hash-length/output-filename/webpack.config.js @@ -222,7 +222,7 @@ module.exports = [ } ]; -module.exports.forEach(function(options) { +module.exports.forEach(function (options) { options.plugins = options.plugins || []; options.plugins.push( new webpack.DefinePlugin({ diff --git a/test/configCases/issues/issue-3596/webpack.config.js b/test/configCases/issues/issue-3596/webpack.config.js index 366a4736a..34cf32437 100644 --- a/test/configCases/issues/issue-3596/webpack.config.js +++ b/test/configCases/issues/issue-3596/webpack.config.js @@ -7,8 +7,8 @@ module.exports = { filename: "[name].js" }, plugins: [ - function() { - this.hooks.emit.tap("TestPlugin", function(compilation) { + function () { + this.hooks.emit.tap("TestPlugin", function (compilation) { delete compilation.assets["b.js"]; }); } diff --git a/test/configCases/loaders/generate-ident/webpack.config.js b/test/configCases/loaders/generate-ident/webpack.config.js index b52f63dab..0f1384495 100644 --- a/test/configCases/loaders/generate-ident/webpack.config.js +++ b/test/configCases/loaders/generate-ident/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { { loader: "./loader2", options: { - f: function() { + f: function () { return "ok"; } } @@ -24,7 +24,7 @@ module.exports = { use: { loader: "./loader2", options: { - f: function() { + f: function () { return "maybe"; } } @@ -35,7 +35,7 @@ module.exports = { use: { loader: "./loader2", options: { - f: function() { + f: function () { return "yes"; } } @@ -50,7 +50,7 @@ module.exports = { { loader: "./loader2", options: { - f: function() { + f: function () { return "ok"; } } diff --git a/test/configCases/loaders/remaining-request/webpack.config.js b/test/configCases/loaders/remaining-request/webpack.config.js index b595ba0d5..7109dba99 100644 --- a/test/configCases/loaders/remaining-request/webpack.config.js +++ b/test/configCases/loaders/remaining-request/webpack.config.js @@ -9,7 +9,7 @@ module.exports = { loader: "./loader2", ident: "loader2", options: { - f: function() { + f: function () { return "ok"; } } @@ -23,7 +23,7 @@ module.exports = { { loader: "./loader2", options: { - f: function() { + f: function () { return "ok"; } } @@ -38,7 +38,7 @@ module.exports = { test: /c\.js$/, loader: "./loader2", options: { - f: function() { + f: function () { return "ok"; } } diff --git a/test/configCases/no-parse/no-parse-function/webpack.config.js b/test/configCases/no-parse/no-parse-function/webpack.config.js index b31b5cc29..2180c19f7 100644 --- a/test/configCases/no-parse/no-parse-function/webpack.config.js +++ b/test/configCases/no-parse/no-parse-function/webpack.config.js @@ -1,6 +1,6 @@ module.exports = { module: { - noParse: function(content) { + noParse: function (content) { return /not-parsed/.test(content); } } diff --git a/test/configCases/optimization/minimizer/webpack.config.js b/test/configCases/optimization/minimizer/webpack.config.js index f7c9eb9e2..100986ba0 100644 --- a/test/configCases/optimization/minimizer/webpack.config.js +++ b/test/configCases/optimization/minimizer/webpack.config.js @@ -9,7 +9,7 @@ module.exports = { expect(compiler).toBeInstanceOf(Compiler); } }, - function(compiler) { + function (compiler) { expect(compiler).toBe(this); expect(compiler).toBeInstanceOf(Compiler); } diff --git a/test/configCases/plugins/define-plugin/webpack.config.js b/test/configCases/plugins/define-plugin/webpack.config.js index 884c71c05..8b85abe12 100644 --- a/test/configCases/plugins/define-plugin/webpack.config.js +++ b/test/configCases/plugins/define-plugin/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { NEGATIVE_ZER0: -0, NEGATIVE_NUMBER: -100.25, POSITIVE_NUMBER: +100.25, - FUNCTION: /* istanbul ignore next */ function(a) { + FUNCTION: /* istanbul ignore next */ function (a) { return a + 1; }, CODE: "(1+2)", @@ -26,7 +26,7 @@ module.exports = { OBJECT: { SUB: { UNDEFINED: undefined, - FUNCTION: /* istanbul ignore next */ function(a) { + FUNCTION: /* istanbul ignore next */ function (a) { return a + 1; }, CODE: "(1+2)", @@ -42,7 +42,7 @@ module.exports = { wurst: "suppe", suppe: "wurst", RUNTIMEVALUE_CALLBACK_ARGUMENT_IS_A_MODULE: DefinePlugin.runtimeValue( - function({ module }) { + function ({ module }) { return module instanceof Module; } ), diff --git a/test/configCases/rule-set/custom/webpack.config.js b/test/configCases/rule-set/custom/webpack.config.js index 916008971..6c1851b2f 100644 --- a/test/configCases/rule-set/custom/webpack.config.js +++ b/test/configCases/rule-set/custom/webpack.config.js @@ -3,7 +3,7 @@ module.exports = { rules: [ { test: /[ab]\.js$/, - use: function(data) { + use: function (data) { return { loader: "./loader", options: { diff --git a/test/configCases/rule-set/simple-use-array-fn/webpack.config.js b/test/configCases/rule-set/simple-use-array-fn/webpack.config.js index d0a4c1502..852de277a 100644 --- a/test/configCases/rule-set/simple-use-array-fn/webpack.config.js +++ b/test/configCases/rule-set/simple-use-array-fn/webpack.config.js @@ -22,7 +22,7 @@ module.exports = { { loader: "./loader", options: { - get: function() { + get: function () { return "second-3"; } } diff --git a/test/configCases/rule-set/simple-use-fn-array/webpack.config.js b/test/configCases/rule-set/simple-use-fn-array/webpack.config.js index 09a92f76a..b58ddda2c 100644 --- a/test/configCases/rule-set/simple-use-fn-array/webpack.config.js +++ b/test/configCases/rule-set/simple-use-fn-array/webpack.config.js @@ -1,6 +1,6 @@ function createFunctionArrayFromUseArray(useArray) { - return useArray.map(function(useItem) { - return function(data) { + return useArray.map(function (useItem) { + return function (data) { return useItem; }; }); @@ -15,7 +15,7 @@ var useArray = createFunctionArrayFromUseArray([ { loader: "./loader", options: { - get: function() { + get: function () { return "second-3"; } } diff --git a/test/configCases/rule-set/simple/webpack.config.js b/test/configCases/rule-set/simple/webpack.config.js index 29371a3b9..5447ed4e1 100644 --- a/test/configCases/rule-set/simple/webpack.config.js +++ b/test/configCases/rule-set/simple/webpack.config.js @@ -22,7 +22,7 @@ module.exports = { { loader: "./loader", options: { - get: function() { + get: function () { return "second-3"; } } diff --git a/test/configCases/simple/multi-compiler-functions-export/webpack.config.js b/test/configCases/simple/multi-compiler-functions-export/webpack.config.js index 5f250c4ac..e625e4618 100644 --- a/test/configCases/simple/multi-compiler-functions-export/webpack.config.js +++ b/test/configCases/simple/multi-compiler-functions-export/webpack.config.js @@ -1,5 +1,5 @@ exports.default = [ - function() { + function () { return {}; } ]; diff --git a/test/configCases/simple/multi-compiler-functions/webpack.config.js b/test/configCases/simple/multi-compiler-functions/webpack.config.js index 6bd31ab78..b87474636 100644 --- a/test/configCases/simple/multi-compiler-functions/webpack.config.js +++ b/test/configCases/simple/multi-compiler-functions/webpack.config.js @@ -1,5 +1,5 @@ module.exports = [ - function() { + function () { return {}; } ]; diff --git a/test/configCases/wasm/identical/webpack.config.js b/test/configCases/wasm/identical/webpack.config.js index 65191ee8b..3901206b1 100644 --- a/test/configCases/wasm/identical/webpack.config.js +++ b/test/configCases/wasm/identical/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { importAwait: true }, plugins: [ - function() { + function () { this.hooks.compilation.tap( "Test", /** diff --git a/test/helpers/PluginEnvironment.js b/test/helpers/PluginEnvironment.js index 456517780..485efc869 100644 --- a/test/helpers/PluginEnvironment.js +++ b/test/helpers/PluginEnvironment.js @@ -14,7 +14,7 @@ module.exports = function PluginEnvironment() { return hookName.replace(/[A-Z]/g, c => "-" + c.toLowerCase()); } - this.getEnvironmentStub = function() { + this.getEnvironmentStub = function () { const hooks = new Map(); return { plugin: addEvent, @@ -49,7 +49,7 @@ module.exports = function PluginEnvironment() { }; }; - this.getEventBindings = function() { + this.getEventBindings = function () { return events; }; }; diff --git a/test/helpers/captureStdio.js b/test/helpers/captureStdio.js index 20caab14e..aed7f3783 100644 --- a/test/helpers/captureStdio.js +++ b/test/helpers/captureStdio.js @@ -6,7 +6,7 @@ module.exports = (stdio, tty) => { const write = stdio.write; const isTTY = stdio.isTTY; - stdio.write = function(str) { + stdio.write = function (str) { logs.push(str); }; if (tty !== undefined) stdio.isTTY = tty; diff --git a/test/helpers/deprecationTracking.js b/test/helpers/deprecationTracking.js index 02b92ab91..8aac542b5 100644 --- a/test/helpers/deprecationTracking.js +++ b/test/helpers/deprecationTracking.js @@ -13,7 +13,7 @@ const originalDeprecate = util.deprecate; util.deprecate = (fn, message, code) => { const original = originalDeprecate(fn, message, code); - return function(...args) { + return function (...args) { if (interception) { interception.set(`${code}: ${message}`, { code, message }); return fn.apply(this, args); diff --git a/test/setupTestFramework.js b/test/setupTestFramework.js index e3adbd467..e6e7660c5 100644 --- a/test/setupTestFramework.js +++ b/test/setupTestFramework.js @@ -47,7 +47,7 @@ expect.extend({ if (process.env.ALTERNATIVE_SORT) { const oldSort = Array.prototype.sort; - Array.prototype.sort = function(cmp) { + Array.prototype.sort = function (cmp) { oldSort.call(this, cmp); if (cmp) { for (let i = 1; i < this.length; i++) { diff --git a/yarn.lock b/yarn.lock index 2270ad7e4..092f3a855 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5313,7 +5313,12 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^1.14.3, prettier@^1.19.1: +prettier@2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.2.tgz#1ba8f3eb92231e769b7fcd7cb73ae1b6b74ade08" + integrity sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg== + +prettier@^1.19.1: version "1.19.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==