From a91f7366dcfabd5f618cf057af3bd611484c86e3 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 10:13:38 +0200 Subject: [PATCH] fix plugin schemas and give them names --- declarations/plugins/BannerPlugin.d.ts | 76 ++++++++++--------- declarations/plugins/DllPlugin.d.ts | 2 +- declarations/plugins/DllReferencePlugin.d.ts | 2 +- .../plugins/HashedModuleIdsPlugin.d.ts | 6 +- declarations/plugins/IgnorePlugin.d.ts | 10 +-- declarations/plugins/LoaderOptionsPlugin.d.ts | 2 +- .../plugins/SourceMapDevToolPlugin.d.ts | 18 ++--- declarations/plugins/WatchIgnorePlugin.d.ts | 6 +- .../plugins/debug/ProfilingPlugin.d.ts | 2 +- .../optimize/AggressiveSplittingPlugin.d.ts | 2 +- .../optimize/LimitChunkCountPlugin.d.ts | 2 +- .../plugins/optimize/MinChunkSizePlugin.d.ts | 2 +- .../OccurrenceOrderChunkIdsPlugin.d.ts | 2 +- .../OccurrenceOrderModuleIdsPlugin.d.ts | 2 +- schemas/plugins/BannerPlugin.json | 26 ++++--- schemas/plugins/DllPlugin.json | 1 + schemas/plugins/DllReferencePlugin.json | 1 + schemas/plugins/HashedModuleIdsPlugin.json | 6 ++ schemas/plugins/IgnorePlugin.json | 10 ++- schemas/plugins/LoaderOptionsPlugin.json | 1 + schemas/plugins/SourceMapDevToolPlugin.json | 7 +- schemas/plugins/WatchIgnorePlugin.json | 4 +- schemas/plugins/debug/ProfilingPlugin.json | 1 + .../optimize/AggressiveSplittingPlugin.json | 1 + .../optimize/LimitChunkCountPlugin.json | 1 + .../plugins/optimize/MinChunkSizePlugin.json | 1 + .../OccurrenceOrderChunkIdsPlugin.json | 1 + .../OccurrenceOrderModuleIdsPlugin.json | 1 + 28 files changed, 111 insertions(+), 85 deletions(-) diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts index b511c8873..d27bd6230 100644 --- a/declarations/plugins/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -4,44 +4,52 @@ * Run `yarn special-lint-fix` to update */ -export type BannerPlugin = - | { - /** - * Specifies the banner - */ - banner: - | { - [k: string]: any; - } - | string; - /** - * If true, the banner will only be added to the entry chunks - */ - entryOnly?: boolean; - /** - * Exclude all modules matching any of these conditions - */ - exclude?: Rules; - /** - * Include all modules matching any of these conditions - */ - include?: Rules; - /** - * If true, banner will not be wrapped in a comment - */ - raw?: boolean; - /** - * Include all modules that pass test assertion - */ - test?: Rules; - } - | { - [k: string]: any; - } +export type BannerPluginArgument = + | BannerPluginOptions + | BannerFunction | string; +/** + * The banner as function, it will be wrapped in a comment + */ +export type BannerFunction = ( + data: { + hash: string; + chunk: import("../../lib/Chunk"); + filename: string; + basename: string; + query: string; + } +) => string; export type Rules = Rule[] | Rule; export type Rule = | { [k: string]: any; } | string; + +export interface BannerPluginOptions { + /** + * Specifies the banner + */ + banner: BannerFunction | string; + /** + * If true, the banner will only be added to the entry chunks + */ + entryOnly?: boolean; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: Rules; + /** + * Include all modules matching any of these conditions + */ + include?: Rules; + /** + * If true, banner will not be wrapped in a comment + */ + raw?: boolean; + /** + * Include all modules that pass test assertion + */ + test?: Rules; +} diff --git a/declarations/plugins/DllPlugin.d.ts b/declarations/plugins/DllPlugin.d.ts index 136cbe18d..f7264c2da 100644 --- a/declarations/plugins/DllPlugin.d.ts +++ b/declarations/plugins/DllPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface DllPlugin { +export interface DllPluginOptions { /** * Context of requests in the manifest file (defaults to the webpack context) */ diff --git a/declarations/plugins/DllReferencePlugin.d.ts b/declarations/plugins/DllReferencePlugin.d.ts index 192d154f7..c9cde96a5 100644 --- a/declarations/plugins/DllReferencePlugin.d.ts +++ b/declarations/plugins/DllReferencePlugin.d.ts @@ -4,6 +4,6 @@ * Run `yarn special-lint-fix` to update */ -export type DllReferencePlugin = { +export type DllReferencePluginOptions = { [k: string]: any; }; diff --git a/declarations/plugins/HashedModuleIdsPlugin.d.ts b/declarations/plugins/HashedModuleIdsPlugin.d.ts index 8175918c5..571ab60a4 100644 --- a/declarations/plugins/HashedModuleIdsPlugin.d.ts +++ b/declarations/plugins/HashedModuleIdsPlugin.d.ts @@ -4,7 +4,11 @@ * Run `yarn special-lint-fix` to update */ -export interface HashedModuleIdsPlugin { +export interface HashedModuleIdsPluginOptions { + /** + * The context directory for creating names. + */ + context?: string; /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts index 7b5685983..2aaf5061c 100644 --- a/declarations/plugins/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export type IgnorePlugin = +export type IgnorePluginOptions = | { /** * A RegExp to test the context (directory) against @@ -23,13 +23,9 @@ export type IgnorePlugin = /** * A filter function for context */ - checkContext?: { - [k: string]: any; - }; + checkContext?: ((context: string) => boolean); /** * A filter function for resource */ - checkResource?: { - [k: string]: any; - }; + checkResource?: ((resource: string) => boolean); }; diff --git a/declarations/plugins/LoaderOptionsPlugin.d.ts b/declarations/plugins/LoaderOptionsPlugin.d.ts index 61ab8d058..cb48ecc28 100644 --- a/declarations/plugins/LoaderOptionsPlugin.d.ts +++ b/declarations/plugins/LoaderOptionsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface LoaderOptionsPlugin { +export interface LoaderOptionsPluginOptions { /** * Whether loaders should be in debug mode or not. debug will be removed as of webpack 3 */ diff --git a/declarations/plugins/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts index c8957e1e5..cff6446ca 100644 --- a/declarations/plugins/SourceMapDevToolPlugin.d.ts +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -5,12 +5,12 @@ */ /** - * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * via the `definition` "rules". */ export type Rules = Rule[] | Rule; /** - * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * via the `definition` "rule". */ export type Rule = @@ -19,7 +19,7 @@ export type Rule = } | string; -export interface SourceMapDevToolPlugin { +export interface SourceMapDevToolPluginOptions { /** * Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending */ @@ -35,11 +35,7 @@ export interface SourceMapDevToolPlugin { /** * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict */ - fallbackModuleFilenameTemplate?: - | { - [k: string]: any; - } - | string; + fallbackModuleFilenameTemplate?: Function | string; /** * Path prefix to which the [file] placeholder is relative to */ @@ -78,11 +74,7 @@ export interface SourceMapDevToolPlugin { /** * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap */ - moduleFilenameTemplate?: - | { - [k: string]: any; - } - | string; + moduleFilenameTemplate?: Function | string; /** * Namespace prefix to allow multiple webpack roots in the devtools */ diff --git a/declarations/plugins/WatchIgnorePlugin.d.ts b/declarations/plugins/WatchIgnorePlugin.d.ts index 540269afd..05c857503 100644 --- a/declarations/plugins/WatchIgnorePlugin.d.ts +++ b/declarations/plugins/WatchIgnorePlugin.d.ts @@ -7,8 +7,4 @@ /** * A list of RegExps or absolute paths to directories or files that should be ignored */ -export type WatchIgnorePlugin = ( - | string - | { - [k: string]: any; - })[]; +export type WatchIgnorePluginOptions = (string | RegExp)[]; diff --git a/declarations/plugins/debug/ProfilingPlugin.d.ts b/declarations/plugins/debug/ProfilingPlugin.d.ts index d24395557..d3cd664ad 100644 --- a/declarations/plugins/debug/ProfilingPlugin.d.ts +++ b/declarations/plugins/debug/ProfilingPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface ProfilingPlugin { +export interface ProfilingPluginOptions { /** * Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`. */ diff --git a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts index 4088b94d0..9f5360c49 100644 --- a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +++ b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface AggressiveSplittingPlugin { +export interface AggressiveSplittingPluginOptions { /** * Default: 0 */ diff --git a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts index 38756335b..8cd59ed6e 100644 --- a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +++ b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface LimitChunkCountPlugin { +export interface LimitChunkCountPluginOptions { /** * Limit the maximum number of chunks using a value greater greater than or equal to 1 */ diff --git a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts index 959b23ce5..61d20fd9c 100644 --- a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +++ b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface MinChunkSizePlugin { +export interface MinChunkSizePluginOptions { /** * Minimum number of characters */ diff --git a/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts index 3c3ad828d..0396f5547 100644 --- a/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +++ b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface OccurrenceOrderChunkIdsPlugin { +export interface OccurrenceOrderChunkIdsPluginOptions { /** * Prioritise initial size over total size */ diff --git a/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts index 7c8f3b412..c29e0e956 100644 --- a/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +++ b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface OccurrenceOrderModuleIdsPlugin { +export interface OccurrenceOrderModuleIdsPluginOptions { /** * Prioritise initial size over total size */ diff --git a/schemas/plugins/BannerPlugin.json b/schemas/plugins/BannerPlugin.json index 9c86c502e..555e29ed7 100644 --- a/schemas/plugins/BannerPlugin.json +++ b/schemas/plugins/BannerPlugin.json @@ -1,6 +1,11 @@ { "definitions": { - "rule": { + "BannerFunction": { + "description": "The banner as function, it will be wrapped in a comment", + "instanceof": "Function", + "tsType": "(data: { hash: string, chunk: import('../../lib/Chunk'), filename: string, basename: string, query: string}) => string" + }, + "Rule": { "oneOf": [ { "instanceof": "RegExp" @@ -11,7 +16,7 @@ } ] }, - "rules": { + "Rules": { "oneOf": [ { "type": "array", @@ -19,19 +24,21 @@ "description": "A rule condition", "anyOf": [ { - "$ref": "#/definitions/rule" + "$ref": "#/definitions/Rule" } ] } }, { - "$ref": "#/definitions/rule" + "$ref": "#/definitions/Rule" } ] } }, + "title": "BannerPluginArgument", "oneOf": [ { + "title": "BannerPluginOptions", "type": "object", "additionalProperties": false, "properties": { @@ -39,7 +46,7 @@ "description": "Specifies the banner", "anyOf": [ { - "instanceof": "Function" + "$ref": "#/definitions/BannerFunction" }, { "type": "string" @@ -54,7 +61,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] }, @@ -62,7 +69,7 @@ "description": "Include all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] }, @@ -74,7 +81,7 @@ "description": "Include all modules that pass test assertion", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] } @@ -82,8 +89,7 @@ "required": ["banner"] }, { - "description": "The banner as function, it will be wrapped in a comment", - "instanceof": "Function" + "$ref": "#/definitions/BannerFunction" }, { "description": "The banner as string, it will be wrapped in a comment", diff --git a/schemas/plugins/DllPlugin.json b/schemas/plugins/DllPlugin.json index 18a0351bf..235b7b9ff 100644 --- a/schemas/plugins/DllPlugin.json +++ b/schemas/plugins/DllPlugin.json @@ -1,4 +1,5 @@ { + "title": "DllPluginOptions", "additionalProperties": false, "properties": { "context": { diff --git a/schemas/plugins/DllReferencePlugin.json b/schemas/plugins/DllReferencePlugin.json index 17587b186..87fa39e68 100644 --- a/schemas/plugins/DllReferencePlugin.json +++ b/schemas/plugins/DllReferencePlugin.json @@ -1,4 +1,5 @@ { + "title": "DllReferencePluginOptions", "additionalProperties": false, "properties": { "content": { diff --git a/schemas/plugins/HashedModuleIdsPlugin.json b/schemas/plugins/HashedModuleIdsPlugin.json index 5645bdd12..c4592ea65 100644 --- a/schemas/plugins/HashedModuleIdsPlugin.json +++ b/schemas/plugins/HashedModuleIdsPlugin.json @@ -1,7 +1,13 @@ { + "title": "HashedModuleIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { + "context": { + "description": "The context directory for creating names.", + "type": "string", + "absolutePath": true + }, "hashDigest": { "description": "The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported.", "enum": ["hex", "latin1", "base64"] diff --git a/schemas/plugins/IgnorePlugin.json b/schemas/plugins/IgnorePlugin.json index e8319f1d1..924073868 100644 --- a/schemas/plugins/IgnorePlugin.json +++ b/schemas/plugins/IgnorePlugin.json @@ -1,7 +1,8 @@ { - "type": "object", + "title": "IgnorePluginOptions", "oneOf": [ { + "type": "object", "additionalProperties": false, "properties": { "contextRegExp": { @@ -15,15 +16,18 @@ } }, { + "type": "object", "additionalProperties": false, "properties": { "checkContext": { "description": "A filter function for context", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "((context: string) => boolean)" }, "checkResource": { "description": "A filter function for resource", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "((resource: string) => boolean)" } } } diff --git a/schemas/plugins/LoaderOptionsPlugin.json b/schemas/plugins/LoaderOptionsPlugin.json index 3a84e0347..67efca433 100644 --- a/schemas/plugins/LoaderOptionsPlugin.json +++ b/schemas/plugins/LoaderOptionsPlugin.json @@ -1,4 +1,5 @@ { + "title": "LoaderOptionsPluginOptions", "type": "object", "additionalProperties": true, "properties": { diff --git a/schemas/plugins/SourceMapDevToolPlugin.json b/schemas/plugins/SourceMapDevToolPlugin.json index 873e2aa98..49ca38cf4 100644 --- a/schemas/plugins/SourceMapDevToolPlugin.json +++ b/schemas/plugins/SourceMapDevToolPlugin.json @@ -30,6 +30,7 @@ ] } }, + "title": "SourceMapDevToolPluginOptions", "type": "object", "additionalProperties": false, "properties": { @@ -63,7 +64,8 @@ "oneOf": [ { "description": "Custom function generating the identifer", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string", @@ -145,7 +147,8 @@ "oneOf": [ { "description": "Custom function generating the identifer", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string", diff --git a/schemas/plugins/WatchIgnorePlugin.json b/schemas/plugins/WatchIgnorePlugin.json index a69c75529..b08d50ba6 100644 --- a/schemas/plugins/WatchIgnorePlugin.json +++ b/schemas/plugins/WatchIgnorePlugin.json @@ -1,4 +1,5 @@ { + "title": "WatchIgnorePluginOptions", "description": "A list of RegExps or absolute paths to directories or files that should be ignored", "type": "array", "items": { @@ -8,7 +9,8 @@ "type": "string" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] }, diff --git a/schemas/plugins/debug/ProfilingPlugin.json b/schemas/plugins/debug/ProfilingPlugin.json index 299762f58..e9a4bf18b 100644 --- a/schemas/plugins/debug/ProfilingPlugin.json +++ b/schemas/plugins/debug/ProfilingPlugin.json @@ -1,4 +1,5 @@ { + "title": "ProfilingPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/AggressiveSplittingPlugin.json b/schemas/plugins/optimize/AggressiveSplittingPlugin.json index 31c439901..19bcdfd56 100644 --- a/schemas/plugins/optimize/AggressiveSplittingPlugin.json +++ b/schemas/plugins/optimize/AggressiveSplittingPlugin.json @@ -1,4 +1,5 @@ { + "title": "AggressiveSplittingPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/LimitChunkCountPlugin.json b/schemas/plugins/optimize/LimitChunkCountPlugin.json index 5e2b67619..b2636eefd 100644 --- a/schemas/plugins/optimize/LimitChunkCountPlugin.json +++ b/schemas/plugins/optimize/LimitChunkCountPlugin.json @@ -1,4 +1,5 @@ { + "title": "LimitChunkCountPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/MinChunkSizePlugin.json b/schemas/plugins/optimize/MinChunkSizePlugin.json index 0250ec5f3..03e17d65e 100644 --- a/schemas/plugins/optimize/MinChunkSizePlugin.json +++ b/schemas/plugins/optimize/MinChunkSizePlugin.json @@ -1,4 +1,5 @@ { + "title": "MinChunkSizePluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json index 98f12f132..12facf2f6 100644 --- a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json @@ -1,4 +1,5 @@ { + "title": "OccurrenceOrderChunkIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json index 98f12f132..d76ac14df 100644 --- a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json @@ -1,4 +1,5 @@ { + "title": "OccurrenceOrderModuleIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": {