mirror of https://github.com/webpack/webpack.git
chore: fix lint and types
This commit is contained in:
parent
7acd348938
commit
1954237716
|
@ -77,6 +77,12 @@ module.exports = [
|
|||
"no-inner-declarations": "error",
|
||||
"no-loop-func": "off",
|
||||
"n/no-missing-require": ["error", { allowModules: ["webpack"] }],
|
||||
"n/no-unsupported-features/node-builtins": [
|
||||
"error",
|
||||
{
|
||||
ignores: ["zlib.createBrotliCompress", "zlib.createBrotliDecompress"]
|
||||
}
|
||||
],
|
||||
"jsdoc/check-alignment": "off",
|
||||
"jsdoc/tag-lines": "off",
|
||||
// TODO enable me
|
||||
|
@ -182,7 +188,6 @@ module.exports = [
|
|||
"n/no-unsupported-features/node-builtins": [
|
||||
"error",
|
||||
{
|
||||
version: ">=10.13.0",
|
||||
allowExperimental: true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -114,8 +114,8 @@ class ConcatenationScope {
|
|||
const asiSafeFlag = asiSafe
|
||||
? "_asiSafe1"
|
||||
: asiSafe === false
|
||||
? "_asiSafe0"
|
||||
: "";
|
||||
? "_asiSafe0"
|
||||
: "";
|
||||
const exportData = ids
|
||||
? Buffer.from(JSON.stringify(ids), "utf-8").toString("hex")
|
||||
: "ns";
|
||||
|
|
|
@ -532,8 +532,8 @@ class ContextModule extends Module {
|
|||
this.context
|
||||
? [this.context]
|
||||
: typeof this.options.resource === "string"
|
||||
? [this.options.resource]
|
||||
: /** @type {string[]} */ (this.options.resource),
|
||||
? [this.options.resource]
|
||||
: /** @type {string[]} */ (this.options.resource),
|
||||
null,
|
||||
SNAPSHOT_OPTIONS,
|
||||
(err, snapshot) => {
|
||||
|
@ -992,8 +992,8 @@ module.exports = webpackAsyncContext;`;
|
|||
const requestPrefix = hasNoChunk
|
||||
? "Promise.resolve()"
|
||||
: hasMultipleOrNoChunks
|
||||
? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))`
|
||||
: `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`;
|
||||
? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))`
|
||||
: `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`;
|
||||
const returnModuleObject = this.getReturnModuleObjectSource(
|
||||
fakeMap,
|
||||
true,
|
||||
|
|
|
@ -93,7 +93,7 @@ class EvalDevToolModulePlugin {
|
|||
compilation.outputOptions.trustedTypes
|
||||
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
||||
content + footer
|
||||
)})`
|
||||
)})`
|
||||
: JSON.stringify(content + footer)
|
||||
});`
|
||||
);
|
||||
|
|
|
@ -175,7 +175,7 @@ const getSourceForImportExternal = (
|
|||
? `, { assert: ${JSON.stringify(
|
||||
dependencyMeta.attributes,
|
||||
importAssertionReplacer
|
||||
)} }`
|
||||
)} }`
|
||||
: `, { with: ${JSON.stringify(dependencyMeta.attributes)} }`
|
||||
: "";
|
||||
if (!Array.isArray(moduleAndSpecifiers)) {
|
||||
|
@ -244,7 +244,7 @@ class ModuleExternalInitFragment extends InitFragment {
|
|||
? ` assert ${JSON.stringify(
|
||||
dependencyMeta.attributes,
|
||||
importAssertionReplacer
|
||||
)}`
|
||||
)}`
|
||||
: ` with ${JSON.stringify(dependencyMeta.attributes)}`
|
||||
: ""
|
||||
};\n`,
|
||||
|
@ -360,10 +360,10 @@ const getSourceForModuleExternal = (
|
|||
? `var x = ${runtimeTemplate.basicFunction(
|
||||
"y",
|
||||
`var x = {}; ${RuntimeGlobals.definePropertyGetters}(x, y); return x`
|
||||
)} \nvar y = ${runtimeTemplate.returningFunction(
|
||||
)} \nvar y = ${runtimeTemplate.returningFunction(
|
||||
runtimeTemplate.returningFunction("x"),
|
||||
"x"
|
||||
)}`
|
||||
)}`
|
||||
: undefined,
|
||||
runtimeRequirements: moduleRemapping
|
||||
? RUNTIME_REQUIREMENTS_FOR_MODULE
|
||||
|
@ -443,7 +443,7 @@ const getSourceForAmdOrUmdExternal = (
|
|||
externalVariable,
|
||||
Array.isArray(request) ? request.join(".") : request,
|
||||
runtimeTemplate
|
||||
)
|
||||
)
|
||||
: undefined,
|
||||
expression: externalVariable
|
||||
};
|
||||
|
@ -703,7 +703,7 @@ class ExternalModule extends Module {
|
|||
/** @type {string} */
|
||||
(runtimeTemplate.outputOptions.importMetaName),
|
||||
runtimeTemplate.supportNodePrefixForCoreModules()
|
||||
)
|
||||
)
|
||||
: getSourceForCommonJsExternal(request);
|
||||
case "amd":
|
||||
case "amd-require":
|
||||
|
|
|
@ -3389,7 +3389,7 @@ class FileSystemInfo {
|
|||
: {
|
||||
...timestamp,
|
||||
...hash
|
||||
};
|
||||
};
|
||||
this._contextTshs.set(path, result);
|
||||
callback(null, result);
|
||||
};
|
||||
|
|
|
@ -500,7 +500,7 @@ class HotModuleReplacementPlugin {
|
|||
: compilation.codeGenerationResults.getHash(
|
||||
module,
|
||||
chunk.runtime
|
||||
);
|
||||
);
|
||||
if (records.chunkModuleHashes[key] !== hash) {
|
||||
updatedModules.add(module, chunk);
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ class HotModuleReplacementPlugin {
|
|||
: compilation.codeGenerationResults.getHash(
|
||||
module,
|
||||
newRuntime
|
||||
);
|
||||
);
|
||||
if (hash !== oldHash) {
|
||||
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
||||
newRuntimeModules = newRuntimeModules || [];
|
||||
|
@ -798,7 +798,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|||
Array.from(removedModules, m =>
|
||||
chunkGraph.getModuleId(m)
|
||||
)
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
const source = new RawSource(JSON.stringify(hotUpdateMainJson));
|
||||
|
|
|
@ -164,7 +164,7 @@ ModuleFilenameHelpers.createFilename = (
|
|||
? options
|
||||
: {
|
||||
moduleFilenameTemplate: options
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
let absoluteResourcePath;
|
||||
|
|
|
@ -142,14 +142,14 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
|
|||
const mapper = !sourceRoot
|
||||
? source => source
|
||||
: sourceRoot.endsWith("/")
|
||||
? source =>
|
||||
source.startsWith("/")
|
||||
? `${sourceRoot.slice(0, -1)}${source}`
|
||||
: `${sourceRoot}${source}`
|
||||
: source =>
|
||||
source.startsWith("/")
|
||||
? `${sourceRoot}${source}`
|
||||
: `${sourceRoot}/${source}`;
|
||||
? source =>
|
||||
source.startsWith("/")
|
||||
? `${sourceRoot.slice(0, -1)}${source}`
|
||||
: `${sourceRoot}${source}`
|
||||
: source =>
|
||||
source.startsWith("/")
|
||||
? `${sourceRoot}${source}`
|
||||
: `${sourceRoot}/${source}`;
|
||||
const newSources = sourceMap.sources.map(source =>
|
||||
contextifySourceUrl(context, mapper(source), associatedObjectForCache)
|
||||
);
|
||||
|
@ -859,7 +859,7 @@ class NormalModule extends Module {
|
|||
currentLoader
|
||||
? compilation.runtimeTemplate.requestShortener.shorten(
|
||||
currentLoader.loader
|
||||
)
|
||||
)
|
||||
: "unknown"
|
||||
}) didn't return a Buffer or String`
|
||||
);
|
||||
|
@ -1156,10 +1156,10 @@ class NormalModule extends Module {
|
|||
if (absolute !== dep && ABSOLUTE_PATH_REGEX.test(absolute)) {
|
||||
(depWithoutGlob !== dep
|
||||
? /** @type {NonNullable<KnownBuildInfo["contextDependencies"]>} */
|
||||
(
|
||||
(
|
||||
/** @type {BuildInfo} */ (this.buildInfo)
|
||||
.contextDependencies
|
||||
)
|
||||
)
|
||||
: deps
|
||||
).add(absolute);
|
||||
}
|
||||
|
@ -1352,7 +1352,7 @@ class NormalModule extends Module {
|
|||
const source = this.error
|
||||
? new RawSource(
|
||||
"throw new Error(" + JSON.stringify(this.error.message) + ");"
|
||||
)
|
||||
)
|
||||
: /** @type {Generator} */ (this.generator).generate(this, {
|
||||
dependencyTemplates,
|
||||
runtimeTemplate,
|
||||
|
@ -1364,7 +1364,7 @@ class NormalModule extends Module {
|
|||
codeGenerationResults,
|
||||
getData,
|
||||
type
|
||||
});
|
||||
});
|
||||
|
||||
if (source) {
|
||||
sources.set(type, new CachedSource(source));
|
||||
|
|
|
@ -479,8 +479,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
noPreAutoLoaders || noPrePostAutoLoaders
|
||||
? 2
|
||||
: noAutoLoaders
|
||||
? 1
|
||||
: 0
|
||||
? 1
|
||||
: 0
|
||||
)
|
||||
.split(/!+/);
|
||||
unresolvedResource = /** @type {string} */ (rawElements.pop());
|
||||
|
@ -763,7 +763,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
||||
"dependencyType",
|
||||
dependencyType
|
||||
)
|
||||
)
|
||||
: resolveOptions
|
||||
);
|
||||
this.resolveResource(
|
||||
|
@ -1178,12 +1178,12 @@ If changing the source code is not an option there is also a resolve options cal
|
|||
const type = /\.mjs$/i.test(parsedResult.path)
|
||||
? "module"
|
||||
: /\.cjs$/i.test(parsedResult.path)
|
||||
? "commonjs"
|
||||
: /** @type {ResolveRequest} */
|
||||
(resolveRequest).descriptionFileData === undefined
|
||||
? undefined
|
||||
: /** @type {ResolveRequest} */
|
||||
(resolveRequest).descriptionFileData.type;
|
||||
? "commonjs"
|
||||
: /** @type {ResolveRequest} */
|
||||
(resolveRequest).descriptionFileData === undefined
|
||||
? undefined
|
||||
: /** @type {ResolveRequest} */
|
||||
(resolveRequest).descriptionFileData.type;
|
||||
const resolved = {
|
||||
loader: parsedResult.path,
|
||||
type,
|
||||
|
|
|
@ -8,12 +8,7 @@
|
|||
const EventEmitter = require("events");
|
||||
const { extname, basename } = require("path");
|
||||
const { URL } = require("url");
|
||||
const {
|
||||
createGunzip,
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
createBrotliDecompress,
|
||||
createInflate
|
||||
} = require("zlib");
|
||||
const { createGunzip, createBrotliDecompress, createInflate } = require("zlib");
|
||||
const NormalModule = require("../NormalModule");
|
||||
const createSchemaValidation = require("../util/create-schema-validation");
|
||||
const createHash = require("../util/createHash");
|
||||
|
@ -205,7 +200,7 @@ class Lockfile {
|
|||
: {
|
||||
resolved: key,
|
||||
...entry
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return lockfile;
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
const { constants } = require("buffer");
|
||||
const { pipeline } = require("stream");
|
||||
const {
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
createBrotliCompress,
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
createBrotliDecompress,
|
||||
createGzip,
|
||||
createGunzip,
|
||||
|
@ -62,23 +60,23 @@ const DECOMPRESSION_CHUNK_SIZE = 100 * 1024 * 1024;
|
|||
const writeUInt64LE = Buffer.prototype.writeBigUInt64LE
|
||||
? (buf, value, offset) => {
|
||||
buf.writeBigUInt64LE(BigInt(value), offset);
|
||||
}
|
||||
}
|
||||
: (buf, value, offset) => {
|
||||
const low = value % 0x100000000;
|
||||
const high = (value - low) / 0x100000000;
|
||||
buf.writeUInt32LE(low, offset);
|
||||
buf.writeUInt32LE(high, offset + 4);
|
||||
};
|
||||
};
|
||||
|
||||
const readUInt64LE = Buffer.prototype.readBigUInt64LE
|
||||
? (buf, offset) => {
|
||||
return Number(buf.readBigUInt64LE(offset));
|
||||
}
|
||||
}
|
||||
: (buf, offset) => {
|
||||
const low = buf.readUInt32LE(offset);
|
||||
const high = buf.readUInt32LE(offset + 4);
|
||||
return high * 0x100000000 + low;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} SerializeResult
|
||||
|
|
|
@ -5182,8 +5182,8 @@ declare interface HashedModuleIdsPluginOptions {
|
|||
}
|
||||
declare abstract class HelperRuntimeModule extends RuntimeModule {}
|
||||
declare class HotModuleReplacementPlugin {
|
||||
constructor(options?: Object);
|
||||
options: Object;
|
||||
constructor(options?: object);
|
||||
options: object;
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
|
@ -7328,7 +7328,7 @@ declare interface LibIdentOptions {
|
|||
/**
|
||||
* object for caching
|
||||
*/
|
||||
associatedObjectForCache?: Object;
|
||||
associatedObjectForCache?: object;
|
||||
}
|
||||
declare class LibManifestPlugin {
|
||||
constructor(options: LibManifestPluginOptions);
|
||||
|
@ -8352,8 +8352,8 @@ declare class ModuleGraph {
|
|||
setDepthIfLower(module: Module, depth: number): boolean;
|
||||
isAsync(module: Module): boolean;
|
||||
setAsync(module: Module): void;
|
||||
getMeta(thing?: any): Object;
|
||||
getMetaIfExisting(thing?: any): undefined | Object;
|
||||
getMeta(thing?: any): object;
|
||||
getMetaIfExisting(thing?: any): undefined | object;
|
||||
freeze(cacheStage?: string): void;
|
||||
unfreeze(): void;
|
||||
cached<T extends any[], V>(
|
||||
|
@ -8886,14 +8886,14 @@ declare class NormalModule extends Module {
|
|||
name: string,
|
||||
content: string | Buffer,
|
||||
sourceMap?: string | SourceMap,
|
||||
associatedObjectForCache?: Object
|
||||
associatedObjectForCache?: object
|
||||
): Source;
|
||||
getCurrentLoader(loaderContext?: any, index?: number): null | LoaderItem;
|
||||
createSource(
|
||||
context: string,
|
||||
content: string | Buffer,
|
||||
sourceMap?: string | SourceMapSource,
|
||||
associatedObjectForCache?: Object
|
||||
associatedObjectForCache?: object
|
||||
): Source;
|
||||
markModuleAsErrored(error: WebpackError): void;
|
||||
applyNoParseRule(rule: any, content: string): boolean;
|
||||
|
@ -9027,8 +9027,8 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
|||
ruleSet: RuleSet;
|
||||
context: string;
|
||||
fs: InputFileSystem;
|
||||
parserCache: Map<string, WeakMap<Object, Parser>>;
|
||||
generatorCache: Map<string, WeakMap<Object, Generator>>;
|
||||
parserCache: Map<string, WeakMap<object, Parser>>;
|
||||
generatorCache: Map<string, WeakMap<object, Generator>>;
|
||||
cleanupForCache(): void;
|
||||
resolveResource(
|
||||
contextInfo: ModuleFactoryCreateDataContextInfo,
|
||||
|
@ -11991,7 +11991,7 @@ declare abstract class Resolver {
|
|||
normalize(path: string): string;
|
||||
}
|
||||
declare interface ResolverCache {
|
||||
direct: WeakMap<Object, ResolverWithOptions>;
|
||||
direct: WeakMap<object, ResolverWithOptions>;
|
||||
stringified: Map<string, ResolverWithOptions>;
|
||||
}
|
||||
declare abstract class ResolverFactory {
|
||||
|
@ -13018,11 +13018,11 @@ declare abstract class Serializer {
|
|||
declare abstract class SerializerMiddleware<DeserializedType, SerializedType> {
|
||||
serialize(
|
||||
data: DeserializedType,
|
||||
context: Object
|
||||
context: object
|
||||
): SerializedType | Promise<SerializedType>;
|
||||
deserialize(
|
||||
data: SerializedType,
|
||||
context: Object
|
||||
context: object
|
||||
): DeserializedType | Promise<DeserializedType>;
|
||||
}
|
||||
type ServerOptionsHttps<
|
||||
|
@ -13645,7 +13645,7 @@ type StatsCompilation = KnownStatsCompilation & Record<string, any>;
|
|||
type StatsError = KnownStatsError & Record<string, any>;
|
||||
declare abstract class StatsFactory {
|
||||
hooks: Readonly<{
|
||||
extract: HookMap<SyncBailHook<[Object, any, StatsFactoryContext], any>>;
|
||||
extract: HookMap<SyncBailHook<[object, any, StatsFactoryContext], any>>;
|
||||
filter: HookMap<
|
||||
SyncBailHook<[any, StatsFactoryContext, number, number], any>
|
||||
>;
|
||||
|
@ -14150,7 +14150,7 @@ declare abstract class StatsPrinter {
|
|||
print: HookMap<SyncBailHook<[{}, StatsPrinterContext], string>>;
|
||||
result: HookMap<SyncWaterfallHook<[string, StatsPrinterContext]>>;
|
||||
}>;
|
||||
print(type: string, object: Object, baseContext?: Object): string;
|
||||
print(type: string, object: object, baseContext?: object): string;
|
||||
}
|
||||
type StatsPrinterContext = KnownStatsPrinterContext & Record<string, any>;
|
||||
type StatsProfile = KnownStatsProfile & Record<string, any>;
|
||||
|
|
Loading…
Reference in New Issue