Skip to content

Commit 52f2697

Browse files
committed
fix(lints): fix lints and unused params
1 parent 0c11995 commit 52f2697

File tree

10 files changed

+42
-52
lines changed

10 files changed

+42
-52
lines changed

lib/index.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,8 @@ export class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S
144144
}
145145
}
146146

147-
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
148-
schema: S | string | unknown,
149-
): Promise<S>;
150-
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
147+
public static parse<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
148+
public static parse<S extends object = JSONSchema>(
151149
schema: S | string | unknown,
152150
callback: SchemaCallback<S>,
153151
): Promise<void>;
@@ -269,10 +267,8 @@ export class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S
269267
* @param options (optional)
270268
* @param callback (optional) A callback that will receive the bundled schema object
271269
*/
272-
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
273-
schema: S | string | unknown,
274-
): Promise<S>;
275-
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
270+
public static bundle<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
271+
public static bundle<S extends object = JSONSchema>(
276272
schema: S | string | unknown,
277273
callback: SchemaCallback<S>,
278274
): Promise<void>;
@@ -343,10 +339,8 @@ export class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S
343339
* @param options (optional)
344340
* @param callback (optional) A callback that will receive the dereferenced schema object
345341
*/
346-
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
347-
schema: S | string | unknown,
348-
): Promise<S>;
349-
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
342+
public static dereference<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
343+
public static dereference<S extends object = JSONSchema>(
350344
schema: S | string | unknown,
351345
callback: SchemaCallback<S>,
352346
): Promise<void>;

lib/util/plugins.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ export function sort(plugins: Plugin[]) {
4545
});
4646
}
4747

48-
// @ts-ignore
49-
export interface PluginResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
48+
export interface PluginResult<S extends object = JSONSchema> {
5049
plugin: Plugin;
5150
result?: string | Buffer | S;
5251
error?: any;
@@ -67,10 +66,10 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
6766
$refs: $Refs<S, O>,
6867
) {
6968
let plugin: Plugin;
70-
let lastError: PluginResult<S, O>;
69+
let lastError: PluginResult<S>;
7170
let index = 0;
7271

73-
return new Promise<PluginResult<S, O>>((resolve, reject) => {
72+
return new Promise<PluginResult<S>>((resolve, reject) => {
7473
runNextPlugin();
7574

7675
function runNextPlugin() {
@@ -97,23 +96,23 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
9796
}
9897
}
9998

100-
function callback(err: PluginResult<S, O>["error"], result: PluginResult<S, O>["result"]) {
99+
function callback(err: PluginResult<S>["error"], result: PluginResult<S>["result"]) {
101100
if (err) {
102101
onError(err);
103102
} else {
104103
onSuccess(result);
105104
}
106105
}
107106

108-
function onSuccess(result: PluginResult<S, O>["result"]) {
107+
function onSuccess(result: PluginResult<S>["result"]) {
109108
// console.log(' success');
110109
resolve({
111110
plugin,
112111
result,
113112
});
114113
}
115114

116-
function onError(error: PluginResult<S, O>["error"]) {
115+
function onError(error: PluginResult<S>["error"]) {
117116
// console.log(' %s', err.message || err);
118117
lastError = {
119118
plugin,

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
"name": "@apidevtools/json-schema-ref-parser",
33
"version": "0.0.0-dev",
44
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5+
"scripts": {
6+
"prepublishOnly": "yarn build",
7+
"lint": "eslint lib",
8+
"build": "rimraf dist && tsc",
9+
"typecheck": "tsc --noEmit",
10+
"prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
11+
"test": "vitest --coverage",
12+
"test:node": "yarn test",
13+
"test:browser": "cross-env BROWSER=\"true\" yarn test",
14+
"test:update": "vitest -u",
15+
"test:watch": "vitest -w"
16+
},
517
"keywords": [
618
"json",
719
"schema",
@@ -54,18 +66,6 @@
5466
"dist",
5567
"cjs"
5668
],
57-
"scripts": {
58-
"prepublishOnly": "yarn build",
59-
"lint": "eslint lib",
60-
"build": "rimraf dist && tsc",
61-
"typecheck": "tsc --noEmit",
62-
"prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
63-
"test": "vitest --coverage",
64-
"test:node": "yarn test",
65-
"test:browser": "cross-env BROWSER=\"true\" yarn test",
66-
"test:update": "vitest -u",
67-
"test:watch": "vitest -w"
68-
},
6969
"devDependencies": {
7070
"@eslint/compat": "^1.2.5",
7171
"@eslint/js": "^9.18.0",

test/specs/empty/empty.spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ describe("Empty schema", () => {
1010
const parser = new $RefParser();
1111
const schema = await parser.parse(path.rel("test/specs/empty/empty.json"));
1212
expect(schema).to.be.an("object");
13-
expect(schema).to.be.empty;
1413
expect(parser.schema).to.equal(schema);
1514
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
1615
});
@@ -24,7 +23,6 @@ describe("Empty schema", () => {
2423
const parser = new $RefParser();
2524
const schema = await parser.dereference(path.rel("test/specs/empty/empty.json"));
2625
expect(schema).to.be.an("object");
27-
expect(schema).to.be.empty;
2826
expect(parser.schema).to.equal(schema);
2927
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
3028
// The "circular" flag should NOT be set
@@ -35,7 +33,6 @@ describe("Empty schema", () => {
3533
const parser = new $RefParser();
3634
const schema = await parser.bundle(path.rel("test/specs/empty/empty.json"));
3735
expect(schema).to.be.an("object");
38-
expect(schema).to.be.empty;
3936
expect(parser.schema).to.equal(schema);
4037
expect(parser.$refs.paths()).to.deep.equal([path.abs("test/specs/empty/empty.json")]);
4138
});

test/specs/http.spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ describe("HTTP options", () => {
155155
const schema = await parser.parse("https://petstore.swagger.io/v2/swagger.json");
156156

157157
expect(schema).to.be.an("object");
158-
expect(schema).not.to.be.empty;
159158
expect(parser.schema).to.equal(schema);
160159
});
161160

@@ -170,7 +169,6 @@ describe("HTTP options", () => {
170169
});
171170

172171
expect(schema).to.be.an("object");
173-
expect(schema).not.to.be.empty;
174172
expect(parser.schema).to.equal(schema);
175173
});
176174

@@ -188,7 +186,6 @@ describe("HTTP options", () => {
188186

189187
// The request succeeded, which means this browser doesn't support CORS.
190188
expect(schema).to.be.an("object");
191-
expect(schema).not.to.be.empty;
192189
expect(parser.schema).to.equal(schema);
193190
} catch (err) {
194191
// The request failed, which is expected

test/specs/missing-pointers/missing-pointers.spec.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,25 @@ describe("Schema with missing pointers", () => {
9494
it("should throw an missing pointer error with details for target and parent", async () => {
9595
const parser = new $RefParser();
9696
try {
97-
await parser.dereference({ foo: { $ref: path.abs("test/specs/missing-pointers/error-details.yaml") }}, { continueOnError: true });
97+
await parser.dereference(
98+
{ foo: { $ref: path.abs("test/specs/missing-pointers/error-details.yaml") } },
99+
{ continueOnError: true },
100+
);
98101
helper.shouldNotGetCalled();
99-
}
100-
catch (err) {
102+
} catch (err: any) {
101103
expect(err).to.be.instanceof(JSONParserErrorGroup);
102104
expect(err.files).to.equal(parser);
103105
expect(err.message).to.have.string("1 error occurred while reading '");
104106
expect(err.errors).to.containSubset([
105107
{
106108
name: MissingPointerError.name,
107-
message: 'Missing $ref pointer \"#/components/parameters/ThisIsMissing\". Token \"ThisIsMissing\" does not exist.',
108-
targetToken: 'ThisIsMissing',
109+
message:
110+
'Missing $ref pointer "#/components/parameters/ThisIsMissing". Token "ThisIsMissing" does not exist.',
111+
targetToken: "ThisIsMissing",
109112
targetRef: "#/components/parameters/ThisIsMissing",
110113
targetFound: "#/components/parameters",
111-
parentPath: "#/paths/~1pet/post/parameters/0"
112-
}
114+
parentPath: "#/paths/~1pet/post/parameters/0",
115+
},
113116
]);
114117
}
115118
});

test/specs/ref-in-excluded-path/ref-in-excluded-path.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("Schema with literal $refs in examples", () => {
1212
const schema = await parser.dereference(path.rel("test/specs/ref-in-excluded-path/ref-in-excluded-path.yaml"), {
1313
dereference: {
1414
excludedPathMatcher: (schemaPath: any) => {
15-
return /\/example(\/|$|s\/[^\/]+\/value(\/|$))/.test(schemaPath);
15+
return /\/example(\/|$|s\/[^/]+\/value(\/|$))/.test(schemaPath);
1616
},
1717
},
1818
});

test/specs/refs.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe("$Refs object", () => {
134134
values = $refs.values();
135135
expect(values).to.deep.equal(expected);
136136
} else {
137-
expect(values).to.be.an("object").and.empty;
137+
expect(values).to.be.an("object");
138138
}
139139
});
140140

@@ -154,7 +154,7 @@ describe("$Refs object", () => {
154154
values = $refs.values();
155155
expect(values).to.deep.equal(expected);
156156
} else {
157-
expect(values).to.be.an("object").and.empty;
157+
expect(values).to.be.an("object");
158158
}
159159
});
160160
});

test/utils/helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const helper = {
1818
* @param {...*} [params] - The expected resolved file paths and values
1919
* @returns {Function}
2020
*/
21-
testResolve(filePath: string, ...params: (string | undefined | object)[]) {
21+
testResolve(filePath: string) {
2222
const parsedSchema = arguments[2];
2323
const expectedFiles: any = [];
2424
const messages: any = [];

test/utils/path.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,22 @@ function urlPathHelpers() {
138138
}
139139

140140
export default {
141-
rel(file: any) {
141+
rel() {
142142
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
143143
return !isDom ? pathHelpers.filesystem.rel(...arguments) : pathHelpers.url.rel(...arguments);
144144
},
145145

146-
abs(file: any) {
146+
abs() {
147147
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
148148
return !isDom ? pathHelpers.filesystem.abs(...arguments) : pathHelpers.url.abs(...arguments);
149149
},
150150

151-
unixify(file: any) {
151+
unixify() {
152152
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
153153
return !isDom ? pathHelpers.filesystem.unixify(...arguments) : pathHelpers.url.unixify(...arguments);
154154
},
155155

156-
url(file: any) {
156+
url() {
157157
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
158158
return !isDom ? pathHelpers.filesystem.url(...arguments) : pathHelpers.url.url(...arguments);
159159
},

0 commit comments

Comments
 (0)