chore: more eslint rules (#19667)
Github Actions / lint (push) Waiting to run Details
Github Actions / validate-legacy-node (push) Waiting to run Details
Github Actions / benchmark (1/4) (push) Waiting to run Details
Github Actions / benchmark (2/4) (push) Waiting to run Details
Github Actions / benchmark (3/4) (push) Waiting to run Details
Github Actions / benchmark (4/4) (push) Waiting to run Details
Github Actions / basic (push) Waiting to run Details
Github Actions / unit (push) Waiting to run Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions Details

This commit is contained in:
Alexander Akait 2025-07-08 17:46:17 +03:00 committed by GitHub
parent 260f85e466
commit 5a204dc8cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
207 changed files with 346 additions and 321 deletions

View File

@ -84,12 +84,6 @@ export default defineConfig([
}
],
// TODO enable me in future
"unicorn/prefer-regexp-test": "off",
"unicorn/prefer-string-slice": "off",
// TODO false positive, need to fix in upstream
"n/prefer-node-protocol": "off",
"n/prefer-global/url": "off",
// TODO enable me in future
"prefer-destructuring": "off"
}
},
@ -160,6 +154,9 @@ export default defineConfig([
// 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",
// No need here, we have custom test logic, so except can be placed in different places
"jest/no-standalone-expect": "off",

View File

@ -179,7 +179,7 @@ class APIPlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.getFullHash)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule());
return true;
});

View File

@ -683,7 +683,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
{
name,
/** @type {AsyncSeriesHook<T>["intercept"]} */
intercept(interceptor) {
intercept(_interceptor) {
throw new Error(errorMessage("it's using 'intercept'"));
},
/** @type {AsyncSeriesHook<T>["tap"]} */
@ -5279,7 +5279,7 @@ This prevents using hashes of each other and should be avoided.`);
runtimeTemplate,
errors,
codeGenerationResults,
(err, codeGenerated) => {
(err, _codeGenerated) => {
callback(err);
}
);
@ -5654,9 +5654,9 @@ Object.defineProperty(compilationPrototype, "cache", {
),
set: util.deprecate(
/**
* @param {EXPECTED_ANY} v value
* @param {EXPECTED_ANY} _v value
*/
v => {},
_v => {},
"Compilation.cache was removed in favor of Compilation.getCache()",
"DEP_WEBPACK_COMPILATION_CACHE"
)

View File

@ -1391,7 +1391,7 @@ ${other}`);
close(callback) {
if (this.watching) {
// When there is still an active watching, close this first
this.watching.close(err => {
this.watching.close(_err => {
this.close(callback);
});
return;

View File

@ -160,7 +160,7 @@ class ConstPlugin {
* @param {JavascriptParser} parser the parser
*/
const handler = parser => {
parser.hooks.terminate.tap(PLUGIN_NAME, statement => true);
parser.hooks.terminate.tap(PLUGIN_NAME, _statement => true);
parser.hooks.statementIf.tap(PLUGIN_NAME, statement => {
if (parser.scope.isAsmJs) return;
const param = parser.evaluateExpression(statement.test);

View File

@ -352,7 +352,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
(segment, callback) => {
const subResource = join(fs, directory, segment);
if (!exclude || !subResource.match(exclude)) {
if (!exclude || !exclude.test(subResource)) {
fs.stat(subResource, (err, _stat) => {
if (err) {
if (err.code === "ENOENT") {
@ -370,7 +370,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
addSubDirectory(ctx, subResource, callback);
} else if (
stat.isFile() &&
(!include || subResource.match(include))
(!include || include.test(subResource))
) {
/** @type {{ context: string, request: string }} */
const obj = {

View File

@ -80,7 +80,7 @@ class DynamicEntryPlugin {
}
return Promise.all(promises);
})
.then(x => {})
.then(() => {})
);
}
}

View File

@ -119,7 +119,7 @@ class EvalDevToolModulePlugin {
if (compilation.outputOptions.trustedTypes) {
compilation.hooks.additionalModuleRuntimeRequirements.tap(
PLUGIN_NAME,
(module, set, context) => {
(module, set, _context) => {
set.add(RuntimeGlobals.createScript);
}
);

View File

@ -669,7 +669,7 @@ class ExternalModule extends Module {
* @param {ConcatenationBailoutReasonContext} context context
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
*/
getConcatenationBailoutReason({ moduleGraph }) {
getConcatenationBailoutReason(context) {
switch (this.externalType) {
case "amd":
case "amd-require":

View File

@ -1950,11 +1950,11 @@ class FileSystemInfo {
if (imp.d === -1) {
// import ... from "..."
dependency = parseString(
source.substring(imp.s - 1, imp.e + 1)
source.slice(imp.s - 1, imp.e + 1)
);
} else if (imp.d > -1) {
// import()
const expr = source.substring(imp.s, imp.e).trim();
const expr = source.slice(imp.s, imp.e).trim();
dependency = parseString(expr);
} else {
// e.g. import.meta
@ -1974,7 +1974,7 @@ class FileSystemInfo {
});
} catch (err1) {
logger.warn(
`Parsing of ${path} for build dependencies failed at 'import(${source.substring(
`Parsing of ${path} for build dependencies failed at 'import(${source.slice(
imp.s,
imp.e
)})'.\n` +

View File

@ -598,7 +598,7 @@ module.exports = class MultiCompiler {
}
return watching;
},
(compiler, watching, callback) => {
(compiler, watching, _callback) => {
if (compiler.watching !== watching) return;
if (!watching.running) watching.invalidate();
},

View File

@ -415,7 +415,7 @@ class ProgressPlugin {
}
return data;
},
err => {
_err => {
// Ignore error
}
);

View File

@ -363,7 +363,7 @@ class RuntimePlugin {
"javascript",
"javascript update",
RuntimeGlobals.getChunkUpdateScriptFilename,
c =>
_chunk =>
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
(compilation.outputOptions.hotUpdateChunkFilename),
true
@ -465,13 +465,13 @@ class RuntimePlugin {
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.relativeUrl)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.onChunksLoaded)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(
chunk,
new OnChunksLoadedRuntimeModule()
@ -495,7 +495,7 @@ class RuntimePlugin {
// TODO webpack 6: remove CompatRuntimeModule
compilation.hooks.additionalTreeRuntimeRequirements.tap(
PLUGIN_NAME,
(chunk, set) => {
(chunk, _set) => {
const { mainTemplate } = compilation;
if (
mainTemplate.hooks.bootstrap.isUsed() ||

View File

@ -1209,7 +1209,7 @@ class PackFileCacheStrategy {
}
logger.time("check build dependencies");
return Promise.all([
new Promise((resolve, reject) => {
new Promise((resolve, _reject) => {
this.fileSystemInfo.checkSnapshotValid(
packContainer.buildSnapshot,
(err, valid) => {
@ -1231,7 +1231,7 @@ class PackFileCacheStrategy {
}
);
}),
new Promise((resolve, reject) => {
new Promise((resolve, _reject) => {
this.fileSystemInfo.checkSnapshotValid(
packContainer.resolveBuildDependenciesSnapshot,
(err, valid) => {

View File

@ -56,7 +56,7 @@ class HoistContainerReferences {
// advanced stage is where SplitChunksPlugin runs.
stage: STAGE_ADVANCED + 1
},
chunks => {
_chunks => {
this.hoistModulesInChunks(
compilation,
depsToTrace,

View File

@ -141,7 +141,7 @@ class RemoteModule extends Module {
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
codeGeneration({ moduleGraph, chunkGraph }) {
const module = moduleGraph.getModule(this.dependencies[0]);
const id = module && chunkGraph.getModuleId(module);
const sources = new Map();

View File

@ -320,6 +320,7 @@ const consumeAStringToken = (input, pos, callbacks) => {
const isNonASCIICodePoint = (cc, q) =>
// Simplify
cc > 0x80;
/**
* @param {number} cc char code
* @returns {boolean} is letter
@ -716,12 +717,12 @@ const consumeRightParenthesis = (input, pos, callbacks) => {
};
/** @type {CharHandler} */
const consumeLeftSquareBracket = (input, pos, callbacks) =>
const consumeLeftSquareBracket = (input, pos, _callbacks) =>
// Return a <]-token>.
pos;
/** @type {CharHandler} */
const consumeRightSquareBracket = (input, pos, callbacks) =>
const consumeRightSquareBracket = (input, pos, _callbacks) =>
// Return a <]-token>.
pos;

View File

@ -378,7 +378,7 @@ const interceptAllParserHooks = (moduleFactory, tracer) => {
for (const moduleType of moduleTypes) {
moduleFactory.hooks.parser
.for(moduleType)
.tap(PLUGIN_NAME, (parser, parserOpts) => {
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
interceptAllHooksFor(parser, tracer, "Parser");
});
}
@ -399,7 +399,7 @@ const interceptAllGeneratorHooks = (moduleFactory, tracer) => {
for (const moduleType of moduleTypes) {
moduleFactory.hooks.generator
.for(moduleType)
.tap(PLUGIN_NAME, (parser, parserOpts) => {
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
interceptAllHooksFor(parser, tracer, "Generator");
});
}

View File

@ -119,13 +119,13 @@ class AMDPlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.amdDefine)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule());
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.amdOptions)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(
chunk,
new AMDOptionsRuntimeModule(amdOptions)

View File

@ -99,11 +99,7 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
* @param {DependencyTemplateContext} templateContext the context object
* @returns {void}
*/
apply(
dependency,
source,
{ runtimeTemplate, dependencyTemplates, initFragments }
) {
apply(dependency, source, { initFragments }) {
const dep = /** @type {CachedConstDependency} */ (dependency);
initFragments.push(

View File

@ -107,15 +107,7 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
apply(
dependency,
source,
{
module,
runtimeTemplate,
moduleGraph,
chunkGraph,
runtimeRequirements,
runtime,
initFragments
}
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements, runtime }
) {
const dep = /** @type {CommonJsFullRequireDependency} */ (dependency);
if (!dep.range) return;

View File

@ -156,7 +156,7 @@ class CommonJsPlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.harmonyModuleDecorator)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(
chunk,
new HarmonyModuleDecoratorRuntimeModule()
@ -165,7 +165,7 @@ class CommonJsPlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.nodeModuleDecorator)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(
chunk,
new NodeModuleDecoratorRuntimeModule()

View File

@ -346,9 +346,9 @@ class ImportParserPlugin {
include,
exclude,
mode,
namespaceObject: /** @type {BuildMeta} */ (
parser.state.module.buildMeta
).strictHarmonyModule
namespaceObject:
/** @type {BuildMeta} */
(parser.state.module.buildMeta).strictHarmonyModule
? "strict"
: true,
typePrefix: "import()",

View File

@ -46,7 +46,7 @@ class SystemPlugin {
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.system)
.tap(PLUGIN_NAME, (chunk, set) => {
.tap(PLUGIN_NAME, (chunk, _set) => {
compilation.addRuntimeModule(chunk, new SystemRuntimeModule());
});

View File

@ -493,12 +493,18 @@ class WorkerPlugin {
const pattern = item.slice(1, firstDot);
const itemMembers = item.slice(firstDot + 1, -2);
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
if (decl.id.type === "Identifier" && decl.id.name === pattern) {
parser.hooks.preDeclarator.tap(
PLUGIN_NAME,
(decl, _statement) => {
if (
decl.id.type === "Identifier" &&
decl.id.name === pattern
) {
parser.tagVariable(decl.id.name, WorkerSpecifierTag);
return true;
}
});
}
);
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
parser.tagVariable(pattern.name, WorkerSpecifierTag);
return true;

View File

@ -287,9 +287,7 @@ class ModuleChunkFormatPlugin {
}
return source;
});
hooks.chunkHash.tap(
PLUGIN_NAME,
(chunk, hash, { chunkGraph, runtimeTemplate }) => {
hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, { chunkGraph }) => {
if (chunk.hasRuntime()) return;
const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
hash.update(PLUGIN_NAME);
@ -301,8 +299,7 @@ class ModuleChunkFormatPlugin {
hash.update(runtimeChunk.hash);
}
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
}
);
});
});
}
}

View File

@ -26,7 +26,7 @@ class NaturalModuleIdsPlugin {
*/
apply(compiler) {
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
compilation.hooks.moduleIds.tap(PLUGIN_NAME, modules => {
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
const [usedIds, modulesInNaturalOrder] =
getUsedModuleIdsAndModules(compilation);
modulesInNaturalOrder.sort(

View File

@ -117,10 +117,10 @@ const printGeneratedCodeForStack = (module, code) => {
/**
* @param {string} line the line
* @param {number} i the index
* @param {string[]} lines the lines
* @param {string[]} _lines the lines
* @returns {string} the line with line number
*/
(line, i, lines) => {
(line, i, _lines) => {
const iStr = `${i + 1}`;
return `${" ".repeat(n - iStr.length)}${iStr} | ${line}`;
}

View File

@ -1386,7 +1386,7 @@ class JavascriptParser extends Parser {
return this.callHooksForInfoWithFallback(
this.hooks.evaluateIdentifier,
info.name,
name => {
_name => {
cachedExpression = expression;
cachedInfo = info;
return undefined;
@ -1441,7 +1441,7 @@ class JavascriptParser extends Parser {
};
}
});
tapEvaluateWithVariableInfo("ThisExpression", expr => {
tapEvaluateWithVariableInfo("ThisExpression", _expr => {
const info = this.getVariableInfo("this");
if (
typeof info === "string" ||
@ -3481,7 +3481,7 @@ class JavascriptParser extends Parser {
return;
}
this.walkExpression(expression.right);
this.enterPattern(expression.left, (name, decl) => {
this.enterPattern(expression.left, (name, _decl) => {
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
this.walkExpression(
/** @type {MemberExpression} */
@ -3491,7 +3491,7 @@ class JavascriptParser extends Parser {
});
} else if (expression.left.type.endsWith("Pattern")) {
this.walkExpression(expression.right);
this.enterPattern(expression.left, (name, decl) => {
this.enterPattern(expression.left, (name, _decl) => {
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
this.defineVariable(name);
}

View File

@ -195,7 +195,7 @@ class InnerGraphPlugin {
}
});
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, _statement) => {
if (!InnerGraph.isEnabled(parser.state)) return;
if (
parser.scope.topLevelScope === true &&
@ -363,7 +363,7 @@ class InnerGraphPlugin {
}
);
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, statement) => {
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, _statement) => {
if (!InnerGraph.isEnabled(parser.state)) return;
const fn = declWithTopLevelSymbol.get(decl);

View File

@ -279,10 +279,10 @@ const INITIAL_CHUNK_FILTER = chunk => chunk.canBeInitial();
*/
const ASYNC_CHUNK_FILTER = chunk => !chunk.canBeInitial();
/**
* @param {Chunk} chunk the chunk
* @param {Chunk} _chunk the chunk
* @returns {boolean} always true
*/
const ALL_CHUNK_FILTER = chunk => true;
const ALL_CHUNK_FILTER = _chunk => true;
/**
* @param {OptimizationSplitChunksSizes | undefined} value the sizes

View File

@ -35,7 +35,7 @@ class BasicEffectRulePlugin {
apply(ruleSetCompiler) {
ruleSetCompiler.hooks.rule.tap(
PLUGIN_NAME,
(path, rule, unhandledProperties, result, references) => {
(path, rule, unhandledProperties, result) => {
if (unhandledProperties.has(this.ruleProperty)) {
unhandledProperties.delete(this.ruleProperty);

View File

@ -5,7 +5,7 @@
"use strict";
const { URL, fileURLToPath } = require("url");
const { fileURLToPath } = require("url");
const { NormalModule } = require("..");
/** @typedef {import("../Compiler")} Compiler */

View File

@ -7,7 +7,6 @@
const EventEmitter = require("events");
const { basename, extname } = require("path");
const { URL } = require("url");
const {
// eslint-disable-next-line n/no-unsupported-features/node-builtins
createBrotliDecompress,
@ -37,7 +36,7 @@ const getHttps = memoize(() => require("https"));
/**
* @param {typeof import("http") | typeof import("https")} request request
* @param {string | { toString: () => string } | undefined} proxy proxy
* @param {string | URL | undefined} proxy proxy
* @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn
*/
const proxyFetch = (request, proxy) => (url, options, callback) => {

View File

@ -554,7 +554,7 @@ class FileMiddleware extends SerializerMiddleware {
* @param {(value?: undefined) => void} resolve resolve
*/
resolve => {
this.fs.rename(filename, `${filename}.old`, err => {
this.fs.rename(filename, `${filename}.old`, _err => {
resolve();
});
}

View File

@ -177,7 +177,7 @@ class ConsumeSharedModule extends Module {
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
codeGeneration({ chunkGraph, moduleGraph, runtimeTemplate }) {
codeGeneration({ chunkGraph, runtimeTemplate }) {
const runtimeRequirements = new Set([RuntimeGlobals.shareScopeMap]);
const {
shareScope,

View File

@ -132,7 +132,7 @@ class ProvideSharedModule extends Module {
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
codeGeneration({ runtimeTemplate, chunkGraph }) {
const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);
const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(
this._version || "0"

View File

@ -495,7 +495,7 @@ const EXTRACT_ERROR = {
errorDetails: (
object,
error,
{ type, compilation, cachedGetErrors, cachedGetWarnings },
{ type, compilation, cachedGetErrors },
{ errorDetails }
) => {
if (
@ -1037,7 +1037,7 @@ const SIMPLE_EXTRACTORS = {
_: (
object,
asset,
{ compilation, compilationFileToChunks, compilationAuxiliaryFileToChunks }
{ compilationFileToChunks, compilationAuxiliaryFileToChunks }
) => {
const chunks = compilationFileToChunks.get(asset.name) || [];
const auxiliaryChunks =
@ -1522,7 +1522,7 @@ const SIMPLE_EXTRACTORS = {
ids: (object, chunk) => {
object.id = /** @type {ChunkId} */ (chunk.id);
},
chunkRelations: (object, chunk, { compilation: { chunkGraph } }) => {
chunkRelations: (object, chunk, _context) => {
/** @type {Set<string|number>} */
const parents = new Set();
/** @type {Set<string|number>} */
@ -1703,7 +1703,7 @@ const SORTERS = {
"chunk.modules": MODULES_SORTER,
"module.modules": MODULES_SORTER,
"module.reasons": {
_: (comparators, { compilation: { chunkGraph } }) => {
_: (comparators, _context) => {
comparators.push(
compareSelect(x => x.originModule, compareModulesByIdentifier)
);
@ -2147,7 +2147,7 @@ const ASSETS_GROUPERS = {
});
}
},
groupAssetsByInfo: (groupConfigs, context, options) => {
groupAssetsByInfo: (groupConfigs, _context, _options) => {
/**
* @param {string} name name
*/
@ -2168,7 +2168,7 @@ const ASSETS_GROUPERS = {
groupByAssetInfoFlag("development");
groupByAssetInfoFlag("hotModuleReplacement");
},
groupAssetsByChunk: (groupConfigs, context, options) => {
groupAssetsByChunk: (groupConfigs, _context, _options) => {
/**
* @param {keyof KnownStatsAsset} name name
*/

View File

@ -384,7 +384,7 @@ class DefaultStatsPresetPlugin {
const defaults = NAMED_PRESETS[/** @type {keyof NamedPresets} */ (key)];
compilation.hooks.statsPreset
.for(key)
.tap(PLUGIN_NAME, (options, context) => {
.tap(PLUGIN_NAME, (options, _context) => {
applyDefaults(options, defaults);
});
}

View File

@ -494,7 +494,7 @@ const MODULE_SIMPLE_PRINTERS = {
const [prefix, resource] = getModuleName(name);
return `${prefix || ""}${bold(resource || "")}`;
},
"module.identifier": identifier => undefined,
"module.identifier": _identifier => undefined,
"module.layer": (layer, { formatLayer }) =>
layer ? formatLayer(layer) : undefined,
"module.sizes": printSizes,
@ -571,7 +571,7 @@ const MODULE_SIMPLE_PRINTERS = {
yellow(optimizationBailout),
"module.issuerPath": (issuerPath, { module }) =>
module.profile ? undefined : "",
"module.profile": profile => undefined,
"module.profile": _profile => undefined,
"module.filteredModules": (filteredModules, { module: { modules } }) =>
filteredModules > 0
? `${moreCount(modules, filteredModules)} nested ${plural(
@ -831,7 +831,7 @@ const ERROR_PRINTERS = {
" "
)
: undefined,
"error.moduleTrace": moduleTrace => undefined,
"error.moduleTrace": _moduleTrace => undefined,
"error.separator!": () => "\n"
};
@ -1856,7 +1856,7 @@ class DefaultStatsPrinterPlugin {
const preferredOrder = PREFERRED_ORDERS[key];
stats.hooks.sortElements
.for(key)
.tap(PLUGIN_NAME, (elements, context) => {
.tap(PLUGIN_NAME, (elements, _context) => {
createOrder(elements, preferredOrder);
});
}

View File

@ -137,7 +137,7 @@
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^51.2.3",
"eslint-plugin-n": "^17.20.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-prettier": "^5.5.0",
"eslint-plugin-unicorn": "^59.0.1",
"file-loader": "^6.0.0",

View File

@ -43,7 +43,7 @@ async function runSetupSymlinkAsync() {
* @returns {Promise<boolean>} result
*/
function checkSymlinkExistsAsync() {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
if (
fs.existsSync(nodeModulesFolder) &&
fs.existsSync(webpackDependencyFolder) &&

View File

@ -133,12 +133,12 @@ describe("Compiler (caching)", () => {
const options = {};
const tempFixture = createTempFixture();
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
// Not cached the first time
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(true);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// Cached the second run
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(false);
@ -151,7 +151,7 @@ describe("Compiler (caching)", () => {
setTimeout(() => {
fs.writeFileSync(tempFixture.aFilepath, aContent);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// Cached the third run
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(true);
@ -167,12 +167,12 @@ describe("Compiler (caching)", () => {
const options = {};
const tempFixture = createTempFixture();
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
// Not cached the first time
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(true);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, files, _iteration) => {
// Cached the second run
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(false);
@ -186,7 +186,7 @@ describe("Compiler (caching)", () => {
fs.writeFileSync(tempFixture.aFilepath, aContent);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, files, _iteration) => {
// Cached the third run
expect(stats.assets[0].name).toBe("bundle.js");
expect(stats.assets[0].emitted).toBe(true);
@ -203,7 +203,7 @@ describe("Compiler (caching)", () => {
const options = {};
const tempFixture = createTempFixture();
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
// Built the first time
expect(stats.modules[0].name).toMatch("c.js");
expect(stats.modules[0].built).toBe(true);
@ -212,7 +212,7 @@ describe("Compiler (caching)", () => {
expect(stats.modules[1].built).toBe(true);
setTimeout(() => {
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// Not built when cached the second run
expect(stats.modules[0].name).toMatch("c.js");
// expect(stats.modules[0].built).toBe(false);
@ -228,7 +228,7 @@ describe("Compiler (caching)", () => {
setTimeout(() => {
fs.writeFileSync(tempFixture.aFilepath, aContent);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// And only a.js built after it was modified
expect(stats.modules[0].name).toMatch("c.js");
expect(stats.modules[0].built).toBe(false);
@ -248,7 +248,7 @@ describe("Compiler (caching)", () => {
const options = {};
const tempFixture = createTempFixture();
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
// Built the first time
expect(stats.modules[0].name).toMatch("c.js");
expect(stats.modules[0].built).toBe(true);
@ -256,7 +256,7 @@ describe("Compiler (caching)", () => {
expect(stats.modules[1].name).toMatch("a.js");
expect(stats.modules[1].built).toBe(true);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// Not built when cached the second run
expect(stats.modules[0].name).toMatch("c.js");
// expect(stats.modules[0].built).toBe(false);
@ -271,7 +271,7 @@ describe("Compiler (caching)", () => {
fs.writeFileSync(tempFixture.aFilepath, aContent);
helper.runAgain((stats, files, iteration) => {
helper.runAgain((stats, _files, _iteration) => {
// And only a.js built after it was modified
expect(stats.modules[0].name).toMatch("c.js");
// expect(stats.modules[0].built).toBe(false);

View File

@ -94,7 +94,7 @@ describe("Compiler", () => {
filename: "the/hell.js"
}
},
(stats, files) => {
(stats, _files) => {
expect(stats.logs.mkdir).toEqual(["/what", "/what/the"]);
done();
}
@ -340,7 +340,7 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
return done(new Error("Bundle should not be created on error"));
@ -430,7 +430,7 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
watching.close();
if (err) return done(err);
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
@ -453,10 +453,10 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done();
});
});
@ -474,10 +474,10 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done();
});
});
@ -495,10 +495,10 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done();
});
});
@ -516,10 +516,10 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done();
});
});
@ -540,7 +540,7 @@ describe("Compiler", () => {
() => {}
);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done();
});
});
@ -561,7 +561,7 @@ describe("Compiler", () => {
compiler.run((err, stats1) => {
if (err) return done(err);
compiler.run((err, stats2) => {
compiler.run((err, _stats2) => {
if (err) return done(err);
expect(stats1.toString({ all: true })).toBeTypeOf("string");
done();
@ -582,10 +582,10 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
watching.close(done);
});
@ -605,11 +605,11 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
watching.close(() => {
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
done();
});
@ -629,7 +629,7 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
watching.close(done);
});
@ -649,11 +649,11 @@ describe("Compiler", () => {
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
watching.close(() => {
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
done();
});
@ -677,12 +677,12 @@ describe("Compiler", () => {
compiler.hooks.afterDone.tap("RunAgainTest", () => {
if (!once) return;
once = false;
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
done();
});
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
});
});
@ -708,7 +708,7 @@ describe("Compiler", () => {
expect(doneHookCb).toHaveBeenCalled();
done();
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
runCb();
});
@ -729,7 +729,7 @@ describe("Compiler", () => {
filename: "bundle.js"
}
},
(err, stats) => {
(err, _stats) => {
if (err) return done(err);
instanceCb();
}
@ -770,7 +770,7 @@ describe("Compiler", () => {
expect(invalidateCb).toHaveBeenCalled();
watching.close(done);
});
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
watchCb();
});
@ -805,7 +805,7 @@ describe("Compiler", () => {
expect(invalidateCb).toHaveBeenCalled();
done();
});
const watch = compiler.watch({}, (err, stats) => {
const watch = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
watch.close(watchCloseCb);
});
@ -881,7 +881,7 @@ describe("Compiler", () => {
});
compiler.hooks.failed.tap("CompilerTest", failedSpy);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
expect(err).toBeTruthy();
expect(failedSpy).toHaveBeenCalledTimes(1);
expect(failedSpy).toHaveBeenCalledWith(err);
@ -956,7 +956,7 @@ describe("Compiler", () => {
plugins: [new MyPlugin()]
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
.toMatchInlineSnapshot(`
"<-> [MyPlugin] Group
@ -990,7 +990,7 @@ describe("Compiler", () => {
plugins: [new MyPlugin()]
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
.toMatchInlineSnapshot(`
"<-> [MyPlugin] Group
@ -1024,7 +1024,7 @@ describe("Compiler", () => {
plugins: [new MyPlugin()]
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(capture.toString()).toMatchInlineSnapshot('""');
done();
});
@ -1047,7 +1047,7 @@ describe("Compiler", () => {
plugins: [new MyPlugin()]
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
.toMatchInlineSnapshot(`
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>
@ -1082,7 +1082,7 @@ describe("Compiler", () => {
plugins: [new MyPlugin()]
});
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
.toMatchInlineSnapshot(`
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>

View File

@ -270,10 +270,10 @@ describe("JavascriptParser", () => {
const testParser = new JavascriptParser({});
testParser.hooks.canRename
.for("abc")
.tap("JavascriptParserTest", expr => true);
.tap("JavascriptParserTest", _expr => true);
testParser.hooks.canRename
.for("ijk")
.tap("JavascriptParserTest", expr => true);
.tap("JavascriptParserTest", _expr => true);
testParser.hooks.call.for("abc").tap("JavascriptParserTest", expr => {
if (!testParser.state.abc) testParser.state.abc = [];
testParser.state.abc.push(testParser.parseString(expr.arguments[0]));
@ -295,7 +295,7 @@ describe("JavascriptParser", () => {
});
testParser.hooks.expression
.for("fgh")
.tap("JavascriptParserTest", expr => {
.tap("JavascriptParserTest", _expr => {
if (!testParser.state.fgh) testParser.state.fgh = [];
testParser.state.fgh.push(
[...testParser.scope.definitions.asSet()].join(" ")
@ -304,7 +304,7 @@ describe("JavascriptParser", () => {
});
testParser.hooks.expression
.for("fgh.sub")
.tap("JavascriptParserTest", expr => {
.tap("JavascriptParserTest", _expr => {
if (!testParser.state.fghsub) testParser.state.fghsub = [];
testParser.state.fghsub.push(
testParser.scope.inTry ? "try" : "notry"
@ -313,7 +313,7 @@ describe("JavascriptParser", () => {
});
testParser.hooks.expression
.for("ijk.sub")
.tap("JavascriptParserTest", expr => {
.tap("JavascriptParserTest", _expr => {
if (!testParser.state.ijksub) testParser.state.ijksub = [];
testParser.state.ijksub.push("test");
return true;
@ -710,7 +710,7 @@ describe("JavascriptParser", () => {
const parser = new JavascriptParser();
parser.hooks.statement.tap("JavascriptParserTest", expr => {
parser.hooks.statement.tap("JavascriptParserTest", _expr => {
definitions = parser.scope.definitions;
return true;
});

View File

@ -26,7 +26,7 @@ const createMultiCompiler = options => {
);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.watchFileSystem = {
watch(a, b, c, d, e, f, g) {}
watch(_a, _b, _c, _d, _e, _f, _g) {}
};
return compiler;
};
@ -64,10 +64,10 @@ describe("MultiCompiler", () => {
it("should not be running twice at a time (run)", done => {
const compiler = createMultiCompiler();
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) {
compiler.close(done);
}
@ -76,10 +76,10 @@ describe("MultiCompiler", () => {
it("should not be running twice at a time (watch)", done => {
const compiler = createMultiCompiler();
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) {
compiler.close(done);
}
@ -88,10 +88,10 @@ describe("MultiCompiler", () => {
it("should not be running twice at a time (run - watch)", done => {
const compiler = createMultiCompiler();
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) {
compiler.close(done);
}
@ -100,10 +100,10 @@ describe("MultiCompiler", () => {
it("should not be running twice at a time (watch - run)", done => {
const compiler = createMultiCompiler();
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) {
compiler.close(done);
}
@ -124,7 +124,7 @@ describe("MultiCompiler", () => {
() => {}
);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) {
compiler.close(done);
}
@ -133,10 +133,10 @@ describe("MultiCompiler", () => {
it("should run again correctly after first compilation", done => {
const compiler = createMultiCompiler();
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
compiler.close(done);
});
@ -145,10 +145,10 @@ describe("MultiCompiler", () => {
it("should watch again correctly after first compilation", done => {
const compiler = createMultiCompiler();
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
compiler.close(done);
});
@ -157,11 +157,11 @@ describe("MultiCompiler", () => {
it("should run again correctly after first closed watch", done => {
const compiler = createMultiCompiler();
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
watching.close(() => {
compiler.run((err, stats) => {
compiler.run((err, _stats) => {
if (err) return done(err);
compiler.close(done);
});
@ -170,11 +170,11 @@ describe("MultiCompiler", () => {
it("should watch again correctly after first closed watch", done => {
const compiler = createMultiCompiler();
const watching = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, _stats) => {
if (err) return done(err);
});
watching.close(() => {
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
compiler.close(done);
});
@ -210,7 +210,7 @@ describe("MultiCompiler", () => {
events.push(`${c.name} done`);
});
}
compiler.run((err, stats) => {
compiler.run((_err, _stats) => {
expect(events.join(" ")).toBe(
"a run a done b run b done d run d done e run e done c run c done"
);
@ -628,7 +628,7 @@ describe("MultiCompiler", () => {
}
}
};
compiler.watch({}, (err, stats) => {
compiler.watch({}, (err, _stats) => {
if (err) return done(err);
compiler.close(done);
});

View File

@ -10,7 +10,7 @@ const captureStdio = require("./helpers/captureStdio");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
const deprecationTracking = require("./helpers/deprecationTracking");
const filterInfraStructureErrors = require("./helpers/infrastructureLogErrors");
const { TestRunner } = require("./runner");
const { TestRunner } = require("./runner/index");
const casesPath = path.join(__dirname, "cases");
let categories = fs.readdirSync(casesPath);

View File

@ -212,7 +212,7 @@ const describeCases = config => {
const compiler = webpack(options);
compiler.hooks.invalid.tap(
"WatchTestCasesTest",
(filename, mtime) => {
(filename, _mtime) => {
triggeringFilename = filename;
}
);

View File

@ -38,7 +38,7 @@ describe("WatcherEvents", () => {
let called = false;
const compiler = createSingleCompiler();
const watcher = compiler.watch({}, (err, stats) => {
const watcher = compiler.watch({}, (err, _stats) => {
expect(called).toBe(true);
done(err);
});
@ -56,7 +56,7 @@ describe("WatcherEvents", () => {
let called = false;
const compiler = createMultiCompiler();
const watcher = compiler.watch({}, (err, stats) => {
const watcher = compiler.watch({}, (err, _stats) => {
expect(called).toBe(true);
done(err);
});

View File

@ -4,7 +4,7 @@ const WebpackError = require("../lib/WebpackError");
describe("WebpackError", () => {
class CustomError extends WebpackError {
constructor(message) {
constructor() {
super();
this.name = "CustomError";

View File

@ -1,3 +1,3 @@
const supportsOptionalChaining = require("../../../helpers/supportsOptionalChaining");
module.exports = config => supportsOptionalChaining();
module.exports = () => supportsOptionalChaining();

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["test.js"];
}
};

View File

@ -10,7 +10,7 @@ module.exports = {
type: "asset",
/** @type {ParserOptionsByModuleTypeKnown['asset']} */
parser: {
dataUrlCondition: (source, { filename, module }) =>
dataUrlCondition: (source, { filename }) =>
filename.includes("?foo=bar")
}
}

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["a.js", "b.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["a.js", "b.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["main.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["main.js", "A.js", "shared.js", "B.js", "B-2.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["entry1.js", "entry2.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["entry1.js", "entry2.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle() {
return ["runtime.js", "common-index_js.js", "main.js"];
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle(i) {
return i === 0 ? "./main.js" : "./module/main.mjs";
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle(i) {
return i === 0 ? "./main.js" : "./module/main.mjs";
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle(i) {
return i === 0 ? "./main.js" : "./module/main.mjs";
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle(i) {
return i === 0 ? "./main.js" : "./module/main.mjs";
}
};

View File

@ -1,5 +1,5 @@
module.exports = {
findBundle(i, options) {
findBundle(i) {
return i === 0 ? "./main.js" : "./module/main.mjs";
}
};

View File

@ -0,0 +1 @@
export default "a";

View File

@ -0,0 +1 @@
export default "b";

View File

@ -0,0 +1 @@
export default "c";

View File

@ -0,0 +1,39 @@
async function loadModule(name) {
return import("./dir/" + name);
}
async function loadModuleWithExclude(name) {
return import(/* webpackExclude: /module-b\.js$/ */ "./dir/" + name);
}
async function loadModuleWithInclude(name) {
return import(/* webpackInclude: /module-b\.js$/ */ "./dir/" + name);
}
async function loadModuleWithMode(name) {
return import(/* webpackMode: "eager" */ "./dir/" + name);
}
it("should work when no options", async () => {
expect((await loadModule("module-a.js")).default).toBe("a");
expect((await loadModule("module-b.js")).default).toBe("b");
expect((await loadModule("module-c.js")).default).toBe("c");
});
it("should work with exclude", async () => {
expect((await loadModuleWithExclude("module-a.js")).default).toBe("a");
await expect(loadModuleWithExclude("module-b.js")).rejects.toThrow("Cannot find module './module-b.js'");
expect((await loadModuleWithExclude("module-c.js")).default).toBe("c");
});
it("should work with include", async () => {
await expect(loadModuleWithInclude("module-a.js")).rejects.toThrow("Cannot find module './module-a.js'");
expect((await loadModuleWithInclude("module-b.js")).default).toBe("b");
await expect(loadModuleWithInclude("module-c.js")).rejects.toThrow("Cannot find module './module-c.js'");
});
it("should work with mode", async () => {
expect((await loadModuleWithMode("module-a.js")).default).toBe("a");
expect((await loadModuleWithMode("module-b.js")).default).toBe("b");
expect((await loadModuleWithMode("module-c.js")).default).toBe("c");
});

View File

@ -0,0 +1,2 @@
/** @type {import("../../../../").Configuration} */
module.exports = {};

View File

@ -5,7 +5,7 @@ var webpack = require("../../../../");
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(
/context-replacement/,
/replacement/,
path.resolve(__dirname, "modules"),
{
a: "./module-b"

View File

@ -4,7 +4,7 @@ const webpack = require("../../../../");
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(
/context-replacement.a$/,
/replacement.a$/,
"new-context",
true,
/^replaced$/

View File

@ -2,7 +2,5 @@ const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(/context-replacement.b$/, /^\.\/only/)
]
plugins: [new webpack.ContextReplacementPlugin(/replacement.b$/, /^\.\/only/)]
};

View File

@ -5,7 +5,7 @@ const webpack = require("../../../../");
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(
/context-replacement.c$/,
/replacement.c$/,
path.resolve(__dirname, "modules"),
{
a: "./a",

View File

@ -13,7 +13,7 @@ module.exports = {
},
plugins: [
new webpack.ContextReplacementPlugin(
/context-replacement.d$/,
/replacement.d$/,
path.resolve(__dirname, "modules?cats=meow"),
{
a: "./a"

Some files were not shown because too many files have changed in this diff Show More