Skip to content

Commit 25eb3a3

Browse files
committed
Update the ESLint 9
1 parent 5b76969 commit 25eb3a3

23 files changed

+121
-229
lines changed

.eslintrc.json

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

bundle/test-utils.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type TestCase = {
1212
};
1313

1414
type Test = {
15-
description: string,
16-
instance: Json
15+
description: string;
16+
instance: Json;
1717
};
1818

1919
export const testSuite: (path: string) => TestCase[];
@@ -22,6 +22,6 @@ export const isCompatible: (compatibility: string | undefined, versionUnderTest:
2222
export const loadSchemas: (testCase: TestCase, retrievalUri: string, dialect: string) => void;
2323
export const unloadSchemas: (testCase: TestCase, retrievalUri: string, dialect: string) => void;
2424
export const toOutput: (instance: JsonNode) => Record<string, {
25-
errors: Record<string>,
26-
annotations: Record<string, Record<string, string>>
25+
errors: Record<string>;
26+
annotations: Record<string, Record<string, string>>;
2727
}>;

draft-04/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Test = {
2323
// is usually because there has been some tradeoff I've made to not support
2424
// something that doesn't come up in real schemas in favor of something that has
2525
// value.
26-
const skip: Set<string> = new Set([
26+
const skip = new Set<string>([
2727
// Skip tests for pointers that cross schema resource boundaries. There might
2828
// be a way to solve this, but because this functionality has been removed
2929
// from the spec and there is no good reason to do this, it will probably not

draft-06/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Test = {
2323
// is usually because there has been some tradeoff I've made to not support
2424
// something that doesn't come up in real schemas in favor of something that has
2525
// value.
26-
const skip: Set<string> = new Set([
26+
const skip = new Set<string>([
2727
// Skip tests for pointers that cross schema resource boundaries. There might
2828
// be a way to solve this, but because this functionality has been removed
2929
// from the spec and there is no good reason to do this, it will probably not

draft-07/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Test = {
2323
// is usually because there has been some tradeoff I've made to not support
2424
// something that doesn't come up in real schemas in favor of something that has
2525
// value.
26-
const skip: Set<string> = new Set([
26+
const skip = new Set<string>([
2727
// Skip tests for pointers that cross schema resource boundaries. There might
2828
// be a way to solve this, but because this functionality has been removed
2929
// from the spec and there is no good reason to do this, it will probably not

draft-2019-09/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Test = {
2222
// This package is indended to be a compatibility mode from stable JSON Schema.
2323
// Some edge cases might not work exactly as specified, but it should work for
2424
// any real-life schema.
25-
const skip: Set<string> = new Set([
25+
const skip = new Set<string>([
2626
// Self-identifying with a `file:` URI is not allowed for security reasons.
2727
"|draft2019-09|ref.json|$id with file URI still resolves pointers - *nix",
2828
"|draft2019-09|ref.json|$id with file URI still resolves pointers - windows"

draft-2020-12/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Test = {
2222
// This package is indended to be a compatibility mode from stable JSON Schema.
2323
// Some edge cases might not work exactly as specified, but it should work for
2424
// any real-life schema.
25-
const skip: Set<string> = new Set([
25+
const skip = new Set<string>([
2626
// Self-identifying with a `file:` URI is not allowed for security reasons.
2727
"|draft2020-12|ref.json|$id with file URI still resolves pointers - *nix",
2828
"|draft2020-12|ref.json|$id with file URI still resolves pointers - windows"

eslint.config.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import js from "@eslint/js";
2+
import stylistic from "@stylistic/eslint-plugin";
3+
import importPlugin from "eslint-plugin-import";
4+
import globals from "globals";
5+
import tseslint from "typescript-eslint";
6+
7+
8+
export default [
9+
js.configs.recommended,
10+
...tseslint.configs.recommendedTypeChecked,
11+
...tseslint.configs.stylisticTypeChecked,
12+
importPlugin.flatConfigs.recommended,
13+
stylistic.configs.customize({
14+
arrowParens: true,
15+
braceStyle: "1tbs",
16+
commaDangle: "never",
17+
flat: true,
18+
jsx: false,
19+
quotes: "double",
20+
semi: true
21+
}),
22+
{
23+
languageOptions: {
24+
ecmaVersion: "latest",
25+
globals: {
26+
...globals.node
27+
},
28+
parserOptions: {
29+
projectService: true,
30+
tsconfigRootDir: import.meta.dirname
31+
}
32+
},
33+
settings: {
34+
"import/resolver": {
35+
node: {},
36+
typescript: {}
37+
}
38+
},
39+
rules: {
40+
// JavaScript
41+
"no-console": ["error"],
42+
"no-empty-function": "off",
43+
"no-fallthrough": "off",
44+
45+
// TypeScript
46+
"@typescript-eslint/no-unused-vars": ["error", { caughtErrorsIgnorePattern: "^_" }],
47+
"@typescript-eslint/no-empty-function": "off",
48+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
49+
50+
// Imports
51+
"import/extensions": ["error", "ignorePackages"],
52+
"import/newline-after-import": ["error", { count: 2, exactCount: false, considerComments: true }],
53+
54+
// Stylistic
55+
"@stylistic/multiline-ternary": "off",
56+
"@stylistic/no-mixed-operators": "off",
57+
"@stylistic/no-multiple-empty-lines": ["error", { max: 2, maxEOF: 0, maxBOF: 0 }], // Allow max=2 for imports
58+
"@stylistic/quote-props": ["error", "consistent"],
59+
"@stylistic/yield-star-spacing": ["error", "after"]
60+
}
61+
},
62+
{
63+
files: ["**/*.js"],
64+
...tseslint.configs.disableTypeChecked
65+
}
66+
];

lib/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ export const jsonTypeOf = (value) => {
1919
} else if (Object.getPrototypeOf(value) === Object.prototype) {
2020
return "object";
2121
}
22-
default:
22+
default: {
2323
const type = jsType === "object" ? Object.getPrototypeOf(value).constructor.name || "anonymous" : jsType;
2424
throw Error(`Not a JSON compatible type: ${type}`);
25+
}
2526
}
2627
};
2728

lib/experimental.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export const getKeywordName: (dialectId: string, keywordId: string) => string;
5959
export const getKeyword: <A>(id: string) => Keyword<A>;
6060
export const getKeywordByName: <A>(keywordName: string, dialectId: string) => Keyword<A>;
6161
export const getKeywordId: (keywordName: string, dialectId: string) => string;
62-
export const defineVocabulary: (id: string, keywords: { [keyword: string]: string }) => void;
63-
export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]: boolean }, allowUnknownKeywords?: boolean) => void;
62+
export const defineVocabulary: (id: string, keywords: Record<string, string>) => void;
63+
export const loadDialect: (dialectId: string, dialect: Record<string, boolean>, allowUnknownKeywords?: boolean) => void;
6464
export const unloadDialect: (dialectId: string) => void;
6565
export const hasDialect: (dialectId: string) => boolean;
6666

lib/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Json } from "@hyperjump/json-pointer";
22

33

44
export type SchemaFragment = string | number | boolean | null | SchemaObject | SchemaFragment[];
5-
export type SchemaObject = {
5+
export type SchemaObject = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
66
[keyword: string]: SchemaFragment;
77
};
88

lib/instance.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ export const fromJs = (value, uri = "", pointer = "", parent = undefined) => {
3434
} else if (value instanceof Reference) {
3535
return fromJs(value.toJSON(), uri, pointer, parent);
3636
}
37-
default:
37+
default: {
3838
const type = jsType === "object" ? Object.getPrototypeOf(value).constructor.name || "anonymous" : jsType;
3939
throw Error(`Not a JSON compatible type: ${type}`);
40+
}
4041
}
4142
};
4243

@@ -77,14 +78,16 @@ export const has = (key, node) => key in node.value;
7778

7879
export const step = (key, node) => {
7980
switch (node.type) {
80-
case "object":
81+
case "object": {
8182
const property = node.children.find((propertyNode) => {
8283
return value(propertyNode.children[0]) === key;
8384
});
8485
return property?.children[1];
85-
case "array":
86+
}
87+
case "array": {
8688
const index = parseInt(key, 10);
8789
return node.children[index];
90+
}
8891
default:
8992
return;
9093
}

lib/schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const schemaPlugin = {
1414

1515
return buildSchemaDocument(await response.json(), response.url, contextDialectId);
1616
},
17-
fileMatcher: (path) => /(\.|\/)schema\.json$/.test(path)
17+
fileMatcher: async (path) => /(\.|\/)schema\.json$/.test(path)
1818
};
1919

2020
const schemaRegistry = {};

0 commit comments

Comments
 (0)