Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ max_line_length = 80
indent_style = space
indent_size = 2

[test/cases/parsing/bom/bomfile.{css,js}]
charset = utf-8-bom

[test/configCases/css/no-extra-runtime-in-js/source.text]
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false

[*.snap]
trim_trailing_whitespace = false

[test/cases/parsing/bom/bomfile.{css,js}]
charset = utf-8-bom

[test/configCases/css/no-extra-runtime-in-js/source.text]
insert_final_newline = false
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
useTabs: true,
tabWidth: 2,
trailingComma: "none",
arrowParens: "avoid",
arrowParens: "always",
overrides: [
{
files: "*.json",
Expand Down
14 changes: 7 additions & 7 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const runCommand = (command, args) => {
shell: true
});

executedCommand.on("error", error => {
executedCommand.on("error", (error) => {
reject(error);
});

executedCommand.on("exit", code => {
executedCommand.on("exit", (code) => {
if (code === 0) {
resolve();
} else {
Expand All @@ -34,7 +34,7 @@ const runCommand = (command, args) => {
* @param {string} packageName name of the package
* @returns {boolean} is the package installed?
*/
const isInstalled = packageName => {
const isInstalled = (packageName) => {
if (process.versions.pnp) {
return true;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ const isInstalled = packageName => {
* @param {CliOption} cli options
* @returns {void}
*/
const runCli = cli => {
const runCli = (cli) => {
const path = require("path");

const pkgPath = require.resolve(`${cli.package}/package.json`);
Expand All @@ -85,7 +85,7 @@ const runCli = cli => {

if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
err => {
(err) => {
console.error(err);
process.exitCode = 1;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ if (!cli.installed) {
// executed. Setting the exit code here to ensure the script exits correctly in those cases. The callback
// function is responsible for clearing the exit code if the user wishes to install webpack-cli.
process.exitCode = 1;
questionInterface.question(question, answer => {
questionInterface.question(question, (answer) => {
questionInterface.close();

const normalizedAnswer = answer.toLowerCase().startsWith("y");
Expand Down Expand Up @@ -183,7 +183,7 @@ if (!cli.installed) {
.then(() => {
runCli(cli);
})
.catch(err => {
.catch((err) => {
console.error(err);
process.exitCode = 1;
});
Expand Down
7 changes: 0 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ export default defineConfig([

"id-length": "off",

"unicorn/no-array-for-each": "off",
"unicorn/prefer-includes": "off",

"jsdoc/require-jsdoc": "off",

// Revisit it in future
Expand All @@ -151,9 +148,6 @@ export default defineConfig([
{
files: ["test/**/*.js"],
rules: {
// TODO enable me
strict: "off",

// Some our tests contain `package.json` without `engines`, but tests should work on Node.js@10, so let's disable it
"n/prefer-node-protocol": "off",

Expand Down Expand Up @@ -208,7 +202,6 @@ export default defineConfig([
{
files: [
"test/configCases/{dll-plugin-entry,dll-plugin-side-effects,dll-plugin}/**/webpack.config.js",
"examples/**/*.js",
"test/NodeTemplatePlugin.test.js",
"test/PersistentCaching.test.js"
],
Expand Down
18 changes: 9 additions & 9 deletions lib/APIPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class APIPlugin {

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.chunkName)
.tap(PLUGIN_NAME, chunk => {
.tap(PLUGIN_NAME, (chunk) => {
compilation.addRuntimeModule(
chunk,
new ChunkNameRuntimeModule(/** @type {string} */ (chunk.name))
Expand Down Expand Up @@ -213,10 +213,10 @@ class APIPlugin {
/**
* @param {JavascriptParser} parser the parser
*/
const handler = parser => {
const handler = (parser) => {
for (const key of Object.keys(REPLACEMENTS)) {
const info = REPLACEMENTS[key];
parser.hooks.expression.for(key).tap(PLUGIN_NAME, expression => {
parser.hooks.expression.for(key).tap(PLUGIN_NAME, (expression) => {
const dep = toConstantDependency(parser, info.expr, info.req);

if (key === "__non_webpack_require__" && this.options.module) {
Expand All @@ -227,7 +227,7 @@ class APIPlugin {
return dep(expression);
});
if (info.assign === false) {
parser.hooks.assign.for(key).tap(PLUGIN_NAME, expr => {
parser.hooks.assign.for(key).tap(PLUGIN_NAME, (expr) => {
const err = new WebpackError(`${key} must not be assigned`);
err.loc = /** @type {DependencyLocation} */ (expr.loc);
throw err;
Expand All @@ -242,7 +242,7 @@ class APIPlugin {

parser.hooks.expression
.for("__webpack_layer__")
.tap(PLUGIN_NAME, expr => {
.tap(PLUGIN_NAME, (expr) => {
const dep = new ConstDependency(
JSON.stringify(parser.state.module.layer),
/** @type {Range} */ (expr.range)
Expand All @@ -253,7 +253,7 @@ class APIPlugin {
});
parser.hooks.evaluateIdentifier
.for("__webpack_layer__")
.tap(PLUGIN_NAME, expr =>
.tap(PLUGIN_NAME, (expr) =>
(parser.state.module.layer === null
? new BasicEvaluatedExpression().setNull()
: new BasicEvaluatedExpression().setString(
Expand All @@ -263,7 +263,7 @@ class APIPlugin {
);
parser.hooks.evaluateTypeof
.for("__webpack_layer__")
.tap(PLUGIN_NAME, expr =>
.tap(PLUGIN_NAME, (expr) =>
new BasicEvaluatedExpression()
.setString(
parser.state.module.layer === null ? "object" : "string"
Expand All @@ -273,7 +273,7 @@ class APIPlugin {

parser.hooks.expression
.for("__webpack_module__.id")
.tap(PLUGIN_NAME, expr => {
.tap(PLUGIN_NAME, (expr) => {
/** @type {BuildInfo} */
(parser.state.module.buildInfo).moduleConcatenationBailout =
"__webpack_module__.id";
Expand All @@ -289,7 +289,7 @@ class APIPlugin {

parser.hooks.expression
.for("__webpack_module__")
.tap(PLUGIN_NAME, expr => {
.tap(PLUGIN_NAME, (expr) => {
/** @type {BuildInfo} */
(parser.state.module.buildInfo).moduleConcatenationBailout =
"__webpack_module__";
Expand Down
4 changes: 2 additions & 2 deletions lib/AutomaticPrefetchPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AutomaticPrefetchPlugin {
);
/** @type {{context: string | null, request: string}[] | null} */
let lastModules = null;
compiler.hooks.afterCompile.tap(PLUGIN_NAME, compilation => {
compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {
lastModules = [];

for (const m of compilation.modules) {
Expand All @@ -54,7 +54,7 @@ class AutomaticPrefetchPlugin {
callback
);
},
err => {
(err) => {
lastModules = null;
callback(err);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/BannerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const validate = createSchemaValidation(
* @param {string} str string to wrap
* @returns {string} wrapped string
*/
const wrapComment = str => {
const wrapComment = (str) => {
if (!str.includes("\n")) {
return Template.toComment(str);
}
Expand Down Expand Up @@ -67,7 +67,7 @@ class BannerPlugin {
/** @type {BannerFunction} */
this.banner = this.options.raw
? getBanner
: /** @type {BannerFunction} */ data => wrapComment(getBanner(data));
: /** @type {BannerFunction} */ (data) => wrapComment(getBanner(data));
} else {
const banner = this.options.raw
? bannerOption
Expand All @@ -93,7 +93,7 @@ class BannerPlugin {
const stage =
this.options.stage || Compilation.PROCESS_ASSETS_STAGE_ADDITIONS;

compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.processAssets.tap({ name: PLUGIN_NAME, stage }, () => {
for (const chunk of compilation.chunks) {
if (options.entryOnly && !chunk.canBeInitial()) {
Expand All @@ -114,7 +114,7 @@ class BannerPlugin {
data
);

compilation.updateAsset(file, old => {
compilation.updateAsset(file, (old) => {
const cached = cache.get(old);
if (!cached || cached.comment !== comment) {
const source = options.footer
Expand Down
2 changes: 1 addition & 1 deletion lib/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const {
* @param {(err?: Error) => void} callback callback
* @returns {(err?: Error) => void} callback
*/
const needCalls = (times, callback) => err => {
const needCalls = (times, callback) => (err) => {
if (--times === 0) {
return callback(err);
}
Expand Down
14 changes: 7 additions & 7 deletions lib/CacheFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class MultiItemCache {
* @param {number} i index
* @returns {Promise<T>} promise with the data
*/
const next = i =>
this._items[i].getPromise().then(result => {
const next = (i) =>
this._items[i].getPromise().then((result) => {
if (result !== undefined) return result;
if (++i < this._items.length) return next(i);
});
Expand All @@ -89,7 +89,7 @@ class MultiItemCache {
* @returns {Promise<void>} promise signals when the value is stored
*/
storePromise(data) {
return Promise.all(this._items.map(item => item.storePromise(data))).then(
return Promise.all(this._items.map((item) => item.storePromise(data))).then(
() => {}
);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class ItemCacheFacade {
*/
storePromise(data) {
return new Promise((resolve, reject) => {
this._cache.store(this._name, this._etag, data, err => {
this._cache.store(this._name, this._etag, data, (err) => {
if (err) {
reject(err);
} else {
Expand All @@ -171,7 +171,7 @@ class ItemCacheFacade {
if (cacheEntry !== undefined) return cacheEntry;
computer((err, result) => {
if (err) return callback(err);
this.store(result, err => {
this.store(result, (err) => {
if (err) return callback(err);
callback(null, result);
});
Expand Down Expand Up @@ -297,7 +297,7 @@ class CacheFacade {
*/
storePromise(identifier, etag, data) {
return new Promise((resolve, reject) => {
this._cache.store(`${this._name}|${identifier}`, etag, data, err => {
this._cache.store(`${this._name}|${identifier}`, etag, data, (err) => {
if (err) {
reject(err);
} else {
Expand All @@ -321,7 +321,7 @@ class CacheFacade {
if (cacheEntry !== undefined) return cacheEntry;
computer((err, result) => {
if (err) return callback(err);
this.store(identifier, etag, result, err => {
this.store(identifier, etag, result, (err) => {
if (err) return callback(err);
callback(null, result);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/CaseSensitiveModulesWarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const WebpackError = require("./WebpackError");
* @param {Module[]} modules the modules to be sorted
* @returns {Module[]} sorted version of original modules
*/
const sortModules = modules =>
const sortModules = (modules) =>
modules.sort((a, b) => {
const aIdent = a.identifier();
const bIdent = b.identifier();
Expand All @@ -33,7 +33,7 @@ const sortModules = modules =>
*/
const createModulesListMessage = (modules, moduleGraph) =>
modules
.map(m => {
.map((m) => {
let message = `* ${m.identifier()}`;
const validReasons = [
...moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
Expand Down
6 changes: 3 additions & 3 deletions lib/Chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ class Chunk {
const chunks = new Set();

const initialChunks = intersect(
Array.from(this.groupsIterable, g => new Set(g.chunks))
Array.from(this.groupsIterable, (g) => new Set(g.chunks))
);

const initialQueue = new Set(this.groupsIterable);
Expand Down Expand Up @@ -672,7 +672,7 @@ class Chunk {
const queue = new Set();

const initialChunks = intersect(
Array.from(this.groupsIterable, g => new Set(g.chunks))
Array.from(this.groupsIterable, (g) => new Set(g.chunks))
);

for (const chunkGroup of this.groupsIterable) {
Expand Down Expand Up @@ -812,7 +812,7 @@ class Chunk {
* @param {Chunk} chunk a chunk
* @returns {void}
*/
const addChildIdsByOrdersToMap = chunk => {
const addChildIdsByOrdersToMap = (chunk) => {
const data = chunk.getChildIdsByOrders(chunkGraph, filterFn);
for (const key of Object.keys(data)) {
let chunkMap = chunkMaps[key];
Expand Down
Loading
Loading