Skip to content

Commit 32f91cc

Browse files
authored
refactor: upgrade schema-utils (#484)
Ref https://github.com/webpack/schema-utils/blob/master/CHANGELOG.md#200-2019-07-17. A lot of webpack packages already upgraded to the new version. API is changed and types are provided out of the box though required to add json-schema types.
1 parent 714dc6e commit 32f91cc

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@
6161
},
6262
"dependencies": {
6363
"@babel/code-frame": "^7.8.3",
64+
"@types/json-schema": "^7.0.5",
6465
"chalk": "^4.1.0",
6566
"cosmiconfig": "^6.0.0",
6667
"deepmerge": "^4.2.2",
6768
"fs-extra": "^9.0.0",
6869
"memfs": "^3.1.2",
6970
"minimatch": "^3.0.4",
70-
"schema-utils": "1.0.0",
71+
"schema-utils": "2.7.0",
7172
"semver": "^7.3.2",
7273
"tapable": "^1.0.0"
7374
},
@@ -87,7 +88,6 @@
8788
"@types/mock-fs": "^4.10.0",
8889
"@types/node": "^13.11.1",
8990
"@types/rimraf": "^3.0.0",
90-
"@types/schema-utils": "1.0.0",
9191
"@types/semver": "^7.1.0",
9292
"@types/webpack": "^4.41.11",
9393
"@typescript-eslint/eslint-plugin": "^2.27.0",

src/ForkTsCheckerWebpackPlugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import webpack from 'webpack';
22
import validateOptions from 'schema-utils';
3+
// type only dependency
4+
// eslint-disable-next-line node/no-extraneous-import
5+
import type { JSONSchema7 } from 'json-schema';
36
import { cosmiconfigSync } from 'cosmiconfig';
47
import merge from 'deepmerge';
58
import schema from './ForkTsCheckerWebpackPluginOptions.json';
@@ -28,12 +31,13 @@ class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
2831
const { config: externalOptions } = explorerSync.search() || {};
2932

3033
// first validate options directly passed to the constructor
31-
validateOptions(schema, options, 'ForkTsCheckerWebpackPlugin');
34+
const configuration = { name: 'ForkTsCheckerWebpackPlugin' };
35+
validateOptions(schema as JSONSchema7, options, configuration);
3236

3337
this.options = merge(externalOptions || {}, options || {});
3438

3539
// then validate merged options
36-
validateOptions(schema, this.options, 'ForkTsCheckerWebpackPlugin');
40+
validateOptions(schema as JSONSchema7, this.options, configuration);
3741
}
3842

3943
public static getCompilerHooks(compiler: webpack.Compiler) {

yarn.lock

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,10 @@
10771077
jest-diff "^25.2.1"
10781078
pretty-format "^25.2.1"
10791079

1080-
"@types/json-schema@*", "@types/json-schema@^7.0.3":
1081-
version "7.0.3"
1082-
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
1083-
integrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==
1080+
"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5":
1081+
version "7.0.5"
1082+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd"
1083+
integrity sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==
10841084

10851085
"@types/minimatch@*", "@types/minimatch@^3.0.1":
10861086
version "3.0.3"
@@ -1140,11 +1140,6 @@
11401140
"@types/glob" "*"
11411141
"@types/node" "*"
11421142

1143-
1144-
version "1.0.0"
1145-
resolved "https://registry.yarnpkg.com/@types/schema-utils/-/schema-utils-1.0.0.tgz#295d36f01e2cb8bc3207ca1d9a68e210db6b40cb"
1146-
integrity sha512-YesPanU1+WCigC/Aj1Mga8UCOjHIfMNHZ3zzDsUY7lI8GlKnh/Kv2QwJOQ+jNQ36Ru7IfzSedlG14hppYaN13A==
1147-
11481143
"@types/semver@^7.1.0":
11491144
version "7.1.0"
11501145
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.1.0.tgz#c8c630d4c18cd326beff77404887596f96408408"
@@ -1526,7 +1521,7 @@ ajv@^6.10.2:
15261521
json-schema-traverse "^0.4.1"
15271522
uri-js "^4.2.2"
15281523

1529-
ajv@^6.5.5:
1524+
ajv@^6.12.2, ajv@^6.5.5:
15301525
version "6.12.3"
15311526
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706"
15321527
integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==
@@ -7976,7 +7971,16 @@ saxes@^3.1.9:
79767971
dependencies:
79777972
xmlchars "^2.1.1"
79787973

7979-
[email protected], schema-utils@^1.0.0:
7974+
7975+
version "2.7.0"
7976+
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7"
7977+
integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==
7978+
dependencies:
7979+
"@types/json-schema" "^7.0.4"
7980+
ajv "^6.12.2"
7981+
ajv-keywords "^3.4.1"
7982+
7983+
schema-utils@^1.0.0:
79807984
version "1.0.0"
79817985
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770"
79827986
dependencies:

0 commit comments

Comments
 (0)