From 5a204dc8cd52f50de2ccd5f2b99b53e58605f20a Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 8 Jul 2025 17:46:17 +0300 Subject: [PATCH] chore: more eslint rules (#19667) --- eslint.config.mjs | 9 +-- lib/APIPlugin.js | 2 +- lib/Compilation.js | 8 +-- lib/Compiler.js | 2 +- lib/ConstPlugin.js | 2 +- lib/ContextModuleFactory.js | 4 +- lib/DynamicEntryPlugin.js | 2 +- lib/EvalDevToolModulePlugin.js | 2 +- lib/ExternalModule.js | 2 +- lib/FileSystemInfo.js | 6 +- lib/MultiCompiler.js | 2 +- lib/ProgressPlugin.js | 2 +- lib/RuntimePlugin.js | 8 +-- lib/cache/PackFileCacheStrategy.js | 4 +- .../HoistContainerReferencesPlugin.js | 2 +- lib/container/RemoteModule.js | 2 +- lib/css/walkCssTokens.js | 5 +- lib/debug/ProfilingPlugin.js | 4 +- lib/dependencies/AMDPlugin.js | 4 +- lib/dependencies/CachedConstDependency.js | 6 +- .../CommonJsFullRequireDependency.js | 10 +-- lib/dependencies/CommonJsPlugin.js | 4 +- lib/dependencies/ImportParserPlugin.js | 10 +-- lib/dependencies/SystemPlugin.js | 2 +- lib/dependencies/WorkerPlugin.js | 16 +++-- lib/esm/ModuleChunkFormatPlugin.js | 27 ++++---- lib/ids/NaturalModuleIdsPlugin.js | 2 +- lib/javascript/JavascriptModulesPlugin.js | 4 +- lib/javascript/JavascriptParser.js | 8 +-- lib/optimize/InnerGraphPlugin.js | 4 +- lib/optimize/SplitChunksPlugin.js | 4 +- lib/rules/BasicEffectRulePlugin.js | 2 +- lib/schemes/FileUriPlugin.js | 2 +- lib/schemes/HttpUriPlugin.js | 3 +- lib/serialization/FileMiddleware.js | 2 +- lib/sharing/ConsumeSharedModule.js | 2 +- lib/sharing/ProvideSharedModule.js | 2 +- lib/stats/DefaultStatsFactoryPlugin.js | 12 ++-- lib/stats/DefaultStatsPresetPlugin.js | 2 +- lib/stats/DefaultStatsPrinterPlugin.js | 8 +-- package.json | 2 +- setup/setup.js | 2 +- test/Compiler-caching.test.js | 24 +++---- test/Compiler.test.js | 64 +++++++++---------- test/JavascriptParser.unittest.js | 12 ++-- test/MultiCompiler.test.js | 40 ++++++------ test/TestCases.template.js | 2 +- test/WatchTestCases.template.js | 2 +- test/WatcherEvents.test.js | 4 +- test/WebpackError.unittest.js | 2 +- .../parsing/optional-chaining/test.filter.js | 2 +- .../asset-modules/only-entry/test.config.js | 2 +- .../webpack.config.js | 2 +- .../chunk-graph/issue-17989/test.config.js | 2 +- .../chunk-graph/issue-9634/test.config.js | 2 +- .../chunk-graph/rewalk-chunk/test.config.js | 2 +- .../chunk-index/issue-18008/test.config.js | 2 +- .../order-multiple-entries/test.config.js | 2 +- .../load-chunk-function/test.config.js | 2 +- .../split-chunk-entry-module/test.config.js | 2 +- .../container/0-container-full/test.config.js | 2 +- .../container/1-container-full/test.config.js | 2 +- .../test.config.js | 2 +- .../reference-hoisting/test.config.js | 2 +- .../track-initial-chunks/test.config.js | 2 +- .../context-options/dir/module-a.js | 1 + .../context-options/dir/module-b.js | 1 + .../context-options/dir/module-c.js | 1 + .../context-modules/context-options/index.js | 39 +++++++++++ .../context-options/webpack.config.js | 2 + .../exclusion}/index.js | 0 .../some-dir/check-here/check-here/file.js | 0 .../check-here/dont-check-here/file.js | 0 .../exclusion}/some-dir/check-here/file.js | 0 .../some-dir/dont-check-here/file.js | 0 .../exclusion}/some-dir/dont.js | 0 .../exclusion}/some-dir/file.js | 0 .../exclusion}/webpack.config.js | 0 .../replacement-System.import}/index.js | 0 .../modules/module-b.js | 0 .../webpack.config.js | 2 +- .../replacement-a}/index.js | 0 .../new-context/node_modules/error.js | 0 .../new-context/node_modules/replaced.js | 0 .../replacement-a}/webpack.config.js | 2 +- .../replacement-b}/error.js | 0 .../replacement-b}/index.js | 0 .../replacement-b}/only-this.js | 0 .../replacement-b}/webpack.config.js | 4 +- .../replacement-c}/index.js | 0 .../replacement-c}/modules/a.js | 0 .../replacement-c}/modules/module-b.js | 0 .../replacement-c}/node_modules/d.js | 0 .../replacement-c}/webpack.config.js | 2 +- .../replacement-d}/index.js | 0 .../replacement-d}/modules/a.js | 0 .../replacement-d}/queryloader.js | 0 .../replacement-d}/webpack.config.js | 2 +- .../replacement-e}/index.js | 0 .../new-context/modules/error.js | 0 .../new-context/modules/replaced.js | 0 .../replacement-e}/webpack.config.js | 2 +- .../replacement-f}/folder/a.js | 0 .../replacement-f}/folder/nested/error.js | 0 .../replacement-f}/index.js | 0 .../replacement-f}/webpack.config.js | 0 .../css/basic-dynamic-only/test.config.js | 2 +- .../css/basic-web-async/test.config.js | 2 +- test/configCases/css/basic/test.config.js | 2 +- .../css/conflicting-order/test.config.js | 2 +- .../css-modules-no-space/webpack.config.js | 4 +- .../css/css-modules/test.config.js | 2 +- .../css/escape-unescape/test.config.js | 2 +- .../css/exports-convention/test.config.js | 2 +- .../test.config.js | 2 +- test/configCases/css/external/test.config.js | 2 +- .../css/local-ident-name/test.config.js | 2 +- .../css/pseudo-import/test.config.js | 2 +- .../css/runtime-issue/test.config.js | 2 +- .../test.config.js | 2 +- .../chunk-and-module/webpack.config.js | 2 +- .../entry/no-chunking/test.config.js | 2 +- .../generator-generate-error/test.config.js | 2 +- .../externals-in-commons-chunk/test.config.js | 2 +- .../externals/module-import/test.config.js | 2 +- .../externals/module-import/webpack.config.js | 5 +- .../filename-function/test.config.js | 2 +- .../graph/issue-11770/test.config.js | 2 +- .../graph/issue-11856/test.config.js | 2 +- .../graph/issue-11863/test.config.js | 2 +- .../issues/issue-3596/webpack.config.js | 2 +- .../library/issue-18951/test.config.js | 2 +- .../test.config.js | 2 +- .../module/iife-innter-strict/test.config.js | 2 +- .../test.config.js | 2 +- .../module/issue-16040/test.config.js | 2 +- .../test.config.js | 2 +- .../configCases/output/charset/test.config.js | 2 +- .../banner-plugin-hashing/test.config.js | 2 +- .../limit-chunk-count-plugin/test.config.js | 2 +- .../mini-css-extract-plugin/test.config.js | 2 +- .../webpack.config.js | 2 +- .../virtual-url-plugin/webpack.config.js | 2 +- .../prefer-absolute/webpack.config.js | 2 +- .../resolving/prefer-root/webpack.config.js | 2 +- .../test.config.js | 2 +- .../test.config.js | 2 +- .../test.config.js | 2 +- .../correct-order/test.config.js | 2 +- .../extract-async-from-entry/test.config.js | 2 +- .../hot-multi/test.config.js | 2 +- .../split-chunks-common/hot/test.config.js | 2 +- .../inverted-order/test.config.js | 2 +- .../issue-12128/test.config.js | 2 +- .../library/test.config.js | 2 +- .../move-entry/test.config.js | 2 +- .../move-to-grandparent/test.config.js | 2 +- .../split-chunks-common/simple/test.config.js | 2 +- .../split-chunks/asnyc-entries/test.config.js | 2 +- .../test.config.js | 2 +- .../chunk-filename-delimiter/test.config.js | 2 +- .../custom-filename-function/test.config.js | 2 +- .../test.config.js | 2 +- .../custom-filename/test.config.js | 2 +- .../entry-point-error/test.config.js | 2 +- .../split-chunks/issue-11513/test.config.js | 2 +- .../split-chunks/issue-17332/test.config.js | 2 +- .../split-chunks/issue-8908/test.config.js | 2 +- .../split-chunks/issue-9491/test.config.js | 2 +- .../max-size-casing/test.config.js | 2 +- .../module-type-filter/test.config.js | 2 +- .../move-to-entrypoint/test.config.js | 2 +- .../split-chunks/no-name/test.config.js | 2 +- .../split-chunks/no-options/test.config.js | 2 +- .../reuse-chunk-name/test.config.js | 2 +- .../runtime-chunk-async-node/test.config.js | 2 +- .../runtime-chunk-node-13130/test.config.js | 2 +- .../runtime-chunk-node/test.config.js | 2 +- .../split-chunks/runtime-chunk/test.config.js | 2 +- .../vendor-only-entrypoint/test.config.js | 2 +- .../chunk-loading-per-entry/test.config.js | 2 +- .../trusted-types/web-worker/test.config.js | 2 +- .../umd/issue-15545/test.config.js | 2 +- test/configCases/wasm/fetch/test.config.js | 2 +- .../test.config.js | 2 +- .../non-js-chunks-entrypoint/test.config.js | 2 +- .../web/preexecuted-chunk/test.config.js | 2 +- .../web/prefetch-split-chunks/test.config.js | 2 +- .../web/unique-jsonp/test.config.js | 2 +- .../worker/custom-worker/test.config.js | 2 +- .../worker/node-worker-esm/test.config.js | 1 - .../worker/node-worker-hmr/test.config.js | 2 +- .../worker/node-worker-named/test.config.js | 2 +- .../worker/node-worker/test.config.js | 2 +- .../worker/self-import/test.config.js | 2 +- .../worker/universal/test.config.js | 2 +- .../worker/web-worker/test.config.js | 2 +- .../worker/worker-contenthash/test.config.js | 2 +- test/helpers/FakeDocument.js | 2 +- test/helpers/deprecationTracking.js | 5 +- .../css/single-css-entry/webpack.config.js | 2 +- .../move-between-runtime/test.filter.js | 2 +- .../unsafe-cache-duplicates/webpack.config.js | 2 +- .../webpack.config.js | 4 +- tooling/print-cache-file.js | 2 +- tsconfig.types.test.json | 3 +- yarn.lock | 11 ++-- 207 files changed, 346 insertions(+), 321 deletions(-) create mode 100644 test/configCases/context-modules/context-options/dir/module-a.js create mode 100644 test/configCases/context-modules/context-options/dir/module-b.js create mode 100644 test/configCases/context-modules/context-options/dir/module-c.js create mode 100644 test/configCases/context-modules/context-options/index.js create mode 100644 test/configCases/context-modules/context-options/webpack.config.js rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/index.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/check-here/check-here/file.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/check-here/dont-check-here/file.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/check-here/file.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/dont-check-here/file.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/dont.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/some-dir/file.js (100%) rename test/configCases/{context-exclusion/simple => context-modules/exclusion}/webpack.config.js (100%) rename test/configCases/{context-replacement/System.import => context-modules/replacement-System.import}/index.js (100%) rename test/configCases/{context-replacement/System.import => context-modules/replacement-System.import}/modules/module-b.js (100%) rename test/configCases/{context-replacement/System.import => context-modules/replacement-System.import}/webpack.config.js (91%) rename test/configCases/{context-replacement/a => context-modules/replacement-a}/index.js (100%) rename test/configCases/{context-replacement/a => context-modules/replacement-a}/new-context/node_modules/error.js (100%) rename test/configCases/{context-replacement/a => context-modules/replacement-a}/new-context/node_modules/replaced.js (100%) rename test/configCases/{context-replacement/a => context-modules/replacement-a}/webpack.config.js (88%) rename test/configCases/{context-replacement/b => context-modules/replacement-b}/error.js (100%) rename test/configCases/{context-replacement/b => context-modules/replacement-b}/index.js (100%) rename test/configCases/{context-replacement/b => context-modules/replacement-b}/only-this.js (100%) rename test/configCases/{context-replacement/b => context-modules/replacement-b}/webpack.config.js (55%) rename test/configCases/{context-replacement/c => context-modules/replacement-c}/index.js (100%) rename test/configCases/{context-replacement/c => context-modules/replacement-c}/modules/a.js (100%) rename test/configCases/{context-replacement/c => context-modules/replacement-c}/modules/module-b.js (100%) rename test/configCases/{context-replacement/c => context-modules/replacement-c}/node_modules/d.js (100%) rename test/configCases/{context-replacement/c => context-modules/replacement-c}/webpack.config.js (92%) rename test/configCases/{context-replacement/d => context-modules/replacement-d}/index.js (100%) rename test/configCases/{context-replacement/d => context-modules/replacement-d}/modules/a.js (100%) rename test/configCases/{context-replacement/d => context-modules/replacement-d}/queryloader.js (100%) rename test/configCases/{context-replacement/d => context-modules/replacement-d}/webpack.config.js (92%) rename test/configCases/{context-replacement/e => context-modules/replacement-e}/index.js (100%) rename test/configCases/{context-replacement/e => context-modules/replacement-e}/new-context/modules/error.js (100%) rename test/configCases/{context-replacement/e => context-modules/replacement-e}/new-context/modules/replaced.js (100%) rename test/configCases/{context-replacement/e => context-modules/replacement-e}/webpack.config.js (92%) rename test/configCases/{context-replacement/f => context-modules/replacement-f}/folder/a.js (100%) rename test/configCases/{context-replacement/f => context-modules/replacement-f}/folder/nested/error.js (100%) rename test/configCases/{context-replacement/f => context-modules/replacement-f}/index.js (100%) rename test/configCases/{context-replacement/f => context-modules/replacement-f}/webpack.config.js (100%) diff --git a/eslint.config.mjs b/eslint.config.mjs index 418e3e854..b8d0a370c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -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", diff --git a/lib/APIPlugin.js b/lib/APIPlugin.js index d51fb7a1e..b8978e337 100644 --- a/lib/APIPlugin.js +++ b/lib/APIPlugin.js @@ -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; }); diff --git a/lib/Compilation.js b/lib/Compilation.js index b8f83d59e..20dca8e71 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -683,7 +683,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si { name, /** @type {AsyncSeriesHook["intercept"]} */ - intercept(interceptor) { + intercept(_interceptor) { throw new Error(errorMessage("it's using 'intercept'")); }, /** @type {AsyncSeriesHook["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" ) diff --git a/lib/Compiler.js b/lib/Compiler.js index 24a72571c..fb509a8dc 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -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; diff --git a/lib/ConstPlugin.js b/lib/ConstPlugin.js index d79fa0215..04cca9430 100644 --- a/lib/ConstPlugin.js +++ b/lib/ConstPlugin.js @@ -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); diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index 003598467..77a7bf591 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -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 = { diff --git a/lib/DynamicEntryPlugin.js b/lib/DynamicEntryPlugin.js index eb2386dd2..796005420 100644 --- a/lib/DynamicEntryPlugin.js +++ b/lib/DynamicEntryPlugin.js @@ -80,7 +80,7 @@ class DynamicEntryPlugin { } return Promise.all(promises); }) - .then(x => {}) + .then(() => {}) ); } } diff --git a/lib/EvalDevToolModulePlugin.js b/lib/EvalDevToolModulePlugin.js index b9b402a1f..bde4bb646 100644 --- a/lib/EvalDevToolModulePlugin.js +++ b/lib/EvalDevToolModulePlugin.js @@ -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); } ); diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index 488fe1876..64f60eb73 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -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": diff --git a/lib/FileSystemInfo.js b/lib/FileSystemInfo.js index 3cb447e31..f295078b6 100644 --- a/lib/FileSystemInfo.js +++ b/lib/FileSystemInfo.js @@ -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` + diff --git a/lib/MultiCompiler.js b/lib/MultiCompiler.js index 5b8a6597d..effd4df63 100644 --- a/lib/MultiCompiler.js +++ b/lib/MultiCompiler.js @@ -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(); }, diff --git a/lib/ProgressPlugin.js b/lib/ProgressPlugin.js index 4b82f61a2..b5add53eb 100644 --- a/lib/ProgressPlugin.js +++ b/lib/ProgressPlugin.js @@ -415,7 +415,7 @@ class ProgressPlugin { } return data; }, - err => { + _err => { // Ignore error } ); diff --git a/lib/RuntimePlugin.js b/lib/RuntimePlugin.js index 462df520d..d4eeb5b86 100644 --- a/lib/RuntimePlugin.js +++ b/lib/RuntimePlugin.js @@ -363,7 +363,7 @@ class RuntimePlugin { "javascript", "javascript update", RuntimeGlobals.getChunkUpdateScriptFilename, - c => + _chunk => /** @type {NonNullable} */ (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() || diff --git a/lib/cache/PackFileCacheStrategy.js b/lib/cache/PackFileCacheStrategy.js index 57f1375e0..29bcf18e5 100644 --- a/lib/cache/PackFileCacheStrategy.js +++ b/lib/cache/PackFileCacheStrategy.js @@ -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) => { diff --git a/lib/container/HoistContainerReferencesPlugin.js b/lib/container/HoistContainerReferencesPlugin.js index 3435c98ef..669dcccdd 100644 --- a/lib/container/HoistContainerReferencesPlugin.js +++ b/lib/container/HoistContainerReferencesPlugin.js @@ -56,7 +56,7 @@ class HoistContainerReferences { // advanced stage is where SplitChunksPlugin runs. stage: STAGE_ADVANCED + 1 }, - chunks => { + _chunks => { this.hoistModulesInChunks( compilation, depsToTrace, diff --git a/lib/container/RemoteModule.js b/lib/container/RemoteModule.js index 9ff13fcfc..41b77701e 100644 --- a/lib/container/RemoteModule.js +++ b/lib/container/RemoteModule.js @@ -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(); diff --git a/lib/css/walkCssTokens.js b/lib/css/walkCssTokens.js index 4fb7808c3..f6b8b042b 100644 --- a/lib/css/walkCssTokens.js +++ b/lib/css/walkCssTokens.js @@ -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; diff --git a/lib/debug/ProfilingPlugin.js b/lib/debug/ProfilingPlugin.js index c28d3bc1c..7a0f64821 100644 --- a/lib/debug/ProfilingPlugin.js +++ b/lib/debug/ProfilingPlugin.js @@ -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"); }); } diff --git a/lib/dependencies/AMDPlugin.js b/lib/dependencies/AMDPlugin.js index 29ebc30ed..9c8a12f6a 100644 --- a/lib/dependencies/AMDPlugin.js +++ b/lib/dependencies/AMDPlugin.js @@ -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) diff --git a/lib/dependencies/CachedConstDependency.js b/lib/dependencies/CachedConstDependency.js index 913904abc..01c0371ed 100644 --- a/lib/dependencies/CachedConstDependency.js +++ b/lib/dependencies/CachedConstDependency.js @@ -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( diff --git a/lib/dependencies/CommonJsFullRequireDependency.js b/lib/dependencies/CommonJsFullRequireDependency.js index 1164eee15..98b3b4cb1 100644 --- a/lib/dependencies/CommonJsFullRequireDependency.js +++ b/lib/dependencies/CommonJsFullRequireDependency.js @@ -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; diff --git a/lib/dependencies/CommonJsPlugin.js b/lib/dependencies/CommonJsPlugin.js index 1f5e28484..97b869587 100644 --- a/lib/dependencies/CommonJsPlugin.js +++ b/lib/dependencies/CommonJsPlugin.js @@ -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() diff --git a/lib/dependencies/ImportParserPlugin.js b/lib/dependencies/ImportParserPlugin.js index 7c28451ed..b41e43dd6 100644 --- a/lib/dependencies/ImportParserPlugin.js +++ b/lib/dependencies/ImportParserPlugin.js @@ -346,11 +346,11 @@ class ImportParserPlugin { include, exclude, mode, - namespaceObject: /** @type {BuildMeta} */ ( - parser.state.module.buildMeta - ).strictHarmonyModule - ? "strict" - : true, + namespaceObject: + /** @type {BuildMeta} */ + (parser.state.module.buildMeta).strictHarmonyModule + ? "strict" + : true, typePrefix: "import()", category: "esm", referencedExports: exports, diff --git a/lib/dependencies/SystemPlugin.js b/lib/dependencies/SystemPlugin.js index 367020d64..b0e09fd1b 100644 --- a/lib/dependencies/SystemPlugin.js +++ b/lib/dependencies/SystemPlugin.js @@ -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()); }); diff --git a/lib/dependencies/WorkerPlugin.js b/lib/dependencies/WorkerPlugin.js index cd0333548..8aea2db26 100644 --- a/lib/dependencies/WorkerPlugin.js +++ b/lib/dependencies/WorkerPlugin.js @@ -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.tagVariable(decl.id.name, WorkerSpecifierTag); - return true; + 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; diff --git a/lib/esm/ModuleChunkFormatPlugin.js b/lib/esm/ModuleChunkFormatPlugin.js index 5aea546d6..61c18ed15 100644 --- a/lib/esm/ModuleChunkFormatPlugin.js +++ b/lib/esm/ModuleChunkFormatPlugin.js @@ -287,22 +287,19 @@ class ModuleChunkFormatPlugin { } return source; }); - hooks.chunkHash.tap( - PLUGIN_NAME, - (chunk, hash, { chunkGraph, runtimeTemplate }) => { - if (chunk.hasRuntime()) return; - const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph); - hash.update(PLUGIN_NAME); - hash.update("1"); - if (runtimeChunk && runtimeChunk.hash) { - // Any change to runtimeChunk should trigger a hash update, - // we shouldn't depend on or inspect its internal implementation. - // import __webpack_require__ from "./runtime-main.e9400aee33633a3973bd.js"; - hash.update(runtimeChunk.hash); - } - updateHashForEntryStartup(hash, chunkGraph, entries, chunk); + hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, { chunkGraph }) => { + if (chunk.hasRuntime()) return; + const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph); + hash.update(PLUGIN_NAME); + hash.update("1"); + if (runtimeChunk && runtimeChunk.hash) { + // Any change to runtimeChunk should trigger a hash update, + // we shouldn't depend on or inspect its internal implementation. + // import __webpack_require__ from "./runtime-main.e9400aee33633a3973bd.js"; + hash.update(runtimeChunk.hash); } - ); + updateHashForEntryStartup(hash, chunkGraph, entries, chunk); + }); }); } } diff --git a/lib/ids/NaturalModuleIdsPlugin.js b/lib/ids/NaturalModuleIdsPlugin.js index e12b69b61..8dc9ae473 100644 --- a/lib/ids/NaturalModuleIdsPlugin.js +++ b/lib/ids/NaturalModuleIdsPlugin.js @@ -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( diff --git a/lib/javascript/JavascriptModulesPlugin.js b/lib/javascript/JavascriptModulesPlugin.js index d58f7003d..81ce7b8cf 100644 --- a/lib/javascript/JavascriptModulesPlugin.js +++ b/lib/javascript/JavascriptModulesPlugin.js @@ -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}`; } diff --git a/lib/javascript/JavascriptParser.js b/lib/javascript/JavascriptParser.js index eb504e0a0..98c00d34d 100644 --- a/lib/javascript/JavascriptParser.js +++ b/lib/javascript/JavascriptParser.js @@ -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); } diff --git a/lib/optimize/InnerGraphPlugin.js b/lib/optimize/InnerGraphPlugin.js index 168f5bf4d..0b70503d9 100644 --- a/lib/optimize/InnerGraphPlugin.js +++ b/lib/optimize/InnerGraphPlugin.js @@ -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); diff --git a/lib/optimize/SplitChunksPlugin.js b/lib/optimize/SplitChunksPlugin.js index 321cb423d..08512518c 100644 --- a/lib/optimize/SplitChunksPlugin.js +++ b/lib/optimize/SplitChunksPlugin.js @@ -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 diff --git a/lib/rules/BasicEffectRulePlugin.js b/lib/rules/BasicEffectRulePlugin.js index 3e7ca5f87..c7ab48b57 100644 --- a/lib/rules/BasicEffectRulePlugin.js +++ b/lib/rules/BasicEffectRulePlugin.js @@ -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); diff --git a/lib/schemes/FileUriPlugin.js b/lib/schemes/FileUriPlugin.js index 26758ac6e..e870e1b6b 100644 --- a/lib/schemes/FileUriPlugin.js +++ b/lib/schemes/FileUriPlugin.js @@ -5,7 +5,7 @@ "use strict"; -const { URL, fileURLToPath } = require("url"); +const { fileURLToPath } = require("url"); const { NormalModule } = require(".."); /** @typedef {import("../Compiler")} Compiler */ diff --git a/lib/schemes/HttpUriPlugin.js b/lib/schemes/HttpUriPlugin.js index 01b0ed337..0dad3db3d 100644 --- a/lib/schemes/HttpUriPlugin.js +++ b/lib/schemes/HttpUriPlugin.js @@ -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) => { diff --git a/lib/serialization/FileMiddleware.js b/lib/serialization/FileMiddleware.js index 1b24bc992..41b7da483 100644 --- a/lib/serialization/FileMiddleware.js +++ b/lib/serialization/FileMiddleware.js @@ -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(); }); } diff --git a/lib/sharing/ConsumeSharedModule.js b/lib/sharing/ConsumeSharedModule.js index 20f8fda1e..7e14b716b 100644 --- a/lib/sharing/ConsumeSharedModule.js +++ b/lib/sharing/ConsumeSharedModule.js @@ -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, diff --git a/lib/sharing/ProvideSharedModule.js b/lib/sharing/ProvideSharedModule.js index 1e67f79f4..e4c83e6c9 100644 --- a/lib/sharing/ProvideSharedModule.js +++ b/lib/sharing/ProvideSharedModule.js @@ -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" diff --git a/lib/stats/DefaultStatsFactoryPlugin.js b/lib/stats/DefaultStatsFactoryPlugin.js index e51a1248f..dce67f1da 100644 --- a/lib/stats/DefaultStatsFactoryPlugin.js +++ b/lib/stats/DefaultStatsFactoryPlugin.js @@ -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} */ const parents = new Set(); /** @type {Set} */ @@ -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 */ diff --git a/lib/stats/DefaultStatsPresetPlugin.js b/lib/stats/DefaultStatsPresetPlugin.js index 96b26d74d..02e4c3dad 100644 --- a/lib/stats/DefaultStatsPresetPlugin.js +++ b/lib/stats/DefaultStatsPresetPlugin.js @@ -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); }); } diff --git a/lib/stats/DefaultStatsPrinterPlugin.js b/lib/stats/DefaultStatsPrinterPlugin.js index 9ffbd6a1b..accddc5d2 100644 --- a/lib/stats/DefaultStatsPrinterPlugin.js +++ b/lib/stats/DefaultStatsPrinterPlugin.js @@ -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); }); } diff --git a/package.json b/package.json index 7289918c9..1c11d9bff 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/setup/setup.js b/setup/setup.js index d109aaf77..83373e617 100644 --- a/setup/setup.js +++ b/setup/setup.js @@ -43,7 +43,7 @@ async function runSetupSymlinkAsync() { * @returns {Promise} result */ function checkSymlinkExistsAsync() { - return new Promise((resolve, reject) => { + return new Promise(resolve => { if ( fs.existsSync(nodeModulesFolder) && fs.existsSync(webpackDependencyFolder) && diff --git a/test/Compiler-caching.test.js b/test/Compiler-caching.test.js index e30346d8c..69f0a9986 100644 --- a/test/Compiler-caching.test.js +++ b/test/Compiler-caching.test.js @@ -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); diff --git a/test/Compiler.test.js b/test/Compiler.test.js index 161879602..7eabfa723 100644 --- a/test/Compiler.test.js +++ b/test/Compiler.test.js @@ -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(` "<-> [MyPlugin] Group @@ -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(` "<-> [MyPlugin] Group diff --git a/test/JavascriptParser.unittest.js b/test/JavascriptParser.unittest.js index 09d19918c..c34c545cd 100644 --- a/test/JavascriptParser.unittest.js +++ b/test/JavascriptParser.unittest.js @@ -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; }); diff --git a/test/MultiCompiler.test.js b/test/MultiCompiler.test.js index 403d0dfc8..3571d6cea 100644 --- a/test/MultiCompiler.test.js +++ b/test/MultiCompiler.test.js @@ -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); }); diff --git a/test/TestCases.template.js b/test/TestCases.template.js index e4b52f7f4..f035711c5 100644 --- a/test/TestCases.template.js +++ b/test/TestCases.template.js @@ -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); diff --git a/test/WatchTestCases.template.js b/test/WatchTestCases.template.js index 16736a9e4..e48843c60 100644 --- a/test/WatchTestCases.template.js +++ b/test/WatchTestCases.template.js @@ -212,7 +212,7 @@ const describeCases = config => { const compiler = webpack(options); compiler.hooks.invalid.tap( "WatchTestCasesTest", - (filename, mtime) => { + (filename, _mtime) => { triggeringFilename = filename; } ); diff --git a/test/WatcherEvents.test.js b/test/WatcherEvents.test.js index 3d0230743..2db8e930b 100644 --- a/test/WatcherEvents.test.js +++ b/test/WatcherEvents.test.js @@ -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); }); diff --git a/test/WebpackError.unittest.js b/test/WebpackError.unittest.js index 19e59b593..7c38588f0 100644 --- a/test/WebpackError.unittest.js +++ b/test/WebpackError.unittest.js @@ -4,7 +4,7 @@ const WebpackError = require("../lib/WebpackError"); describe("WebpackError", () => { class CustomError extends WebpackError { - constructor(message) { + constructor() { super(); this.name = "CustomError"; diff --git a/test/cases/parsing/optional-chaining/test.filter.js b/test/cases/parsing/optional-chaining/test.filter.js index e54f5d848..9486c09cf 100644 --- a/test/cases/parsing/optional-chaining/test.filter.js +++ b/test/cases/parsing/optional-chaining/test.filter.js @@ -1,3 +1,3 @@ const supportsOptionalChaining = require("../../../helpers/supportsOptionalChaining"); -module.exports = config => supportsOptionalChaining(); +module.exports = () => supportsOptionalChaining(); diff --git a/test/configCases/asset-modules/only-entry/test.config.js b/test/configCases/asset-modules/only-entry/test.config.js index 32f4be1d4..f48f8b79d 100644 --- a/test/configCases/asset-modules/only-entry/test.config.js +++ b/test/configCases/asset-modules/only-entry/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["test.js"]; } }; diff --git a/test/configCases/asset-modules/query-and-custom-condition/webpack.config.js b/test/configCases/asset-modules/query-and-custom-condition/webpack.config.js index a9a1dbbfb..96dfc3ba9 100644 --- a/test/configCases/asset-modules/query-and-custom-condition/webpack.config.js +++ b/test/configCases/asset-modules/query-and-custom-condition/webpack.config.js @@ -10,7 +10,7 @@ module.exports = { type: "asset", /** @type {ParserOptionsByModuleTypeKnown['asset']} */ parser: { - dataUrlCondition: (source, { filename, module }) => + dataUrlCondition: (source, { filename }) => filename.includes("?foo=bar") } } diff --git a/test/configCases/chunk-graph/issue-17989/test.config.js b/test/configCases/chunk-graph/issue-17989/test.config.js index fa813148f..e03ba4e84 100644 --- a/test/configCases/chunk-graph/issue-17989/test.config.js +++ b/test/configCases/chunk-graph/issue-17989/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js", "b.js"]; } }; diff --git a/test/configCases/chunk-graph/issue-9634/test.config.js b/test/configCases/chunk-graph/issue-9634/test.config.js index fa813148f..e03ba4e84 100644 --- a/test/configCases/chunk-graph/issue-9634/test.config.js +++ b/test/configCases/chunk-graph/issue-9634/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js", "b.js"]; } }; diff --git a/test/configCases/chunk-graph/rewalk-chunk/test.config.js b/test/configCases/chunk-graph/rewalk-chunk/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/chunk-graph/rewalk-chunk/test.config.js +++ b/test/configCases/chunk-graph/rewalk-chunk/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/chunk-index/issue-18008/test.config.js b/test/configCases/chunk-index/issue-18008/test.config.js index 527794589..4e1620b10 100644 --- a/test/configCases/chunk-index/issue-18008/test.config.js +++ b/test/configCases/chunk-index/issue-18008/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js", "A.js", "shared.js", "B.js", "B-2.js"]; } }; diff --git a/test/configCases/chunk-index/order-multiple-entries/test.config.js b/test/configCases/chunk-index/order-multiple-entries/test.config.js index 76c7ddf80..e4c2d7d4b 100644 --- a/test/configCases/chunk-index/order-multiple-entries/test.config.js +++ b/test/configCases/chunk-index/order-multiple-entries/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["entry1.js", "entry2.js"]; } }; diff --git a/test/configCases/concatenate-modules/load-chunk-function/test.config.js b/test/configCases/concatenate-modules/load-chunk-function/test.config.js index 76c7ddf80..e4c2d7d4b 100644 --- a/test/configCases/concatenate-modules/load-chunk-function/test.config.js +++ b/test/configCases/concatenate-modules/load-chunk-function/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["entry1.js", "entry2.js"]; } }; diff --git a/test/configCases/concatenate-modules/split-chunk-entry-module/test.config.js b/test/configCases/concatenate-modules/split-chunk-entry-module/test.config.js index 6f8ffeaa3..ed54956ea 100644 --- a/test/configCases/concatenate-modules/split-chunk-entry-module/test.config.js +++ b/test/configCases/concatenate-modules/split-chunk-entry-module/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime.js", "common-index_js.js", "main.js"]; } }; diff --git a/test/configCases/container/0-container-full/test.config.js b/test/configCases/container/0-container-full/test.config.js index 0755f427d..acc7d2091 100644 --- a/test/configCases/container/0-container-full/test.config.js +++ b/test/configCases/container/0-container-full/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./main.js" : "./module/main.mjs"; } }; diff --git a/test/configCases/container/1-container-full/test.config.js b/test/configCases/container/1-container-full/test.config.js index 0755f427d..acc7d2091 100644 --- a/test/configCases/container/1-container-full/test.config.js +++ b/test/configCases/container/1-container-full/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./main.js" : "./module/main.mjs"; } }; diff --git a/test/configCases/container/module-federation-with-shareScope/test.config.js b/test/configCases/container/module-federation-with-shareScope/test.config.js index 0755f427d..acc7d2091 100644 --- a/test/configCases/container/module-federation-with-shareScope/test.config.js +++ b/test/configCases/container/module-federation-with-shareScope/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./main.js" : "./module/main.mjs"; } }; diff --git a/test/configCases/container/reference-hoisting/test.config.js b/test/configCases/container/reference-hoisting/test.config.js index 0755f427d..acc7d2091 100644 --- a/test/configCases/container/reference-hoisting/test.config.js +++ b/test/configCases/container/reference-hoisting/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./main.js" : "./module/main.mjs"; } }; diff --git a/test/configCases/container/track-initial-chunks/test.config.js b/test/configCases/container/track-initial-chunks/test.config.js index 0755f427d..acc7d2091 100644 --- a/test/configCases/container/track-initial-chunks/test.config.js +++ b/test/configCases/container/track-initial-chunks/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./main.js" : "./module/main.mjs"; } }; diff --git a/test/configCases/context-modules/context-options/dir/module-a.js b/test/configCases/context-modules/context-options/dir/module-a.js new file mode 100644 index 000000000..e94fef185 --- /dev/null +++ b/test/configCases/context-modules/context-options/dir/module-a.js @@ -0,0 +1 @@ +export default "a"; diff --git a/test/configCases/context-modules/context-options/dir/module-b.js b/test/configCases/context-modules/context-options/dir/module-b.js new file mode 100644 index 000000000..eff703ff4 --- /dev/null +++ b/test/configCases/context-modules/context-options/dir/module-b.js @@ -0,0 +1 @@ +export default "b"; diff --git a/test/configCases/context-modules/context-options/dir/module-c.js b/test/configCases/context-modules/context-options/dir/module-c.js new file mode 100644 index 000000000..5d50db5bc --- /dev/null +++ b/test/configCases/context-modules/context-options/dir/module-c.js @@ -0,0 +1 @@ +export default "c"; diff --git a/test/configCases/context-modules/context-options/index.js b/test/configCases/context-modules/context-options/index.js new file mode 100644 index 000000000..699ea3632 --- /dev/null +++ b/test/configCases/context-modules/context-options/index.js @@ -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"); +}); diff --git a/test/configCases/context-modules/context-options/webpack.config.js b/test/configCases/context-modules/context-options/webpack.config.js new file mode 100644 index 000000000..3583b70a3 --- /dev/null +++ b/test/configCases/context-modules/context-options/webpack.config.js @@ -0,0 +1,2 @@ +/** @type {import("../../../../").Configuration} */ +module.exports = {}; diff --git a/test/configCases/context-exclusion/simple/index.js b/test/configCases/context-modules/exclusion/index.js similarity index 100% rename from test/configCases/context-exclusion/simple/index.js rename to test/configCases/context-modules/exclusion/index.js diff --git a/test/configCases/context-exclusion/simple/some-dir/check-here/check-here/file.js b/test/configCases/context-modules/exclusion/some-dir/check-here/check-here/file.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/check-here/check-here/file.js rename to test/configCases/context-modules/exclusion/some-dir/check-here/check-here/file.js diff --git a/test/configCases/context-exclusion/simple/some-dir/check-here/dont-check-here/file.js b/test/configCases/context-modules/exclusion/some-dir/check-here/dont-check-here/file.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/check-here/dont-check-here/file.js rename to test/configCases/context-modules/exclusion/some-dir/check-here/dont-check-here/file.js diff --git a/test/configCases/context-exclusion/simple/some-dir/check-here/file.js b/test/configCases/context-modules/exclusion/some-dir/check-here/file.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/check-here/file.js rename to test/configCases/context-modules/exclusion/some-dir/check-here/file.js diff --git a/test/configCases/context-exclusion/simple/some-dir/dont-check-here/file.js b/test/configCases/context-modules/exclusion/some-dir/dont-check-here/file.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/dont-check-here/file.js rename to test/configCases/context-modules/exclusion/some-dir/dont-check-here/file.js diff --git a/test/configCases/context-exclusion/simple/some-dir/dont.js b/test/configCases/context-modules/exclusion/some-dir/dont.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/dont.js rename to test/configCases/context-modules/exclusion/some-dir/dont.js diff --git a/test/configCases/context-exclusion/simple/some-dir/file.js b/test/configCases/context-modules/exclusion/some-dir/file.js similarity index 100% rename from test/configCases/context-exclusion/simple/some-dir/file.js rename to test/configCases/context-modules/exclusion/some-dir/file.js diff --git a/test/configCases/context-exclusion/simple/webpack.config.js b/test/configCases/context-modules/exclusion/webpack.config.js similarity index 100% rename from test/configCases/context-exclusion/simple/webpack.config.js rename to test/configCases/context-modules/exclusion/webpack.config.js diff --git a/test/configCases/context-replacement/System.import/index.js b/test/configCases/context-modules/replacement-System.import/index.js similarity index 100% rename from test/configCases/context-replacement/System.import/index.js rename to test/configCases/context-modules/replacement-System.import/index.js diff --git a/test/configCases/context-replacement/System.import/modules/module-b.js b/test/configCases/context-modules/replacement-System.import/modules/module-b.js similarity index 100% rename from test/configCases/context-replacement/System.import/modules/module-b.js rename to test/configCases/context-modules/replacement-System.import/modules/module-b.js diff --git a/test/configCases/context-replacement/System.import/webpack.config.js b/test/configCases/context-modules/replacement-System.import/webpack.config.js similarity index 91% rename from test/configCases/context-replacement/System.import/webpack.config.js rename to test/configCases/context-modules/replacement-System.import/webpack.config.js index 3b5569bcc..102b3879c 100644 --- a/test/configCases/context-replacement/System.import/webpack.config.js +++ b/test/configCases/context-modules/replacement-System.import/webpack.config.js @@ -5,7 +5,7 @@ var webpack = require("../../../../"); module.exports = { plugins: [ new webpack.ContextReplacementPlugin( - /context-replacement/, + /replacement/, path.resolve(__dirname, "modules"), { a: "./module-b" diff --git a/test/configCases/context-replacement/a/index.js b/test/configCases/context-modules/replacement-a/index.js similarity index 100% rename from test/configCases/context-replacement/a/index.js rename to test/configCases/context-modules/replacement-a/index.js diff --git a/test/configCases/context-replacement/a/new-context/node_modules/error.js b/test/configCases/context-modules/replacement-a/new-context/node_modules/error.js similarity index 100% rename from test/configCases/context-replacement/a/new-context/node_modules/error.js rename to test/configCases/context-modules/replacement-a/new-context/node_modules/error.js diff --git a/test/configCases/context-replacement/a/new-context/node_modules/replaced.js b/test/configCases/context-modules/replacement-a/new-context/node_modules/replaced.js similarity index 100% rename from test/configCases/context-replacement/a/new-context/node_modules/replaced.js rename to test/configCases/context-modules/replacement-a/new-context/node_modules/replaced.js diff --git a/test/configCases/context-replacement/a/webpack.config.js b/test/configCases/context-modules/replacement-a/webpack.config.js similarity index 88% rename from test/configCases/context-replacement/a/webpack.config.js rename to test/configCases/context-modules/replacement-a/webpack.config.js index 2b44d0ceb..8d86fa0a0 100644 --- a/test/configCases/context-replacement/a/webpack.config.js +++ b/test/configCases/context-modules/replacement-a/webpack.config.js @@ -4,7 +4,7 @@ const webpack = require("../../../../"); module.exports = { plugins: [ new webpack.ContextReplacementPlugin( - /context-replacement.a$/, + /replacement.a$/, "new-context", true, /^replaced$/ diff --git a/test/configCases/context-replacement/b/error.js b/test/configCases/context-modules/replacement-b/error.js similarity index 100% rename from test/configCases/context-replacement/b/error.js rename to test/configCases/context-modules/replacement-b/error.js diff --git a/test/configCases/context-replacement/b/index.js b/test/configCases/context-modules/replacement-b/index.js similarity index 100% rename from test/configCases/context-replacement/b/index.js rename to test/configCases/context-modules/replacement-b/index.js diff --git a/test/configCases/context-replacement/b/only-this.js b/test/configCases/context-modules/replacement-b/only-this.js similarity index 100% rename from test/configCases/context-replacement/b/only-this.js rename to test/configCases/context-modules/replacement-b/only-this.js diff --git a/test/configCases/context-replacement/b/webpack.config.js b/test/configCases/context-modules/replacement-b/webpack.config.js similarity index 55% rename from test/configCases/context-replacement/b/webpack.config.js rename to test/configCases/context-modules/replacement-b/webpack.config.js index 3a5a33b4d..9fa2c022f 100644 --- a/test/configCases/context-replacement/b/webpack.config.js +++ b/test/configCases/context-modules/replacement-b/webpack.config.js @@ -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/)] }; diff --git a/test/configCases/context-replacement/c/index.js b/test/configCases/context-modules/replacement-c/index.js similarity index 100% rename from test/configCases/context-replacement/c/index.js rename to test/configCases/context-modules/replacement-c/index.js diff --git a/test/configCases/context-replacement/c/modules/a.js b/test/configCases/context-modules/replacement-c/modules/a.js similarity index 100% rename from test/configCases/context-replacement/c/modules/a.js rename to test/configCases/context-modules/replacement-c/modules/a.js diff --git a/test/configCases/context-replacement/c/modules/module-b.js b/test/configCases/context-modules/replacement-c/modules/module-b.js similarity index 100% rename from test/configCases/context-replacement/c/modules/module-b.js rename to test/configCases/context-modules/replacement-c/modules/module-b.js diff --git a/test/configCases/context-replacement/c/node_modules/d.js b/test/configCases/context-modules/replacement-c/node_modules/d.js similarity index 100% rename from test/configCases/context-replacement/c/node_modules/d.js rename to test/configCases/context-modules/replacement-c/node_modules/d.js diff --git a/test/configCases/context-replacement/c/webpack.config.js b/test/configCases/context-modules/replacement-c/webpack.config.js similarity index 92% rename from test/configCases/context-replacement/c/webpack.config.js rename to test/configCases/context-modules/replacement-c/webpack.config.js index 2602bce53..6c00f0d0b 100644 --- a/test/configCases/context-replacement/c/webpack.config.js +++ b/test/configCases/context-modules/replacement-c/webpack.config.js @@ -5,7 +5,7 @@ const webpack = require("../../../../"); module.exports = { plugins: [ new webpack.ContextReplacementPlugin( - /context-replacement.c$/, + /replacement.c$/, path.resolve(__dirname, "modules"), { a: "./a", diff --git a/test/configCases/context-replacement/d/index.js b/test/configCases/context-modules/replacement-d/index.js similarity index 100% rename from test/configCases/context-replacement/d/index.js rename to test/configCases/context-modules/replacement-d/index.js diff --git a/test/configCases/context-replacement/d/modules/a.js b/test/configCases/context-modules/replacement-d/modules/a.js similarity index 100% rename from test/configCases/context-replacement/d/modules/a.js rename to test/configCases/context-modules/replacement-d/modules/a.js diff --git a/test/configCases/context-replacement/d/queryloader.js b/test/configCases/context-modules/replacement-d/queryloader.js similarity index 100% rename from test/configCases/context-replacement/d/queryloader.js rename to test/configCases/context-modules/replacement-d/queryloader.js diff --git a/test/configCases/context-replacement/d/webpack.config.js b/test/configCases/context-modules/replacement-d/webpack.config.js similarity index 92% rename from test/configCases/context-replacement/d/webpack.config.js rename to test/configCases/context-modules/replacement-d/webpack.config.js index fb0177ae5..fdc797fc2 100644 --- a/test/configCases/context-replacement/d/webpack.config.js +++ b/test/configCases/context-modules/replacement-d/webpack.config.js @@ -13,7 +13,7 @@ module.exports = { }, plugins: [ new webpack.ContextReplacementPlugin( - /context-replacement.d$/, + /replacement.d$/, path.resolve(__dirname, "modules?cats=meow"), { a: "./a" diff --git a/test/configCases/context-replacement/e/index.js b/test/configCases/context-modules/replacement-e/index.js similarity index 100% rename from test/configCases/context-replacement/e/index.js rename to test/configCases/context-modules/replacement-e/index.js diff --git a/test/configCases/context-replacement/e/new-context/modules/error.js b/test/configCases/context-modules/replacement-e/new-context/modules/error.js similarity index 100% rename from test/configCases/context-replacement/e/new-context/modules/error.js rename to test/configCases/context-modules/replacement-e/new-context/modules/error.js diff --git a/test/configCases/context-replacement/e/new-context/modules/replaced.js b/test/configCases/context-modules/replacement-e/new-context/modules/replaced.js similarity index 100% rename from test/configCases/context-replacement/e/new-context/modules/replaced.js rename to test/configCases/context-modules/replacement-e/new-context/modules/replaced.js diff --git a/test/configCases/context-replacement/e/webpack.config.js b/test/configCases/context-modules/replacement-e/webpack.config.js similarity index 92% rename from test/configCases/context-replacement/e/webpack.config.js rename to test/configCases/context-modules/replacement-e/webpack.config.js index 302cc9423..291621800 100644 --- a/test/configCases/context-replacement/e/webpack.config.js +++ b/test/configCases/context-modules/replacement-e/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { }, plugins: [ new webpack.ContextReplacementPlugin( - /context-replacement.e$/, + /replacement.e$/, "new-context", true, /^replaced$|^\.\/modules\/rep/ diff --git a/test/configCases/context-replacement/f/folder/a.js b/test/configCases/context-modules/replacement-f/folder/a.js similarity index 100% rename from test/configCases/context-replacement/f/folder/a.js rename to test/configCases/context-modules/replacement-f/folder/a.js diff --git a/test/configCases/context-replacement/f/folder/nested/error.js b/test/configCases/context-modules/replacement-f/folder/nested/error.js similarity index 100% rename from test/configCases/context-replacement/f/folder/nested/error.js rename to test/configCases/context-modules/replacement-f/folder/nested/error.js diff --git a/test/configCases/context-replacement/f/index.js b/test/configCases/context-modules/replacement-f/index.js similarity index 100% rename from test/configCases/context-replacement/f/index.js rename to test/configCases/context-modules/replacement-f/index.js diff --git a/test/configCases/context-replacement/f/webpack.config.js b/test/configCases/context-modules/replacement-f/webpack.config.js similarity index 100% rename from test/configCases/context-replacement/f/webpack.config.js rename to test/configCases/context-modules/replacement-f/webpack.config.js diff --git a/test/configCases/css/basic-dynamic-only/test.config.js b/test/configCases/css/basic-dynamic-only/test.config.js index c141c9959..5e4602a59 100644 --- a/test/configCases/css/basic-dynamic-only/test.config.js +++ b/test/configCases/css/basic-dynamic-only/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["style_css.bundle0.js", "bundle0.js"]; } }; diff --git a/test/configCases/css/basic-web-async/test.config.js b/test/configCases/css/basic-web-async/test.config.js index 2462953a0..41c0f0a0c 100644 --- a/test/configCases/css/basic-web-async/test.config.js +++ b/test/configCases/css/basic-web-async/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["style2_css.bundle0.js", "bundle0.js"]; }, moduleScope(scope) { diff --git a/test/configCases/css/basic/test.config.js b/test/configCases/css/basic/test.config.js index 2462953a0..41c0f0a0c 100644 --- a/test/configCases/css/basic/test.config.js +++ b/test/configCases/css/basic/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["style2_css.bundle0.js", "bundle0.js"]; }, moduleScope(scope) { diff --git a/test/configCases/css/conflicting-order/test.config.js b/test/configCases/css/conflicting-order/test.config.js index c53f34535..457af6186 100644 --- a/test/configCases/css/conflicting-order/test.config.js +++ b/test/configCases/css/conflicting-order/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["css.bundle0.js", "lazy4_js.bundle0.js", "bundle0.js"]; } }; diff --git a/test/configCases/css/css-modules-no-space/webpack.config.js b/test/configCases/css/css-modules-no-space/webpack.config.js index b8e2164d1..31bf688da 100644 --- a/test/configCases/css/css-modules-no-space/webpack.config.js +++ b/test/configCases/css/css-modules-no-space/webpack.config.js @@ -1,5 +1,5 @@ -/** @type {(env: Env, options: TestOptions) => import("../../../../").Configuration} */ -module.exports = (env, { testPath }) => ({ +/** @type {() => import("../../../../").Configuration} */ +module.exports = () => ({ target: "web", mode: "development", experiments: { diff --git a/test/configCases/css/css-modules/test.config.js b/test/configCases/css/css-modules/test.config.js index f8d4d18b3..002bd6add 100644 --- a/test/configCases/css/css-modules/test.config.js +++ b/test/configCases/css/css-modules/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? ["./use-style_js.bundle0.js", "./bundle0.js"] : ["./142.bundle1.js", "./bundle1.js"]; diff --git a/test/configCases/css/escape-unescape/test.config.js b/test/configCases/css/escape-unescape/test.config.js index 523bd0096..937cd273f 100644 --- a/test/configCases/css/escape-unescape/test.config.js +++ b/test/configCases/css/escape-unescape/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["bundle0.js"]; }, moduleScope(scope) { diff --git a/test/configCases/css/exports-convention/test.config.js b/test/configCases/css/exports-convention/test.config.js index 1fcdcbd62..05db19fcc 100644 --- a/test/configCases/css/exports-convention/test.config.js +++ b/test/configCases/css/exports-convention/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return [ `style_module_css_as-is.bundle${i}.js`, `style_module_css_camel-case.bundle${i}.js`, diff --git a/test/configCases/css/exports-only-generator-options/test.config.js b/test/configCases/css/exports-only-generator-options/test.config.js index ee33a0386..ce962330e 100644 --- a/test/configCases/css/exports-only-generator-options/test.config.js +++ b/test/configCases/css/exports-only-generator-options/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "pseudo-export_style_module_css.bundle0.js", "pseudo-export_style_module_css_module.bundle0.js", diff --git a/test/configCases/css/external/test.config.js b/test/configCases/css/external/test.config.js index f543ee110..35c79b066 100644 --- a/test/configCases/css/external/test.config.js +++ b/test/configCases/css/external/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["125.bundle0.js", "bundle0.js"]; } }; diff --git a/test/configCases/css/local-ident-name/test.config.js b/test/configCases/css/local-ident-name/test.config.js index 621df3274..207224f51 100644 --- a/test/configCases/css/local-ident-name/test.config.js +++ b/test/configCases/css/local-ident-name/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return [ `style_module_css.bundle${i}.js`, `style_module_css_hash.bundle${i}.js`, diff --git a/test/configCases/css/pseudo-import/test.config.js b/test/configCases/css/pseudo-import/test.config.js index 1d05d5add..25a8b9f4d 100644 --- a/test/configCases/css/pseudo-import/test.config.js +++ b/test/configCases/css/pseudo-import/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["reexport_modules_css.bundle0.js", "bundle0.js"]; }, moduleScope(scope) { diff --git a/test/configCases/css/runtime-issue/test.config.js b/test/configCases/css/runtime-issue/test.config.js index 6362048d5..b4dce7584 100644 --- a/test/configCases/css/runtime-issue/test.config.js +++ b/test/configCases/css/runtime-issue/test.config.js @@ -9,7 +9,7 @@ module.exports = { link2.href = "asyncChunk2_js.css"; scope.window.document.head.appendChild(link2); }, - findBundle(i, options) { + findBundle() { return [ "./common-share_js-img_png.js", "./asyncChunk_js.js", diff --git a/test/configCases/css/url-and-asset-module-filename/test.config.js b/test/configCases/css/url-and-asset-module-filename/test.config.js index d34e2224b..f3049c55a 100644 --- a/test/configCases/css/url-and-asset-module-filename/test.config.js +++ b/test/configCases/css/url-and-asset-module-filename/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return [`index_css.bundle${i}.js`, `bundle${i}.js`]; } }; diff --git a/test/configCases/deprecations/chunk-and-module/webpack.config.js b/test/configCases/deprecations/chunk-and-module/webpack.config.js index c54ee01fe..f0519bd26 100644 --- a/test/configCases/deprecations/chunk-and-module/webpack.config.js +++ b/test/configCases/deprecations/chunk-and-module/webpack.config.js @@ -30,7 +30,7 @@ module.exports = { expect(chunk.isEmpty()).toBe(false); expect(chunk.modulesSize()).toBeTypeOf("number"); expect(chunk.size()).toBe(chunk.modulesSize() * 10 + 10000); - expect(chunk.getChunkModuleMaps(m => true)).toEqual({ + expect(chunk.getChunkModuleMaps(() => true)).toEqual({ id: {}, hash: {} }); diff --git a/test/configCases/entry/no-chunking/test.config.js b/test/configCases/entry/no-chunking/test.config.js index c8bd29f48..81a03d4c3 100644 --- a/test/configCases/entry/no-chunking/test.config.js +++ b/test/configCases/entry/no-chunking/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./a.js", "./b.js", "./c.js", "./runtime.js", "./d.js"]; } }; diff --git a/test/configCases/errors/generator-generate-error/test.config.js b/test/configCases/errors/generator-generate-error/test.config.js index 13e7530a8..ac2a9c3a4 100644 --- a/test/configCases/errors/generator-generate-error/test.config.js +++ b/test/configCases/errors/generator-generate-error/test.config.js @@ -4,6 +4,6 @@ module.exports = { findBundle(i, options) { const files = findOutputFiles(options, new RegExp(/\.js$/)); - return files.sort((a, b) => (a.startsWith("main") ? 1 : 0)); + return files.sort((a, _b) => (a.startsWith("main") ? 1 : 0)); } }; diff --git a/test/configCases/externals/externals-in-commons-chunk/test.config.js b/test/configCases/externals/externals-in-commons-chunk/test.config.js index 07adc696f..33095374f 100644 --- a/test/configCases/externals/externals-in-commons-chunk/test.config.js +++ b/test/configCases/externals/externals-in-commons-chunk/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./common.js", "./main.js"]; } }; diff --git a/test/configCases/externals/module-import/test.config.js b/test/configCases/externals/module-import/test.config.js index 93fd44fb1..8280b4d30 100644 --- a/test/configCases/externals/module-import/test.config.js +++ b/test/configCases/externals/module-import/test.config.js @@ -1,3 +1,3 @@ module.exports = { - findBundle: (i, options) => ["main.js"] + findBundle: () => ["main.js"] }; diff --git a/test/configCases/externals/module-import/webpack.config.js b/test/configCases/externals/module-import/webpack.config.js index 66c1a65ad..eee267f89 100644 --- a/test/configCases/externals/module-import/webpack.config.js +++ b/test/configCases/externals/module-import/webpack.config.js @@ -21,10 +21,7 @@ module.exports = { }, externalsType: "module-import", externals: [ - function externals( - { context, request, contextInfo, getResolve, dependencyType }, - callback - ) { + function externals({ request }, callback) { if (request === "external2") { return callback(null, "node-commonjs external2"); } diff --git a/test/configCases/filename-template/filename-function/test.config.js b/test/configCases/filename-template/filename-function/test.config.js index 298cbe6d5..57cc4f4b2 100644 --- a/test/configCases/filename-template/filename-function/test.config.js +++ b/test/configCases/filename-template/filename-function/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["11.js", "22.js", "aa.js", "bbb.js"]; } }; diff --git a/test/configCases/graph/issue-11770/test.config.js b/test/configCases/graph/issue-11770/test.config.js index d6424e6f0..ee8eace4e 100644 --- a/test/configCases/graph/issue-11770/test.config.js +++ b/test/configCases/graph/issue-11770/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "shared.js", "a.js", diff --git a/test/configCases/graph/issue-11856/test.config.js b/test/configCases/graph/issue-11856/test.config.js index 4ff816dc9..5162706af 100644 --- a/test/configCases/graph/issue-11856/test.config.js +++ b/test/configCases/graph/issue-11856/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["shared.js", "a.js", "b.js"]; } }; diff --git a/test/configCases/graph/issue-11863/test.config.js b/test/configCases/graph/issue-11863/test.config.js index 3a3565765..5f56a3e6c 100644 --- a/test/configCases/graph/issue-11863/test.config.js +++ b/test/configCases/graph/issue-11863/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "shared.js", "a.js", diff --git a/test/configCases/issues/issue-3596/webpack.config.js b/test/configCases/issues/issue-3596/webpack.config.js index 614835822..cd23171cf 100644 --- a/test/configCases/issues/issue-3596/webpack.config.js +++ b/test/configCases/issues/issue-3596/webpack.config.js @@ -10,7 +10,7 @@ module.exports = { plugins: [ function apply() { this.hooks.compilation.tap("TestPlugin", compilation => { - compilation.hooks.processAssets.tap("TestPlugin", assets => { + compilation.hooks.processAssets.tap("TestPlugin", () => { delete compilation.assets["b.js"]; }); }); diff --git a/test/configCases/library/issue-18951/test.config.js b/test/configCases/library/issue-18951/test.config.js index ab6930549..bc434b87b 100644 --- a/test/configCases/library/issue-18951/test.config.js +++ b/test/configCases/library/issue-18951/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.mjs"]; } }; diff --git a/test/configCases/module/iife-entry-module-with-others/test.config.js b/test/configCases/module/iife-entry-module-with-others/test.config.js index b0ea3b44c..53042d86f 100644 --- a/test/configCases/module/iife-entry-module-with-others/test.config.js +++ b/test/configCases/module/iife-entry-module-with-others/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "module-avoidEntryIife-false.mjs", "module-avoidEntryIife-true.mjs", diff --git a/test/configCases/module/iife-innter-strict/test.config.js b/test/configCases/module/iife-innter-strict/test.config.js index 32f4be1d4..f48f8b79d 100644 --- a/test/configCases/module/iife-innter-strict/test.config.js +++ b/test/configCases/module/iife-innter-strict/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["test.js"]; } }; diff --git a/test/configCases/module/iife-multiple-entry-modules/test.config.js b/test/configCases/module/iife-multiple-entry-modules/test.config.js index 5e7f742d6..bb3de309b 100644 --- a/test/configCases/module/iife-multiple-entry-modules/test.config.js +++ b/test/configCases/module/iife-multiple-entry-modules/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["bundle0.mjs", "test.js"]; } }; diff --git a/test/configCases/module/issue-16040/test.config.js b/test/configCases/module/issue-16040/test.config.js index 15fd839d7..194e05220 100644 --- a/test/configCases/module/issue-16040/test.config.js +++ b/test/configCases/module/issue-16040/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.mjs", "vendor.mjs", "runtime.mjs"]; } }; diff --git a/test/configCases/module/split-chunks-without-externals/test.config.js b/test/configCases/module/split-chunks-without-externals/test.config.js index 1dd2dfc63..6dfa44861 100644 --- a/test/configCases/module/split-chunks-without-externals/test.config.js +++ b/test/configCases/module/split-chunks-without-externals/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.mjs", "testModule1.mjs", "testModule2.mjs"]; } }; diff --git a/test/configCases/output/charset/test.config.js b/test/configCases/output/charset/test.config.js index ea656968b..d338a4c02 100644 --- a/test/configCases/output/charset/test.config.js +++ b/test/configCases/output/charset/test.config.js @@ -1,5 +1,5 @@ module.exports = { - moduleScope(scope, options) { + moduleScope(scope) { const link = scope.window.document.createElement("link"); link.rel = "stylesheet"; link.href = "chunk1.css"; diff --git a/test/configCases/plugins/banner-plugin-hashing/test.config.js b/test/configCases/plugins/banner-plugin-hashing/test.config.js index 5d626611b..72f2bf28c 100644 --- a/test/configCases/plugins/banner-plugin-hashing/test.config.js +++ b/test/configCases/plugins/banner-plugin-hashing/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return "./dist/banner.js"; } }; diff --git a/test/configCases/plugins/limit-chunk-count-plugin/test.config.js b/test/configCases/plugins/limit-chunk-count-plugin/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/plugins/limit-chunk-count-plugin/test.config.js +++ b/test/configCases/plugins/limit-chunk-count-plugin/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/plugins/mini-css-extract-plugin/test.config.js b/test/configCases/plugins/mini-css-extract-plugin/test.config.js index 393afd969..41eeb395b 100644 --- a/test/configCases/plugins/mini-css-extract-plugin/test.config.js +++ b/test/configCases/plugins/mini-css-extract-plugin/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return [`${i}_a.js`, `${i}_b.js`, `${i}_c.js`]; } }; diff --git a/test/configCases/plugins/source-map-dev-tool-plugin-append-function/webpack.config.js b/test/configCases/plugins/source-map-dev-tool-plugin-append-function/webpack.config.js index 8abc96022..316da3e88 100644 --- a/test/configCases/plugins/source-map-dev-tool-plugin-append-function/webpack.config.js +++ b/test/configCases/plugins/source-map-dev-tool-plugin-append-function/webpack.config.js @@ -20,7 +20,7 @@ module.exports = { plugins: [ new webpack.SourceMapDevToolPlugin({ filename: "sourcemaps/[file].map", - append: data => "\n//# sourceMappingURL=http://localhost:50505/[file].map" + append: () => "\n//# sourceMappingURL=http://localhost:50505/[file].map" }) ] }; diff --git a/test/configCases/plugins/virtual-url-plugin/webpack.config.js b/test/configCases/plugins/virtual-url-plugin/webpack.config.js index c14c93fee..a5081e275 100644 --- a/test/configCases/plugins/virtual-url-plugin/webpack.config.js +++ b/test/configCases/plugins/virtual-url-plugin/webpack.config.js @@ -10,7 +10,7 @@ const watchDir = path.join(__dirname, "./routes"); const config = { plugins: [ new VirtualUrlPlugin({ - routes(loaderContext) { + routes() { const files = fs.readdirSync(watchDir); return ` export const routes = { diff --git a/test/configCases/resolving/prefer-absolute/webpack.config.js b/test/configCases/resolving/prefer-absolute/webpack.config.js index 9d5b63424..21adc6f0f 100644 --- a/test/configCases/resolving/prefer-absolute/webpack.config.js +++ b/test/configCases/resolving/prefer-absolute/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { * @param {Resolver & { hooks: { file: SyncBailHook<[ResolveRequest, ResolveContext], void> } }} resolver resolver */ apply(resolver) { - resolver.hooks.file.tap("Test", (request, resolverContext) => { + resolver.hooks.file.tap("Test", request => { if ( /test.configCases.*test.configCases/.test( /** @type {string} */ diff --git a/test/configCases/resolving/prefer-root/webpack.config.js b/test/configCases/resolving/prefer-root/webpack.config.js index 36a2fd09e..9aecc535c 100644 --- a/test/configCases/resolving/prefer-root/webpack.config.js +++ b/test/configCases/resolving/prefer-root/webpack.config.js @@ -16,7 +16,7 @@ module.exports = { * @param {Resolver & { hooks: { file: SyncBailHook<[ResolveRequest, ResolveContext], void> } }} resolver resolver */ apply(resolver) { - resolver.hooks.file.tap("Test", (request, resolverContext) => { + resolver.hooks.file.tap("Test", request => { if (request.path === "/index.js") { throw new Error("Trying to resolve as absolute path"); } diff --git a/test/configCases/source-map/devtool-namespace-with-eval-source-map/test.config.js b/test/configCases/source-map/devtool-namespace-with-eval-source-map/test.config.js index a773bb4eb..be2150cc6 100644 --- a/test/configCases/source-map/devtool-namespace-with-eval-source-map/test.config.js +++ b/test/configCases/source-map/devtool-namespace-with-eval-source-map/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["entry-a-bundle.js", "entry-b-bundle.js"]; } }; diff --git a/test/configCases/source-map/devtool-namespace-with-eval/test.config.js b/test/configCases/source-map/devtool-namespace-with-eval/test.config.js index a773bb4eb..be2150cc6 100644 --- a/test/configCases/source-map/devtool-namespace-with-eval/test.config.js +++ b/test/configCases/source-map/devtool-namespace-with-eval/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["entry-a-bundle.js", "entry-b-bundle.js"]; } }; diff --git a/test/configCases/source-map/devtool-namespace-with-source-map/test.config.js b/test/configCases/source-map/devtool-namespace-with-source-map/test.config.js index a773bb4eb..be2150cc6 100644 --- a/test/configCases/source-map/devtool-namespace-with-source-map/test.config.js +++ b/test/configCases/source-map/devtool-namespace-with-source-map/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["entry-a-bundle.js", "entry-b-bundle.js"]; } }; diff --git a/test/configCases/split-chunks-common/correct-order/test.config.js b/test/configCases/split-chunks-common/correct-order/test.config.js index f8bc4b847..ac3afebfc 100644 --- a/test/configCases/split-chunks-common/correct-order/test.config.js +++ b/test/configCases/split-chunks-common/correct-order/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./vendor.js", "./main.js"]; } }; diff --git a/test/configCases/split-chunks-common/extract-async-from-entry/test.config.js b/test/configCases/split-chunks-common/extract-async-from-entry/test.config.js index 74e4d94cc..0e721ca14 100644 --- a/test/configCases/split-chunks-common/extract-async-from-entry/test.config.js +++ b/test/configCases/split-chunks-common/extract-async-from-entry/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./main.js"]; } }; diff --git a/test/configCases/split-chunks-common/hot-multi/test.config.js b/test/configCases/split-chunks-common/hot-multi/test.config.js index c5249179a..649527115 100644 --- a/test/configCases/split-chunks-common/hot-multi/test.config.js +++ b/test/configCases/split-chunks-common/hot-multi/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./vendor.js", "./first.js", "./second.js"]; } }; diff --git a/test/configCases/split-chunks-common/hot/test.config.js b/test/configCases/split-chunks-common/hot/test.config.js index f8bc4b847..ac3afebfc 100644 --- a/test/configCases/split-chunks-common/hot/test.config.js +++ b/test/configCases/split-chunks-common/hot/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./vendor.js", "./main.js"]; } }; diff --git a/test/configCases/split-chunks-common/inverted-order/test.config.js b/test/configCases/split-chunks-common/inverted-order/test.config.js index fc22d3b57..eed5873a9 100644 --- a/test/configCases/split-chunks-common/inverted-order/test.config.js +++ b/test/configCases/split-chunks-common/inverted-order/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./main.js", "./vendor.js"]; } }; diff --git a/test/configCases/split-chunks-common/issue-12128/test.config.js b/test/configCases/split-chunks-common/issue-12128/test.config.js index 8e220227b..69f19523b 100644 --- a/test/configCases/split-chunks-common/issue-12128/test.config.js +++ b/test/configCases/split-chunks-common/issue-12128/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./common.js", "./main.js", "./main2.js"]; } }; diff --git a/test/configCases/split-chunks-common/library/test.config.js b/test/configCases/split-chunks-common/library/test.config.js index 8ede468fd..06e8b92c0 100644 --- a/test/configCases/split-chunks-common/library/test.config.js +++ b/test/configCases/split-chunks-common/library/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./vendor.js", "./main.js"]; }, modules: { diff --git a/test/configCases/split-chunks-common/move-entry/test.config.js b/test/configCases/split-chunks-common/move-entry/test.config.js index 1aceaa7c1..40bcfbb63 100644 --- a/test/configCases/split-chunks-common/move-entry/test.config.js +++ b/test/configCases/split-chunks-common/move-entry/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./commons.js", "./main.js"]; } }; diff --git a/test/configCases/split-chunks-common/move-to-grandparent/test.config.js b/test/configCases/split-chunks-common/move-to-grandparent/test.config.js index c29a7929d..20f79312e 100644 --- a/test/configCases/split-chunks-common/move-to-grandparent/test.config.js +++ b/test/configCases/split-chunks-common/move-to-grandparent/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./main.js", "./misc.js"]; } }; diff --git a/test/configCases/split-chunks-common/simple/test.config.js b/test/configCases/split-chunks-common/simple/test.config.js index f8bc4b847..ac3afebfc 100644 --- a/test/configCases/split-chunks-common/simple/test.config.js +++ b/test/configCases/split-chunks-common/simple/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["./vendor.js", "./main.js"]; } }; diff --git a/test/configCases/split-chunks/asnyc-entries/test.config.js b/test/configCases/split-chunks/asnyc-entries/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/split-chunks/asnyc-entries/test.config.js +++ b/test/configCases/split-chunks/asnyc-entries/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/split-chunks/chunk-filename-delimiter-default/test.config.js b/test/configCases/split-chunks/chunk-filename-delimiter-default/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/split-chunks/chunk-filename-delimiter-default/test.config.js +++ b/test/configCases/split-chunks/chunk-filename-delimiter-default/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/split-chunks/chunk-filename-delimiter/test.config.js b/test/configCases/split-chunks/chunk-filename-delimiter/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/split-chunks/chunk-filename-delimiter/test.config.js +++ b/test/configCases/split-chunks/chunk-filename-delimiter/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/split-chunks/custom-filename-function/test.config.js b/test/configCases/split-chunks/custom-filename-function/test.config.js index af4691d78..4ca166970 100644 --- a/test/configCases/split-chunks/custom-filename-function/test.config.js +++ b/test/configCases/split-chunks/custom-filename-function/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js"]; } }; diff --git a/test/configCases/split-chunks/custom-filename-many-custom/test.config.js b/test/configCases/split-chunks/custom-filename-many-custom/test.config.js index af4691d78..4ca166970 100644 --- a/test/configCases/split-chunks/custom-filename-many-custom/test.config.js +++ b/test/configCases/split-chunks/custom-filename-many-custom/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js"]; } }; diff --git a/test/configCases/split-chunks/custom-filename/test.config.js b/test/configCases/split-chunks/custom-filename/test.config.js index af4691d78..4ca166970 100644 --- a/test/configCases/split-chunks/custom-filename/test.config.js +++ b/test/configCases/split-chunks/custom-filename/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js"]; } }; diff --git a/test/configCases/split-chunks/entry-point-error/test.config.js b/test/configCases/split-chunks/entry-point-error/test.config.js index 024c0caed..fa1cdb2fc 100644 --- a/test/configCases/split-chunks/entry-point-error/test.config.js +++ b/test/configCases/split-chunks/entry-point-error/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["vendors.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/issue-11513/test.config.js b/test/configCases/split-chunks/issue-11513/test.config.js index 24317dca7..aab02d48e 100644 --- a/test/configCases/split-chunks/issue-11513/test.config.js +++ b/test/configCases/split-chunks/issue-11513/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["test.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/issue-17332/test.config.js b/test/configCases/split-chunks/issue-17332/test.config.js index 33308d294..1a6234f5e 100644 --- a/test/configCases/split-chunks/issue-17332/test.config.js +++ b/test/configCases/split-chunks/issue-17332/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["split-foo.js", "foo.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/issue-8908/test.config.js b/test/configCases/split-chunks/issue-8908/test.config.js index 51e90d128..7948c3fe7 100644 --- a/test/configCases/split-chunks/issue-8908/test.config.js +++ b/test/configCases/split-chunks/issue-8908/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime.js", "vendor-a.js", "a.js"]; } }; diff --git a/test/configCases/split-chunks/issue-9491/test.config.js b/test/configCases/split-chunks/issue-9491/test.config.js index 69c3d55b6..823968a3f 100644 --- a/test/configCases/split-chunks/issue-9491/test.config.js +++ b/test/configCases/split-chunks/issue-9491/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime.js", "constructor.js"]; } }; diff --git a/test/configCases/split-chunks/max-size-casing/test.config.js b/test/configCases/split-chunks/max-size-casing/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/split-chunks/max-size-casing/test.config.js +++ b/test/configCases/split-chunks/max-size-casing/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/split-chunks/module-type-filter/test.config.js b/test/configCases/split-chunks/module-type-filter/test.config.js index 23e1b2636..5e6f0eb36 100644 --- a/test/configCases/split-chunks/module-type-filter/test.config.js +++ b/test/configCases/split-chunks/module-type-filter/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["json.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/move-to-entrypoint/test.config.js b/test/configCases/split-chunks/move-to-entrypoint/test.config.js index 60ac768dc..97e8d085f 100644 --- a/test/configCases/split-chunks/move-to-entrypoint/test.config.js +++ b/test/configCases/split-chunks/move-to-entrypoint/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime.js", "a.js", "b.js"]; } }; diff --git a/test/configCases/split-chunks/no-name/test.config.js b/test/configCases/split-chunks/no-name/test.config.js index b29ba4773..859a3d0a5 100644 --- a/test/configCases/split-chunks/no-name/test.config.js +++ b/test/configCases/split-chunks/no-name/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["common-a_js.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/no-options/test.config.js b/test/configCases/split-chunks/no-options/test.config.js index 39c2883c7..5875983aa 100644 --- a/test/configCases/split-chunks/no-options/test.config.js +++ b/test/configCases/split-chunks/no-options/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["vendor.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/reuse-chunk-name/test.config.js b/test/configCases/split-chunks/reuse-chunk-name/test.config.js index ad7cd7e18..dc9c0aae5 100644 --- a/test/configCases/split-chunks/reuse-chunk-name/test.config.js +++ b/test/configCases/split-chunks/reuse-chunk-name/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["common.js", "main.js"]; } }; diff --git a/test/configCases/split-chunks/runtime-chunk-async-node/test.config.js b/test/configCases/split-chunks/runtime-chunk-async-node/test.config.js index fafd4ba62..1b0256ddd 100644 --- a/test/configCases/split-chunks/runtime-chunk-async-node/test.config.js +++ b/test/configCases/split-chunks/runtime-chunk-async-node/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["b.js", "deep/path/a.js", "somewhere/c.js"]; } }; diff --git a/test/configCases/split-chunks/runtime-chunk-node-13130/test.config.js b/test/configCases/split-chunks/runtime-chunk-node-13130/test.config.js index fafd4ba62..1b0256ddd 100644 --- a/test/configCases/split-chunks/runtime-chunk-node-13130/test.config.js +++ b/test/configCases/split-chunks/runtime-chunk-node-13130/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["b.js", "deep/path/a.js", "somewhere/c.js"]; } }; diff --git a/test/configCases/split-chunks/runtime-chunk-node/test.config.js b/test/configCases/split-chunks/runtime-chunk-node/test.config.js index fafd4ba62..1b0256ddd 100644 --- a/test/configCases/split-chunks/runtime-chunk-node/test.config.js +++ b/test/configCases/split-chunks/runtime-chunk-node/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["b.js", "deep/path/a.js", "somewhere/c.js"]; } }; diff --git a/test/configCases/split-chunks/runtime-chunk/test.config.js b/test/configCases/split-chunks/runtime-chunk/test.config.js index b00df088b..cdc9dd1d4 100644 --- a/test/configCases/split-chunks/runtime-chunk/test.config.js +++ b/test/configCases/split-chunks/runtime-chunk/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime.js", "a.js"]; } }; diff --git a/test/configCases/split-chunks/vendor-only-entrypoint/test.config.js b/test/configCases/split-chunks/vendor-only-entrypoint/test.config.js index d0803add7..f80a9c6f5 100644 --- a/test/configCases/split-chunks/vendor-only-entrypoint/test.config.js +++ b/test/configCases/split-chunks/vendor-only-entrypoint/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["runtime~vendor.js", "vendor.js"]; } }; diff --git a/test/configCases/target/chunk-loading-per-entry/test.config.js b/test/configCases/target/chunk-loading-per-entry/test.config.js index cb1a34c33..643395505 100644 --- a/test/configCases/target/chunk-loading-per-entry/test.config.js +++ b/test/configCases/target/chunk-loading-per-entry/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { return i === 0 ? "./web-0.js" : "./webworker-1.js"; } }; diff --git a/test/configCases/trusted-types/web-worker/test.config.js b/test/configCases/trusted-types/web-worker/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/trusted-types/web-worker/test.config.js +++ b/test/configCases/trusted-types/web-worker/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/umd/issue-15545/test.config.js b/test/configCases/umd/issue-15545/test.config.js index 2b00586a4..678748077 100644 --- a/test/configCases/umd/issue-15545/test.config.js +++ b/test/configCases/umd/issue-15545/test.config.js @@ -1,7 +1,7 @@ const CONTEXT = {}; module.exports = { - nonEsmThis(module) { + nonEsmThis() { return CONTEXT; }, findBundle() { diff --git a/test/configCases/wasm/fetch/test.config.js b/test/configCases/wasm/fetch/test.config.js index 3e6e0925a..68d0c25fc 100644 --- a/test/configCases/wasm/fetch/test.config.js +++ b/test/configCases/wasm/fetch/test.config.js @@ -3,7 +3,7 @@ const path = require("path"); const url = require("url"); module.exports = { - findBundle(i, options) { + findBundle(i) { switch (i) { case 0: return ["bundle0.mjs"]; diff --git a/test/configCases/web/non-js-chunks-entrypoint-runtime-chunk/test.config.js b/test/configCases/web/non-js-chunks-entrypoint-runtime-chunk/test.config.js index 7de30aabd..09896fb50 100644 --- a/test/configCases/web/non-js-chunks-entrypoint-runtime-chunk/test.config.js +++ b/test/configCases/web/non-js-chunks-entrypoint-runtime-chunk/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "runtime.js", "main.js", diff --git a/test/configCases/web/non-js-chunks-entrypoint/test.config.js b/test/configCases/web/non-js-chunks-entrypoint/test.config.js index 096ce4cd9..229a4f1a0 100644 --- a/test/configCases/web/non-js-chunks-entrypoint/test.config.js +++ b/test/configCases/web/non-js-chunks-entrypoint/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return [ "main.js", "vendors-node_modules_other-package_index_js-node_modules_package_index_js.js" diff --git a/test/configCases/web/preexecuted-chunk/test.config.js b/test/configCases/web/preexecuted-chunk/test.config.js index 6ad8df89e..7aafb4861 100644 --- a/test/configCases/web/preexecuted-chunk/test.config.js +++ b/test/configCases/web/preexecuted-chunk/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["the-chunk.js", "bundle0.js"]; } }; diff --git a/test/configCases/web/prefetch-split-chunks/test.config.js b/test/configCases/web/prefetch-split-chunks/test.config.js index b9ed0f575..086baa60b 100644 --- a/test/configCases/web/prefetch-split-chunks/test.config.js +++ b/test/configCases/web/prefetch-split-chunks/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js", "runtime~main.js", "separate-public-path_js.js"]; } }; diff --git a/test/configCases/web/unique-jsonp/test.config.js b/test/configCases/web/unique-jsonp/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/web/unique-jsonp/test.config.js +++ b/test/configCases/web/unique-jsonp/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/worker/custom-worker/test.config.js b/test/configCases/worker/custom-worker/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/worker/custom-worker/test.config.js +++ b/test/configCases/worker/custom-worker/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/worker/node-worker-esm/test.config.js b/test/configCases/worker/node-worker-esm/test.config.js index aac7fff6c..b048fb04e 100644 --- a/test/configCases/worker/node-worker-esm/test.config.js +++ b/test/configCases/worker/node-worker-esm/test.config.js @@ -1,6 +1,5 @@ const fs = require("fs"); const path = require("path"); -const { URL } = require("url"); module.exports = { findBundle() { diff --git a/test/configCases/worker/node-worker-hmr/test.config.js b/test/configCases/worker/node-worker-hmr/test.config.js index 28532b869..d0b177310 100644 --- a/test/configCases/worker/node-worker-hmr/test.config.js +++ b/test/configCases/worker/node-worker-hmr/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js", "b.js", "c.js", "d.js"]; } }; diff --git a/test/configCases/worker/node-worker-named/test.config.js b/test/configCases/worker/node-worker-named/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/worker/node-worker-named/test.config.js +++ b/test/configCases/worker/node-worker-named/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/worker/node-worker/test.config.js b/test/configCases/worker/node-worker/test.config.js index 28532b869..d0b177310 100644 --- a/test/configCases/worker/node-worker/test.config.js +++ b/test/configCases/worker/node-worker/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["a.js", "b.js", "c.js", "d.js"]; } }; diff --git a/test/configCases/worker/self-import/test.config.js b/test/configCases/worker/self-import/test.config.js index 86bc794f1..792e0848f 100644 --- a/test/configCases/worker/self-import/test.config.js +++ b/test/configCases/worker/self-import/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle(i) { switch (i) { case 0: return [`bundle${i}.js`]; diff --git a/test/configCases/worker/universal/test.config.js b/test/configCases/worker/universal/test.config.js index 4b0564c5d..61de36bb6 100644 --- a/test/configCases/worker/universal/test.config.js +++ b/test/configCases/worker/universal/test.config.js @@ -4,7 +4,7 @@ module.exports = { delete scope.Worker; } }, - findBundle(i, options) { + findBundle() { return ["web-main.mjs"]; } }; diff --git a/test/configCases/worker/web-worker/test.config.js b/test/configCases/worker/web-worker/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/worker/web-worker/test.config.js +++ b/test/configCases/worker/web-worker/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/configCases/worker/worker-contenthash/test.config.js b/test/configCases/worker/worker-contenthash/test.config.js index 0c4cdb953..78a59a588 100644 --- a/test/configCases/worker/worker-contenthash/test.config.js +++ b/test/configCases/worker/worker-contenthash/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle(i, options) { + findBundle() { return ["main.js"]; } }; diff --git a/test/helpers/FakeDocument.js b/test/helpers/FakeDocument.js index c0e869d1c..a50bd6187 100644 --- a/test/helpers/FakeDocument.js +++ b/test/helpers/FakeDocument.js @@ -91,7 +91,7 @@ class FakeElement { } } - insertBefore(node, before) { + insertBefore(node) { this._attach(node); this._load(node); } diff --git a/test/helpers/deprecationTracking.js b/test/helpers/deprecationTracking.js index 17c1c68d6..24bce22da 100644 --- a/test/helpers/deprecationTracking.js +++ b/test/helpers/deprecationTracking.js @@ -40,10 +40,9 @@ util.deprecate = (fn, message, _code) => { }; /** - * @param {EXPECTED_ANY} handler handler * @returns {() => EXPECTED_ANY} result */ -module.exports.start = handler => { +module.exports.start = () => { interception = new Map(); return () => { @@ -55,6 +54,6 @@ module.exports.start = handler => { if (a > b) return 1; return 0; }) - .map(([key, data]) => data); + .map(([_key, data]) => data); }; }; diff --git a/test/hotCases/css/single-css-entry/webpack.config.js b/test/hotCases/css/single-css-entry/webpack.config.js index 26f2eae1e..62cd01bf7 100644 --- a/test/hotCases/css/single-css-entry/webpack.config.js +++ b/test/hotCases/css/single-css-entry/webpack.config.js @@ -14,7 +14,7 @@ module.exports = { compiler.hooks.compilation.tap("Test", compilation => { compilation.hooks.additionalTreeRuntimeRequirements.tap( "Test", - (module, set, context) => { + (module, set, _context) => { // To prevent the runtime error `ReferenceError: __webpack_exports__ is not defined`, // which occurs because the default `output.library` setting is `commonjs2`, // resulting in adding `module.exports = __webpack_exports__;`. diff --git a/test/hotCases/worker/move-between-runtime/test.filter.js b/test/hotCases/worker/move-between-runtime/test.filter.js index 23936757a..d456e8870 100644 --- a/test/hotCases/worker/move-between-runtime/test.filter.js +++ b/test/hotCases/worker/move-between-runtime/test.filter.js @@ -1,3 +1,3 @@ const supportsWorker = require("../../../helpers/supportsWorker"); -module.exports = config => supportsWorker(); +module.exports = () => supportsWorker(); diff --git a/test/watchCases/cache/unsafe-cache-duplicates/webpack.config.js b/test/watchCases/cache/unsafe-cache-duplicates/webpack.config.js index 790b968d8..a6974524b 100644 --- a/test/watchCases/cache/unsafe-cache-duplicates/webpack.config.js +++ b/test/watchCases/cache/unsafe-cache-duplicates/webpack.config.js @@ -21,7 +21,7 @@ module.exports = (env, { srcPath }) => ({ name: "webpack.config.js", stage: -1000 }, - (identifier, etag) => { + identifier => { if (identifier.includes(path.join(srcPath, "module.js"))) { return null; } diff --git a/test/watchCases/cache/unsafe-cache-managed-paths/webpack.config.js b/test/watchCases/cache/unsafe-cache-managed-paths/webpack.config.js index 510ec2e86..231f2371a 100644 --- a/test/watchCases/cache/unsafe-cache-managed-paths/webpack.config.js +++ b/test/watchCases/cache/unsafe-cache-managed-paths/webpack.config.js @@ -1,5 +1,5 @@ -/** @type {(env: Env, options: TestOptions) => import("../../../../").Configuration} */ -module.exports = (env, { srcPath }) => ({ +/** @type {() => import("../../../../").Configuration} */ +module.exports = () => ({ mode: "development", cache: { type: "memory" diff --git a/tooling/print-cache-file.js b/tooling/print-cache-file.js index df9b43866..e0c6bbd38 100644 --- a/tooling/print-cache-file.js +++ b/tooling/print-cache-file.js @@ -152,7 +152,7 @@ const printData = async (data, indent) => { } } const refCounters = [...referencedValuesCounters]; - refCounters.sort(([a, A], [b, B]) => B - A); + refCounters.sort(([_a, A], [_b, B]) => B - A); printLine("SUMMARY: top references:"); for (const [ref, count] of refCounters.slice(10)) { const value = referencedValues.get(ref); diff --git a/tsconfig.types.test.json b/tsconfig.types.test.json index 52ab5c904..b6f832bd0 100644 --- a/tsconfig.types.test.json +++ b/tsconfig.types.test.json @@ -12,5 +12,6 @@ "test/configCases/**/*loader*.js", "test/hotCases/**/*loader*.js", "declarations.test.d.ts" - ] + ], + "exclude": ["test/js/**/*"] } diff --git a/yarn.lock b/yarn.lock index 899d6902e..92e3ee242 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1568,7 +1568,7 @@ semver "^7.6.0" ts-api-utils "^2.1.0" -"@typescript-eslint/utils@^8.0.0", "@typescript-eslint/utils@^8.26.1": +"@typescript-eslint/utils@^8.0.0": version "8.34.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.34.1.tgz#f98c9b0c5cae407e34f5131cac0f3a74347a398e" integrity sha512-mqOwUdZ3KjtGk7xJJnLbHxTuWVn3GO2WZZuM+Slhkun4+qthLdXx32C8xIXbO1kfCECb3jIs3eoxK3eryk7aoQ== @@ -3380,13 +3380,12 @@ eslint-plugin-jsdoc@^51.2.3: semver "^7.7.2" spdx-expression-parse "^4.0.0" -eslint-plugin-n@^17.20.0: - version "17.20.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.20.0.tgz#000a7a39675d737824d704ae77b626c257b318ef" - integrity sha512-IRSoatgB/NQJZG5EeTbv/iAx1byOGdbbyhQrNvWdCfTnmPxUT0ao9/eGOeG7ljD8wJBsxwE8f6tES5Db0FRKEw== +eslint-plugin-n@^17.21.0: + version "17.21.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.21.0.tgz#6b1833e5e8fd07a69bbab2be429771ff2309db5e" + integrity sha512-1+iZ8We4ZlwVMtb/DcHG3y5/bZOdazIpa/4TySo22MLKdwrLcfrX0hbadnCvykSQCCmkAnWmIP8jZVb2AAq29A== dependencies: "@eslint-community/eslint-utils" "^4.5.0" - "@typescript-eslint/utils" "^8.26.1" enhanced-resolve "^5.17.1" eslint-plugin-es-x "^7.8.0" get-tsconfig "^4.8.1"