@@ -18,18 +18,16 @@ export function loadSchema(
18
18
schemaPath : string ,
19
19
context : RuleContext ,
20
20
) : null | SchemaObject {
21
- return loadJsonInternal ( schemaPath , context , ( schema ) => {
22
- migrateToDraft7 ( schema as SchemaObject ) ;
21
+ return loadJsonInternal ( schemaPath , context , ( schema_ ) => {
22
+ const schema = schema_ as SchemaObject ;
23
+ migrateToDraft7 ( schema ) ;
23
24
return schema ;
24
25
} ) ;
25
26
}
26
27
/**
27
28
* Load json data
28
29
*/
29
- export function loadJson <
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
31
- T = any ,
32
- > ( jsonPath : string , context : RuleContext ) : null | T {
30
+ export function loadJson < T > ( jsonPath : string , context : RuleContext ) : null | T {
33
31
return loadJsonInternal ( jsonPath , context ) ;
34
32
}
35
33
@@ -39,7 +37,7 @@ export function loadJson<
39
37
function loadJsonInternal < T > (
40
38
jsonPath : string ,
41
39
context : RuleContext ,
42
- edit ?: ( json : unknown ) => unknown ,
40
+ edit ?: ( json : unknown ) => T ,
43
41
) : null | T {
44
42
if ( jsonPath . startsWith ( "http://" ) || jsonPath . startsWith ( "https://" ) ) {
45
43
return loadJsonFromURL ( jsonPath , context , edit ) ;
@@ -52,7 +50,7 @@ function loadJsonInternal<T>(
52
50
url = `${ url } .json` ;
53
51
}
54
52
return loadJsonFromURL ( url , context , ( orig ) => {
55
- const result = edit ?.( orig ) ?? orig ;
53
+ const result = edit ?.( orig ) ?? ( orig as T ) ;
56
54
if ( jsonPath === "vscode://schemas/settings/machine" ) {
57
55
// Adjust `vscode://schemas/settings/machine` resource to avoid bugs.
58
56
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
@@ -111,7 +109,7 @@ function removeEmptyEnum(
111
109
function loadJsonFromURL < T > (
112
110
jsonPath : string ,
113
111
context : RuleContext ,
114
- edit ?: ( json : unknown ) => unknown ,
112
+ edit ?: ( json : unknown ) => T ,
115
113
) : null | T {
116
114
let jsonFileName = jsonPath . replace ( / ^ h t t p s ? : \/ \/ / u, "" ) ;
117
115
if ( ! jsonFileName . endsWith ( ".json" ) ) {
@@ -180,9 +178,9 @@ function postProcess<T>(
180
178
jsonFilePath : string ,
181
179
json : string ,
182
180
context : RuleContext ,
183
- edit : ( ( json : unknown ) => unknown ) | undefined ,
181
+ edit : ( ( json : unknown ) => T ) | undefined ,
184
182
) : T | null {
185
- let data ;
183
+ let data : T ;
186
184
try {
187
185
data = JSON . parse ( json ) ;
188
186
} catch {
0 commit comments