Skip to content

Commit 4e81683

Browse files
committed
fix: update linting and bump all versions
1 parent 6de3ce7 commit 4e81683

10 files changed

+10022
-5709
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@ module.exports = {
88
'eslint:recommended',
99
'plugin:@typescript-eslint/eslint-recommended',
1010
'plugin:@typescript-eslint/recommended',
11+
],
12+
overrides: [
13+
{
14+
files: ["src/*.ts"],
15+
rules: {
16+
"@typescript-eslint/no-explicit-any": "off"
17+
}
18+
}
1119
]
1220
};

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.19.0
1+
16.17.0

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ module.exports = {
44
resetMocks: true,
55
restoreMocks: true,
66
rootDir: './src',
7-
testEnvironment: 'jsdom',
87
preset: 'ts-jest'
98
};

package-lock.json

Lines changed: 9990 additions & 5672 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@json-schema-tools/reference-resolver",
33
"version": "0.0.0-development",
4-
"description": "",
4+
"description": "Turns a $ref into a JSONSchema",
55
"main": "build/index.js",
66
"browser": "build/index-web.js",
77
"publishConfig": {
@@ -10,7 +10,8 @@
1010
"scripts": {
1111
"build": "npm run build:code && typedoc --out docs && touch docs/.nojekyll",
1212
"build:code": "tsc",
13-
"lint": "tslint --fix -p .",
13+
"lint": "eslint . --ext .ts",
14+
"lint:fix": "eslint . --ext .ts --fix",
1415
"test": "npm run test:unit && npm run test:web",
1516
"test:unit": "npm run lint && jest --coverage",
1617
"test:web": "npm run build:code && webpack && rm -rf dist"
@@ -29,17 +30,19 @@
2930
"!build/**/*.test.*"
3031
],
3132
"devDependencies": {
32-
"@json-schema-tools/meta-schema": "^1.6.18",
33-
"@types/isomorphic-fetch": "0.0.36",
34-
"@types/jest": "^26.0.23",
35-
"@types/node": "^18.0.4",
36-
"jest": "^24.9.0",
37-
"ts-jest": "^24.3.0",
38-
"tslint": "^6.1.3",
39-
"typedoc": "^0.21.0",
40-
"typescript": "4.3.5",
41-
"webpack": "^5.38.1",
42-
"webpack-cli": "^4.7.2"
33+
"@json-schema-tools/meta-schema": "^1.7.0",
34+
"@types/isomorphic-fetch": "^0.0.36",
35+
"@types/jest": "^29.1.1",
36+
"@types/node": "^18.8.2",
37+
"@typescript-eslint/eslint-plugin": "^5.39.0",
38+
"@typescript-eslint/parser": "^5.39.0",
39+
"eslint": "^8.24.0",
40+
"jest": "^29.1.2",
41+
"ts-jest": "^29.0.3",
42+
"typedoc": "^0.23.15",
43+
"typescript": "^4.8.4",
44+
"webpack": "^5.74.0",
45+
"webpack-cli": "^4.10.0"
4346
},
4447
"dependencies": {
4548
"@json-schema-spec/json-pointer": "^0.1.2",

src/default-protocol-handler-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { InvalidRemoteURLError, NonJsonRefError } from "./errors";
33
import { JSONSchema } from "@json-schema-tools/meta-schema";
44
import fetch from "isomorphic-fetch";
55

6-
const fetchHandler = async (uri: string, root: JSONSchema): Promise<JSONSchema> => {
6+
const fetchHandler = async (uri: string): Promise<JSONSchema> => {
77
let schemaReq;
88
try {
99
schemaReq = await fetch(uri);
@@ -14,7 +14,7 @@ const fetchHandler = async (uri: string, root: JSONSchema): Promise<JSONSchema>
1414
try {
1515
return await schemaReq.json() as JSONSchema;
1616
} catch (e) {
17-
throw new NonJsonRefError({ $ref: uri }, e.message);
17+
throw new NonJsonRefError({ $ref: uri }, (e as Error).message);
1818
}
1919
};
2020

src/index-web.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fetch from "isomorphic-fetch";
21
import defaultProtocolHandlerMap from "./default-protocol-handler-map";
32
import ReferenceResolver, { ProtocolHandlerMap } from "./reference-resolver";
43

src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import ReferenceResolver, { ProtocolHandlerMap } from "./reference-resolver";
22
import * as fs from "fs";
33
import { JSONSchema, JSONSchemaObject } from "@json-schema-tools/meta-schema";
4-
import { InvalidRemoteURLError, NonJsonRefError } from "./errors";
54
import defaultProtocolHandlerMap from "./default-protocol-handler-map";
65
import path from "path";
76

87
const fileExistsAndReadable = (f: string): Promise<boolean> => {
98
return new Promise((resolve) => {
10-
return fs.access(f, fs.constants.F_OK | fs.constants.R_OK, (e: any) => { //tslint:disable-line
9+
return fs.access(f, fs.constants.F_OK | fs.constants.R_OK, (e: any) => {
1110
if (e) { return resolve(false); }
1211
return resolve(true);
1312
});
@@ -20,10 +19,10 @@ const readFile = (f: string): Promise<string> => {
2019

2120
const nodeProtocolHandlerMap: ProtocolHandlerMap = {
2221
...defaultProtocolHandlerMap,
23-
"file": async (uri,root: JSONSchema) => {
22+
"file": async (uri, root: JSONSchema) => {
2423
let filePath = uri;
2524
const ref = (root as JSONSchemaObject).$ref;
26-
if(ref && ref !== uri && await fileExistsAndReadable(ref)) filePath = `${path.parse(ref).dir}/${uri}`;
25+
if (ref && ref !== uri && await fileExistsAndReadable(ref)) filePath = `${path.parse(ref).dir}/${uri}`;
2726
if (await fileExistsAndReadable(filePath) === true) {
2827
const fileContents = await readFile(filePath);
2928
return JSON.parse(fileContents) as JSONSchema;

src/reference-resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const isUrlLike = (s: string) => {
1212

1313
export interface ProtocolHandlerMap {
1414
[protocol: string]: (uri: string, root: JSONSchema) => Promise<JSONSchema | undefined>;
15-
};
15+
}
1616

1717
export default class ReferenceResolver {
1818
constructor(public protocolHandlerMap: ProtocolHandlerMap) { }
@@ -43,7 +43,7 @@ export default class ReferenceResolver {
4343
try {
4444
relativePathSchema = await this.protocolHandlerMap.file(hashlessRef, root);
4545
} catch (e) {
46-
throw new NonJsonRefError({ $ref: ref }, e.message);
46+
throw new NonJsonRefError({ $ref: ref }, (e as Error).message);
4747
}
4848
if (relativePathSchema !== undefined) {
4949
let schema: JSONSchema = relativePathSchema;

tslint.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)