style: improve style of code

This commit is contained in:
alexander.akait 2024-07-31 01:15:03 +03:00
parent 500ee96dcb
commit ac0bd21801
44 changed files with 87 additions and 86 deletions

View File

@ -112,6 +112,7 @@ module.exports = [
"object-shorthand": "error", "object-shorthand": "error",
"no-else-return": "error", "no-else-return": "error",
"no-lonely-if": "error", "no-lonely-if": "error",
"no-undef-init": "error",
"n/no-missing-require": ["error", { allowModules: ["webpack"] }], "n/no-missing-require": ["error", { allowModules: ["webpack"] }],
"n/no-unsupported-features/node-builtins": [ "n/no-unsupported-features/node-builtins": [
"error", "error",
@ -182,6 +183,7 @@ module.exports = [
rules: { rules: {
"prefer-const": "off", "prefer-const": "off",
"object-shorthand": "off", "object-shorthand": "off",
"no-undef-init": "off",
"n/exports-style": "off" "n/exports-style": "off"
} }
}, },
@ -231,5 +233,11 @@ module.exports = [
rules: { rules: {
"n/no-missing-require": "off" "n/no-missing-require": "off"
} }
},
{
files: ["lib/util/semver.js"],
rules: {
"n/exports-style": "off"
}
} }
]; ];

View File

@ -7,7 +7,7 @@
const asyncLib = require("neo-async"); const asyncLib = require("neo-async");
const { SyncBailHook } = require("tapable"); const { SyncBailHook } = require("tapable");
const Compilation = require("../lib/Compilation"); const Compilation = require("./Compilation");
const createSchemaValidation = require("./util/create-schema-validation"); const createSchemaValidation = require("./util/create-schema-validation");
const { join } = require("./util/fs"); const { join } = require("./util/fs");
const processAsyncTree = require("./util/processAsyncTree"); const processAsyncTree = require("./util/processAsyncTree");

View File

@ -448,7 +448,7 @@ class Compilation {
* @returns {CompilationAssets} new assets * @returns {CompilationAssets} new assets
*/ */
const popNewAssets = assets => { const popNewAssets = assets => {
let newAssets = undefined; let newAssets;
for (const file of Object.keys(assets)) { for (const file of Object.keys(assets)) {
if (savedAssets.has(file)) continue; if (savedAssets.has(file)) continue;
if (newAssets === undefined) { if (newAssets === undefined) {
@ -1960,7 +1960,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
callback callback
) { ) {
// Check for cycles when build is trigger inside another build // Check for cycles when build is trigger inside another build
let creatingModuleDuringBuildSet = undefined; let creatingModuleDuringBuildSet;
if (checkCycle && this.buildQueue.isProcessing(originModule)) { if (checkCycle && this.buildQueue.isProcessing(originModule)) {
// Track build dependency // Track build dependency
creatingModuleDuringBuildSet = creatingModuleDuringBuildSet =
@ -2361,7 +2361,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
*/ */
const computeReferences = module => { const computeReferences = module => {
/** @type {References | undefined} */ /** @type {References | undefined} */
let references = undefined; let references;
for (const connection of moduleGraph.getOutgoingConnections(module)) { for (const connection of moduleGraph.getOutgoingConnections(module)) {
const d = connection.dependency; const d = connection.dependency;
const m = connection.module; const m = connection.module;
@ -2530,9 +2530,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
const computeReferences = module => { const computeReferences = module => {
const id = chunkGraph.getModuleId(module); const id = chunkGraph.getModuleId(module);
/** @type {Map<Module, string | number | undefined> | undefined} */ /** @type {Map<Module, string | number | undefined> | undefined} */
let modules = undefined; let modules;
/** @type {(string | number | null)[] | undefined} */ /** @type {(string | number | null)[] | undefined} */
let blocks = undefined; let blocks;
const outgoing = moduleGraph.getOutgoingConnectionsByModule(module); const outgoing = moduleGraph.getOutgoingConnectionsByModule(module);
if (outgoing !== undefined) { if (outgoing !== undefined) {
for (const m of outgoing.keys()) { for (const m of outgoing.keys()) {
@ -3328,7 +3328,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
/** @type {WebpackError[]} */ /** @type {WebpackError[]} */
const errors = []; const errors = [];
/** @type {NotCodeGeneratedModules | undefined} */ /** @type {NotCodeGeneratedModules | undefined} */
let notCodeGeneratedModules = undefined; let notCodeGeneratedModules;
const runIteration = () => { const runIteration = () => {
/** @type {CodeGenerationJobs} */ /** @type {CodeGenerationJobs} */
let delayedJobs = []; let delayedJobs = [];

View File

@ -14,7 +14,7 @@ const {
AsyncSeriesHook AsyncSeriesHook
} = require("tapable"); } = require("tapable");
const { SizeOnlySource } = require("webpack-sources"); const { SizeOnlySource } = require("webpack-sources");
const webpack = require("./"); const webpack = require(".");
const Cache = require("./Cache"); const Cache = require("./Cache");
const CacheFacade = require("./CacheFacade"); const CacheFacade = require("./CacheFacade");
const ChunkGraph = require("./ChunkGraph"); const ChunkGraph = require("./ChunkGraph");

View File

@ -846,7 +846,7 @@ class ExternalModule extends Module {
if (sourceData.init) if (sourceData.init)
sourceString = `${sourceData.init}\n${sourceString}`; sourceString = `${sourceData.init}\n${sourceString}`;
let data = undefined; let data;
if (sourceData.chunkInitFragments) { if (sourceData.chunkInitFragments) {
data = new Map(); data = new Map();
data.set("chunkInitFragments", sourceData.chunkInitFragments); data.set("chunkInitFragments", sourceData.chunkInitFragments);

View File

@ -573,7 +573,7 @@ class SnapshotOptimization {
}; };
/** @type {SnapshotOptimizationEntry | undefined} */ /** @type {SnapshotOptimizationEntry | undefined} */
let newOptimizationEntry = undefined; let newOptimizationEntry;
const capturedFilesSize = capturedFiles.size; const capturedFilesSize = capturedFiles.size;
@ -2501,7 +2501,7 @@ class FileSystemInfo {
*/ */
_checkSnapshotValidNoCache(snapshot, callback) { _checkSnapshotValidNoCache(snapshot, callback) {
/** @type {number | undefined} */ /** @type {number | undefined} */
let startTime = undefined; let startTime;
if (snapshot.hasStartTime()) { if (snapshot.hasStartTime()) {
startTime = snapshot.startTime; startTime = snapshot.startTime;
} }
@ -3181,7 +3181,7 @@ class FileSystemInfo {
}); });
}, },
reduce: (files, tsEntries) => { reduce: (files, tsEntries) => {
let symlinks = undefined; let symlinks;
const hash = createHash(this._hashFunction); const hash = createHash(this._hashFunction);
@ -3306,7 +3306,7 @@ class FileSystemInfo {
* @returns {ContextHash} reduced hash * @returns {ContextHash} reduced hash
*/ */
reduce: (files, fileHashes) => { reduce: (files, fileHashes) => {
let symlinks = undefined; let symlinks;
const hash = createHash(this._hashFunction); const hash = createHash(this._hashFunction);
for (const file of files) hash.update(file); for (const file of files) hash.update(file);
@ -3437,7 +3437,7 @@ class FileSystemInfo {
* @returns {ContextTimestampAndHash} tsh * @returns {ContextTimestampAndHash} tsh
*/ */
reduce: (files, results) => { reduce: (files, results) => {
let symlinks = undefined; let symlinks;
const tsHash = createHash(this._hashFunction); const tsHash = createHash(this._hashFunction);
const hash = createHash(this._hashFunction); const hash = createHash(this._hashFunction);

View File

@ -30,7 +30,7 @@ class FlagAllModulesAsUsedPlugin {
const moduleGraph = compilation.moduleGraph; const moduleGraph = compilation.moduleGraph;
compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => { compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => {
/** @type {RuntimeSpec} */ /** @type {RuntimeSpec} */
let runtime = undefined; let runtime;
for (const [name, { options }] of compilation.entries) { for (const [name, { options }] of compilation.entries) {
runtime = mergeRuntimeOwned( runtime = mergeRuntimeOwned(
runtime, runtime,

View File

@ -189,9 +189,9 @@ class FlagDependencyExportsPlugin {
let name; let name;
let canMangle = globalCanMangle; let canMangle = globalCanMangle;
let terminalBinding = globalTerminalBinding; let terminalBinding = globalTerminalBinding;
let exports = undefined; let exports;
let from = globalFrom; let from = globalFrom;
let fromExport = undefined; let fromExport;
let priority = globalPriority; let priority = globalPriority;
let hidden = false; let hidden = false;
if (typeof exportNameOrSpec === "string") { if (typeof exportNameOrSpec === "string") {
@ -261,7 +261,7 @@ class FlagDependencyExportsPlugin {
// Recalculate target exportsInfo // Recalculate target exportsInfo
const target = exportInfo.getTarget(moduleGraph); const target = exportInfo.getTarget(moduleGraph);
let targetExportsInfo = undefined; let targetExportsInfo;
if (target) { if (target) {
const targetModuleExportsInfo = const targetModuleExportsInfo =
moduleGraph.getExportsInfo(target.module); moduleGraph.getExportsInfo(target.module);

View File

@ -308,7 +308,7 @@ class FlagDependencyUsagePlugin {
} }
}; };
/** @type {RuntimeSpec} */ /** @type {RuntimeSpec} */
let globalRuntime = undefined; let globalRuntime;
for (const [ for (const [
entryName, entryName,
{ dependencies: deps, includeDependencies: includeDeps, options } { dependencies: deps, includeDependencies: includeDeps, options }

View File

@ -19,7 +19,7 @@ class ModuleBuildError extends WebpackError {
*/ */
constructor(err, { from = null } = {}) { constructor(err, { from = null } = {}) {
let message = "Module build failed"; let message = "Module build failed";
let details = undefined; let details;
if (from) { if (from) {
message += ` (from ${from}):\n`; message += ` (from ${from}):\n`;

View File

@ -36,7 +36,7 @@ const getConnectionsByOriginModule = set => {
/** @type {Module | 0} */ /** @type {Module | 0} */
let lastModule = 0; let lastModule = 0;
/** @type {ModuleGraphConnection[] | undefined} */ /** @type {ModuleGraphConnection[] | undefined} */
let lastList = undefined; let lastList;
for (const connection of set) { for (const connection of set) {
const { originModule } = connection; const { originModule } = connection;
if (lastModule === originModule) { if (lastModule === originModule) {
@ -67,7 +67,7 @@ const getConnectionsByModule = set => {
/** @type {Module | 0} */ /** @type {Module | 0} */
let lastModule = 0; let lastModule = 0;
/** @type {ModuleGraphConnection[] | undefined} */ /** @type {ModuleGraphConnection[] | undefined} */
let lastList = undefined; let lastList;
for (const connection of set) { for (const connection of set) {
const { module } = connection; const { module } = connection;
if (lastModule === module) { if (lastModule === module) {

View File

@ -22,7 +22,7 @@ class ModuleParseError extends WebpackError {
*/ */
constructor(source, err, loaders, type) { constructor(source, err, loaders, type) {
let message = "Module parse failed: " + (err && err.message); let message = "Module parse failed: " + (err && err.message);
let loc = undefined; let loc;
if ( if (
((Buffer.isBuffer(source) && source.slice(0, 4).equals(WASM_HEADER)) || ((Buffer.isBuffer(source) && source.slice(0, 4).equals(WASM_HEADER)) ||

View File

@ -1138,7 +1138,7 @@ class NormalModule extends Module {
// add warning for all non-absolute paths in fileDependencies, etc // add warning for all non-absolute paths in fileDependencies, etc
// This makes it easier to find problems with watching and/or caching // This makes it easier to find problems with watching and/or caching
/** @type {undefined | Set<string>} */ /** @type {undefined | Set<string>} */
let nonAbsoluteDependencies = undefined; let nonAbsoluteDependencies;
/** /**
* @param {LazySet<string>} deps deps * @param {LazySet<string>} deps deps
*/ */

View File

@ -426,7 +426,7 @@ class NormalModuleFactory extends ModuleFactory {
const loaderResolver = this.getResolver("loader"); const loaderResolver = this.getResolver("loader");
/** @type {ResourceData | undefined} */ /** @type {ResourceData | undefined} */
let matchResourceData = undefined; let matchResourceData;
/** @type {string} */ /** @type {string} */
let unresolvedResource; let unresolvedResource;
/** @type {ParsedLoaderRequest[]} */ /** @type {ParsedLoaderRequest[]} */

View File

@ -255,7 +255,7 @@ class Watching {
(compilation && compilation.getLogger("webpack.Watching")); (compilation && compilation.getLogger("webpack.Watching"));
/** @type {Stats | undefined} */ /** @type {Stats | undefined} */
let stats = undefined; let stats;
/** /**
* @param {Error} err error * @param {Error} err error

View File

@ -137,7 +137,7 @@ class AssetModulesPlugin {
.tap(plugin, generatorOptions => { .tap(plugin, generatorOptions => {
validateGeneratorOptions[type](generatorOptions); validateGeneratorOptions[type](generatorOptions);
let dataUrl = undefined; let dataUrl;
if (type !== ASSET_MODULE_TYPE_RESOURCE) { if (type !== ASSET_MODULE_TYPE_RESOURCE) {
dataUrl = generatorOptions.dataUrl; dataUrl = generatorOptions.dataUrl;
if (!dataUrl || typeof dataUrl === "object") { if (!dataUrl || typeof dataUrl === "object") {
@ -149,9 +149,9 @@ class AssetModulesPlugin {
} }
} }
let filename = undefined; let filename;
let publicPath = undefined; let publicPath;
let outputPath = undefined; let outputPath;
if (type !== ASSET_MODULE_TYPE_INLINE) { if (type !== ASSET_MODULE_TYPE_INLINE) {
filename = generatorOptions.filename; filename = generatorOptions.filename;
publicPath = generatorOptions.publicPath; publicPath = generatorOptions.publicPath;

View File

@ -175,7 +175,7 @@ class IdleFileCachePlugin {
} }
}; };
/** @type {ReturnType<typeof setTimeout> | undefined} */ /** @type {ReturnType<typeof setTimeout> | undefined} */
let idleTimer = undefined; let idleTimer;
compiler.cache.hooks.beginIdle.tap( compiler.cache.hooks.beginIdle.tap(
{ name: "IdleFileCachePlugin", stage: Cache.STAGE_DISK }, { name: "IdleFileCachePlugin", stage: Cache.STAGE_DISK },
() => { () => {

View File

@ -527,7 +527,7 @@ class Pack {
*/ */
_gcOldestContent() { _gcOldestContent() {
/** @type {PackItemInfo | undefined} */ /** @type {PackItemInfo | undefined} */
let oldest = undefined; let oldest;
for (const info of this.itemInfo.values()) { for (const info of this.itemInfo.values()) {
if (oldest === undefined || info.lastAccess < oldest.lastAccess) { if (oldest === undefined || info.lastAccess < oldest.lastAccess) {
oldest = info; oldest = info;

View File

@ -124,7 +124,7 @@ const A = (obj, prop, factory) => {
obj[prop] = factory(); obj[prop] = factory();
} else if (Array.isArray(value)) { } else if (Array.isArray(value)) {
/** @type {any[] | undefined} */ /** @type {any[] | undefined} */
let newArray = undefined; let newArray;
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
const item = value[i]; const item = value[i];
if (item === "...") { if (item === "...") {

View File

@ -508,7 +508,7 @@ class CssModulesPlugin {
} }
/** @type {Module} */ /** @type {Module} */
let selectedModule = list[list.length - 1]; let selectedModule = list[list.length - 1];
let hasFailed = undefined; let hasFailed;
outer: for (;;) { outer: for (;;) {
for (const { list, set } of modulesByChunkGroup) { for (const { list, set } of modulesByChunkGroup) {
if (list.length === 0) continue; if (list.length === 0) continue;

View File

@ -201,13 +201,13 @@ class CssParser extends Parser {
/** @type {boolean} */ /** @type {boolean} */
let allowImportAtRule = true; let allowImportAtRule = true;
/** @type {"local" | "global" | undefined} */ /** @type {"local" | "global" | undefined} */
let modeData = undefined; let modeData;
/** @type {[number, number] | undefined} */ /** @type {[number, number] | undefined} */
let lastIdentifier = undefined; let lastIdentifier;
/** @type [string, number, number][] */ /** @type [string, number, number][] */
const balanced = []; const balanced = [];
/** @type {undefined | { start: number, url?: string, urlStart?: number, urlEnd?: number, layer?: string, layerStart?: number, layerEnd?: number, supports?: string, supportsStart?: number, supportsEnd?: number, inSupports?:boolean, media?: string }} */ /** @type {undefined | { start: number, url?: string, urlStart?: number, urlEnd?: number, layer?: string, layerStart?: number, layerEnd?: number, supports?: string, supportsStart?: number, supportsEnd?: number, inSupports?:boolean, media?: string }} */
let importData = undefined; let importData;
/** @type {boolean} */ /** @type {boolean} */
let inAnimationProperty = false; let inAnimationProperty = false;
/** @type {boolean} */ /** @type {boolean} */

View File

@ -36,7 +36,7 @@ const validate = createSchemaValidation(
); );
/** @type {Inspector | undefined} */ /** @type {Inspector | undefined} */
let inspector = undefined; let inspector;
try { try {
// eslint-disable-next-line n/no-unsupported-features/node-builtins // eslint-disable-next-line n/no-unsupported-features/node-builtins

View File

@ -22,7 +22,7 @@ module.exports.handleDependencyBase = (
module, module,
runtimeRequirements runtimeRequirements
) => { ) => {
let base = undefined; let base;
let type; let type;
switch (depBase) { switch (depBase) {
case "exports": case "exports":

View File

@ -120,7 +120,7 @@ CommonJsSelfReferenceDependency.Template = class CommonJsSelfReferenceDependency
); );
} }
let base = undefined; let base;
switch (dep.base) { switch (dep.base) {
case "exports": case "exports":
runtimeRequirements.add(RuntimeGlobals.exports); runtimeRequirements.add(RuntimeGlobals.exports);

View File

@ -444,7 +444,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
const ignoredExports = new Set(["default", ...this.activeExports]); const ignoredExports = new Set(["default", ...this.activeExports]);
let hiddenExports = undefined; let hiddenExports;
const otherStarExports = const otherStarExports =
this._discoverActiveExportsFromOtherStarExports(moduleGraph); this._discoverActiveExportsFromOtherStarExports(moduleGraph);
if (otherStarExports !== undefined) { if (otherStarExports !== undefined) {

View File

@ -1210,9 +1210,9 @@ class JavascriptParser extends Parser {
*/ */
const tapEvaluateWithVariableInfo = (exprType, getInfo) => { const tapEvaluateWithVariableInfo = (exprType, getInfo) => {
/** @type {Expression | undefined} */ /** @type {Expression | undefined} */
let cachedExpression = undefined; let cachedExpression;
/** @type {GetInfoResult | undefined} */ /** @type {GetInfoResult | undefined} */
let cachedInfo = undefined; let cachedInfo;
this.hooks.evaluate.for(exprType).tap("JavascriptParser", expr => { this.hooks.evaluate.for(exprType).tap("JavascriptParser", expr => {
const expression = /** @type {MemberExpression} */ (expr); const expression = /** @type {MemberExpression} */ (expr);

View File

@ -71,8 +71,8 @@ module.exports.generateEntryStartup = (
} }
}; };
let currentChunks = undefined; let currentChunks;
let currentModuleIds = undefined; let currentModuleIds;
for (const [module, entrypoint] of entries) { for (const [module, entrypoint] of entries) {
const runtimeChunk = const runtimeChunk =

View File

@ -19,7 +19,7 @@ const truncateArgs = require("../logging/truncateArgs");
*/ */
module.exports = ({ colors, appendOnly, stream }) => { module.exports = ({ colors, appendOnly, stream }) => {
/** @type {string[] | undefined} */ /** @type {string[] | undefined} */
let currentStatusMessage = undefined; let currentStatusMessage;
let hasStatusMessage = false; let hasStatusMessage = false;
let currentIndent = ""; let currentIndent = "";
let currentCollapsed = 0; let currentCollapsed = 0;

View File

@ -74,7 +74,7 @@ class FlagIncludedChunksPlugin {
const chunkAModulesCount = const chunkAModulesCount =
chunkGraph.getNumberOfChunkModules(chunkA); chunkGraph.getNumberOfChunkModules(chunkA);
if (chunkAModulesCount === 0) continue; if (chunkAModulesCount === 0) continue;
let bestModule = undefined; let bestModule;
for (const module of chunkGraph.getChunkModulesIterable(chunkA)) { for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
if ( if (
bestModule === undefined || bestModule === undefined ||

View File

@ -278,7 +278,7 @@ class ModuleConcatenationPlugin {
// TODO reconsider that when it's only used in a different runtime // TODO reconsider that when it's only used in a different runtime
if (usedAsInner.has(currentRoot)) continue; if (usedAsInner.has(currentRoot)) continue;
let chunkRuntime = undefined; let chunkRuntime;
for (const r of chunkGraph.getModuleRuntimes(currentRoot)) { for (const r of chunkGraph.getModuleRuntimes(currentRoot)) {
chunkRuntime = mergeRuntimeOwned(chunkRuntime, r); chunkRuntime = mergeRuntimeOwned(chunkRuntime, r);
} }
@ -675,7 +675,7 @@ class ModuleConcatenationPlugin {
if (chunkGraph.getNumberOfModuleChunks(originModule) === 0) continue; if (chunkGraph.getNumberOfModuleChunks(originModule) === 0) continue;
// We don't care for connections from other runtimes // We don't care for connections from other runtimes
let originRuntime = undefined; let originRuntime;
for (const r of chunkGraph.getModuleRuntimes(originModule)) { for (const r of chunkGraph.getModuleRuntimes(originModule)) {
originRuntime = mergeRuntimeOwned(originRuntime, r); originRuntime = mergeRuntimeOwned(originRuntime, r);
} }

View File

@ -60,7 +60,7 @@ const proxyFetch = (request, proxy) => (url, options, callback) => {
}; };
/** @type {(() => void)[] | undefined} */ /** @type {(() => void)[] | undefined} */
let inProgressWrite = undefined; let inProgressWrite;
const validate = createSchemaValidation( const validate = createSchemaValidation(
require("../../schemas/plugins/schemes/HttpUriPlugin.check.js"), require("../../schemas/plugins/schemes/HttpUriPlugin.check.js"),
@ -239,11 +239,11 @@ class Lockfile {
const cachedWithoutKey = fn => { const cachedWithoutKey = fn => {
let inFlight = false; let inFlight = false;
/** @type {Error | undefined} */ /** @type {Error | undefined} */
let cachedError = undefined; let cachedError;
/** @type {R | undefined} */ /** @type {R | undefined} */
let cachedResult = undefined; let cachedResult;
/** @type {(function(Error=, R=): void)[] | undefined} */ /** @type {(function(Error=, R=): void)[] | undefined} */
let cachedCallbacks = undefined; let cachedCallbacks;
return callback => { return callback => {
if (inFlight) { if (inFlight) {
if (cachedResult !== undefined) return callback(null, cachedResult); if (cachedResult !== undefined) return callback(null, cachedResult);
@ -481,7 +481,7 @@ class HttpUriPlugin {
); );
/** @type {Map<string, LockfileEntry | "ignore" | "no-cache"> | undefined} */ /** @type {Map<string, LockfileEntry | "ignore" | "no-cache"> | undefined} */
let lockfileUpdates = undefined; let lockfileUpdates;
/** /**
* @param {Lockfile} lockfile lockfile instance * @param {Lockfile} lockfile lockfile instance

View File

@ -105,7 +105,7 @@ const serialize = async (
/** @type {WeakMap<SerializeResult, function(): any | Promise<any>>} */ /** @type {WeakMap<SerializeResult, function(): any | Promise<any>>} */
const resultToLazy = new WeakMap(); const resultToLazy = new WeakMap();
/** @type {Buffer[]} */ /** @type {Buffer[]} */
let lastBuffers = undefined; let lastBuffers;
for (const item of await data) { for (const item of await data) {
if (typeof item === "function") { if (typeof item === "function") {
if (!SerializerMiddleware.isLazy(item)) if (!SerializerMiddleware.isLazy(item))

View File

@ -589,7 +589,7 @@ const SIMPLE_EXTRACTORS = {
if (depthInCollapsedGroup > 0) depthInCollapsedGroup--; if (depthInCollapsedGroup > 0) depthInCollapsedGroup--;
continue; continue;
} }
let message = undefined; let message;
if (entry.type === LogType.time) { if (entry.type === LogType.time) {
message = `${entry.args[0]}: ${ message = `${entry.args[0]}: ${
entry.args[1] * 1000 + entry.args[2] / 1000000 entry.args[1] * 1000 + entry.args[2] / 1000000
@ -1689,9 +1689,9 @@ const spaceLimited = (
}; };
} }
/** @type {any[] | undefined} */ /** @type {any[] | undefined} */
let children = undefined; let children;
/** @type {number | undefined} */ /** @type {number | undefined} */
let filteredChildren = undefined; let filteredChildren;
// This are the groups, which take 1+ lines each // This are the groups, which take 1+ lines each
const groups = []; const groups = [];
// The sizes of the groups are stored in groupSizes // The sizes of the groups are stored in groupSizes

View File

@ -5,7 +5,7 @@
"use strict"; "use strict";
const binarySearchBounds = require("../util/binarySearchBounds"); const binarySearchBounds = require("./binarySearchBounds");
/** @typedef {function(number): void} Callback */ /** @typedef {function(number): void} Callback */

View File

@ -103,7 +103,7 @@ class TupleSet {
[Symbol.iterator]() { [Symbol.iterator]() {
const iteratorStack = []; const iteratorStack = [];
const tuple = []; const tuple = [];
let currentSetIterator = undefined; let currentSetIterator;
const next = it => { const next = it => {
const result = it.next(); const result = it.next();

View File

@ -133,13 +133,13 @@ class DebugHash extends Hash {
} }
/** @type {typeof import("crypto") | undefined} */ /** @type {typeof import("crypto") | undefined} */
let crypto = undefined; let crypto;
/** @type {typeof import("./hash/xxhash64") | undefined} */ /** @type {typeof import("./hash/xxhash64") | undefined} */
let createXXHash64 = undefined; let createXXHash64;
/** @type {typeof import("./hash/md4") | undefined} */ /** @type {typeof import("./hash/md4") | undefined} */
let createMd4 = undefined; let createMd4;
/** @type {typeof import("./hash/BatchedHash") | undefined} */ /** @type {typeof import("./hash/BatchedHash") | undefined} */
let BatchedHash = undefined; let BatchedHash;
/** /**
* Creates a hash by name or function * Creates a hash by name or function

View File

@ -259,7 +259,7 @@ const getSimilarities = nodes => {
// calculate similarities between lexically adjacent nodes // calculate similarities between lexically adjacent nodes
/** @type {number[]} */ /** @type {number[]} */
const similarities = []; const similarities = [];
let last = undefined; let last;
for (const node of nodes) { for (const node of nodes) {
if (last !== undefined) { if (last !== undefined) {
similarities.push(similarity(last.key, node.key)); similarities.push(similarity(last.key, node.key));

View File

@ -14,7 +14,7 @@
const memoize = fn => { const memoize = fn => {
let cache = false; let cache = false;
/** @type {T | undefined} */ /** @type {T | undefined} */
let result = undefined; let result;
return () => { return () => {
if (cache) { if (cache) {
return /** @type {T} */ (result); return /** @type {T} */ (result);

View File

@ -5,10 +5,7 @@
"use strict"; "use strict";
const { const { SAFE_IDENTIFIER, RESERVED_IDENTIFIER } = require("./propertyName");
SAFE_IDENTIFIER,
RESERVED_IDENTIFIER
} = require("../util/propertyName");
/** /**
* @param {ArrayLike<string>} properties properties * @param {ArrayLike<string>} properties properties

View File

@ -31,7 +31,7 @@ module.exports.getEntryRuntime = (compilation, name, options) => {
} }
if (dependOn) { if (dependOn) {
/** @type {RuntimeSpec} */ /** @type {RuntimeSpec} */
let result = undefined; let result;
const queue = new Set(dependOn); const queue = new Set(dependOn);
for (const name of queue) { for (const name of queue) {
const dep = compilation.entries.get(name); const dep = compilation.entries.get(name);
@ -396,7 +396,7 @@ module.exports.filterRuntime = (runtime, filter) => {
if (typeof runtime === "string") return filter(runtime); if (typeof runtime === "string") return filter(runtime);
let some = false; let some = false;
let every = true; let every = true;
let result = undefined; let result;
for (const r of runtime) { for (const r of runtime) {
const v = filter(r); const v = filter(r);
if (v) { if (v) {

View File

@ -452,19 +452,15 @@ module.exports.stringifyHoley = json => {
}; };
//#region runtime code: parseVersion //#region runtime code: parseVersion
module.exports.parseVersionRuntimeCode = runtimeTemplate => exports.parseVersionRuntimeCode = runtimeTemplate =>
`var parseVersion = ${runtimeTemplate.basicFunction("str", [ `var parseVersion = ${runtimeTemplate.basicFunction("str", [
"// see webpack/lib/util/semver.js for original code", "// see webpack/lib/util/semver.js for original code",
`var p=${ `var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map((${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"
}{return p.split(".").map((${
runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"
}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
])}`; ])}`;
//#endregion //#endregion
//#region runtime code: versionLt //#region runtime code: versionLt
module.exports.versionLtRuntimeCode = runtimeTemplate => exports.versionLtRuntimeCode = runtimeTemplate =>
`var versionLt = ${runtimeTemplate.basicFunction("a, b", [ `var versionLt = ${runtimeTemplate.basicFunction("a, b", [
"// see webpack/lib/util/semver.js for original code", "// see webpack/lib/util/semver.js for original code",
'a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var e=a[r],n=(typeof e)[0];if(r>=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e<t;r++}' 'a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var e=a[r],n=(typeof e)[0];if(r>=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e<t;r++}'
@ -472,7 +468,7 @@ module.exports.versionLtRuntimeCode = runtimeTemplate =>
//#endregion //#endregion
//#region runtime code: rangeToString //#region runtime code: rangeToString
module.exports.rangeToStringRuntimeCode = runtimeTemplate => exports.rangeToStringRuntimeCode = runtimeTemplate =>
`var rangeToString = ${runtimeTemplate.basicFunction("range", [ `var rangeToString = ${runtimeTemplate.basicFunction("range", [
"// see webpack/lib/util/semver.js for original code", "// see webpack/lib/util/semver.js for original code",
'var r=range[0],n="";if(1===range.length)return"*";if(r+.5){n+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){e--,n+="u"==(typeof(t=range[a]))[0]?"-":(e>0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+o()+")":1===t?"("+o()+" || "+o()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return o();function o(){return g.pop().replace(/^\\((.+)\\)$/,"$1")}' 'var r=range[0],n="";if(1===range.length)return"*";if(r+.5){n+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){e--,n+="u"==(typeof(t=range[a]))[0]?"-":(e>0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+o()+")":1===t?"("+o()+" || "+o()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return o();function o(){return g.pop().replace(/^\\((.+)\\)$/,"$1")}'
@ -480,7 +476,7 @@ module.exports.rangeToStringRuntimeCode = runtimeTemplate =>
//#endregion //#endregion
//#region runtime code: satisfy //#region runtime code: satisfy
module.exports.satisfyRuntimeCode = runtimeTemplate => exports.satisfyRuntimeCode = runtimeTemplate =>
`var satisfy = ${runtimeTemplate.basicFunction("range, version", [ `var satisfy = ${runtimeTemplate.basicFunction("range, version", [
"// see webpack/lib/util/semver.js for original code", "// see webpack/lib/util/semver.js for original code",
'if(0 in range){version=parseVersion(version);var e=range[0],r=e<0;r&&(e=-e-1);for(var n=0,i=1,a=!0;;i++,n++){var f,s,g=i<range.length?(typeof range[i])[0]:"";if(n>=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f<range[i])return!1;f!=range[i]&&(a=!1)}else if("s"!=g&&"n"!=g){if(r||i<=e)return!1;a=!1,i--}else{if(i<=e||s<g!=r)return!1;a=!1}else"s"!=g&&"n"!=g&&(a=!1,i--)}}var t=[],o=t.pop.bind(t);for(n=1;n<range.length;n++){var u=range[n];t.push(1==u?o()|o():2==u?o()&o():u?satisfy(u,version):!o())}return!!o();' 'if(0 in range){version=parseVersion(version);var e=range[0],r=e<0;r&&(e=-e-1);for(var n=0,i=1,a=!0;;i++,n++){var f,s,g=i<range.length?(typeof range[i])[0]:"";if(n>=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f<range[i])return!1;f!=range[i]&&(a=!1)}else if("s"!=g&&"n"!=g){if(r||i<=e)return!1;a=!1,i--}else{if(i<=e||s<g!=r)return!1;a=!1}else"s"!=g&&"n"!=g&&(a=!1,i--)}}var t=[],o=t.pop.bind(t);for(n=1;n<range.length;n++){var u=range[n];t.push(1==u?o()|o():2==u?o()&o():u?satisfy(u,version):!o())}return!!o();'

View File

@ -111,10 +111,10 @@ const smartGrouping = (items, groupConfigs) => {
const results = []; const results = [];
for (;;) { for (;;) {
/** @type {Group<T, R> | undefined} */ /** @type {Group<T, R> | undefined} */
let bestGroup = undefined; let bestGroup;
let bestGroupSize = -1; let bestGroupSize = -1;
let bestGroupItems = undefined; let bestGroupItems;
let bestGroupOptions = undefined; let bestGroupOptions;
for (const [group, state] of groupMap) { for (const [group, state] of groupMap) {
const { items, used } = state; const { items, used } = state;
let options = state.options; let options = state.options;

View File

@ -187,7 +187,7 @@ class FakeSheet {
const walkCssTokens = require("../../lib/css/walkCssTokens"); const walkCssTokens = require("../../lib/css/walkCssTokens");
const rules = []; const rules = [];
let currentRule = { getPropertyValue }; let currentRule = { getPropertyValue };
let selector = undefined; let selector;
let last = 0; let last = 0;
const processDeclaration = str => { const processDeclaration = str => {
const colon = str.indexOf(":"); const colon = str.indexOf(":");

View File

@ -7,7 +7,7 @@
const util = require("util"); const util = require("util");
let interception = undefined; let interception;
const originalDeprecate = util.deprecate; const originalDeprecate = util.deprecate;
util.deprecate = (fn, message, code) => { util.deprecate = (fn, message, code) => {