Skip to content

Commit

Permalink
Upgrade to Prettier 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Mar 28, 2020
1 parent e964f08 commit 7b07a8d
Show file tree
Hide file tree
Showing 70 changed files with 251 additions and 270 deletions.
2 changes: 2 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
printWidth: 80,
useTabs: true,
tabWidth: 2,
trailingComma: "none",
arrowParens: "avoid",
overrides: [
{
files: "*.json",
Expand Down
2 changes: 1 addition & 1 deletion benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const outputPath = path.join(__dirname, "js");

const benchmarkOptions = {
defer: true,
onCycle: function() {
onCycle: function () {
process.stderr.write(".");
},
minSamples: 10
Expand Down
6 changes: 3 additions & 3 deletions hot/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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...");
Expand Down
10 changes: 5 additions & 5 deletions hot/log-apply-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
});
}
Expand All @@ -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());
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions hot/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions hot/only-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand All @@ -53,7 +53,7 @@ if (module.hot) {
);
}
})
.then(function(renewedModules) {
.then(function (renewedModules) {
if (!upToDate()) {
check();
}
Expand All @@ -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(
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions hot/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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;
}
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.");
Expand Down
10 changes: 5 additions & 5 deletions hot/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -18,22 +18,22 @@ if (module.hot) {
return module.hot
.apply({
ignoreUnaccepted: true,
onUnaccepted: function(data) {
onUnaccepted: function (data) {
log(
"warning",
"Ignored an update to unaccepted module " +
data.chain.join(" -> ")
);
}
})
.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.");
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/ChunkTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 2 additions & 2 deletions lib/ContextModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/EvalSourceMapDevToolPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/MainTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
10 changes: 3 additions & 7 deletions lib/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -868,7 +864,7 @@ Object.defineProperty(Module.prototype, "errors", {
* @this {Module}
* @returns {WebpackError[]} array
*/
function() {
function () {
if (this._errors === undefined) {
this._errors = [];
}
Expand All @@ -886,7 +882,7 @@ Object.defineProperty(Module.prototype, "warnings", {
* @this {Module}
* @returns {WebpackError[]} array
*/
function() {
function () {
if (this._warnings === undefined) {
this._warnings = [];
}
Expand Down
5 changes: 1 addition & 4 deletions lib/ModuleDependencyError.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions lib/ModuleDependencyWarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions lib/ModuleFilenameHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/ModuleTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 1 addition & 3 deletions lib/config/normalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}),
Expand Down
Loading

0 comments on commit 7b07a8d

Please sign in to comment.