From 25eb3a34316123a15caf9ee45af94538d34dee0c Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 12 Nov 2024 15:37:58 -0800 Subject: [PATCH] Update the ESLint 9 --- .eslintrc.json | 177 ------------------- bundle/test-utils.d.ts | 8 +- draft-04/json-schema-test-suite.spec.ts | 2 +- draft-06/json-schema-test-suite.spec.ts | 2 +- draft-07/json-schema-test-suite.spec.ts | 2 +- draft-2019-09/json-schema-test-suite.spec.ts | 2 +- draft-2020-12/json-schema-test-suite.spec.ts | 2 +- eslint.config.js | 66 +++++++ lib/common.js | 3 +- lib/experimental.d.ts | 4 +- lib/index.d.ts | 2 +- lib/instance.js | 9 +- lib/schema.js | 2 +- lib/schema.spec.ts | 18 +- lib/to-schema.spec.ts | 20 +-- lib/yaml-schema.spec.ts | 6 +- openapi-3-0/index.d.ts | 2 +- openapi-3-0/json-schema-test-suite.spec.ts | 4 +- openapi-3-1/index.d.ts | 6 +- openapi-3-1/json-schema-test-suite.spec.ts | 2 +- package.json | 7 +- stable/json-schema-test-suite.spec.ts | 2 +- tsconfig.json | 2 + 23 files changed, 121 insertions(+), 229 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f5b45826..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "root": true, - "env": { - "es6": true, - "node": true, - "browser": true - }, - "parserOptions": { - "ecmaVersion": 2023, - "sourceType": "module" - }, - "extends": [ - "eslint:recommended", - "plugin:import/recommended" - ], - "plugins": ["import"], - "settings": { - "import/resolver": { - "node": {}, - "exports": {} - } - }, - "rules": { - "array-bracket-newline": ["error", "consistent"], - "array-bracket-spacing": "error", - "arrow-parens": "error", - "arrow-spacing": "error", - "block-spacing": "error", - "brace-style": "error", - "comma-dangle": "error", - "comma-spacing": "error", - "comma-style": "error", - "curly": "error", - "default-param-last": "error", - "dot-location": ["error", "property"], - "dot-notation": "error", - "eol-last": "error", - "eqeqeq": "error", - "func-call-spacing": "error", - "function-paren-newline": "error", - "generator-star-spacing": ["error", { "before": false, "after": true }], - "implicit-arrow-linebreak": "error", - "indent": ["error", 2, { "ignoreComments": true, "SwitchCase": 1 }], - "key-spacing": "error", - "keyword-spacing": "error", - "linebreak-style": "error", - "max-len": ["warn", { "code": 160, "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreRegExpLiterals": true }], - "new-parens": "error", - "no-caller": "error", - "no-case-declarations": "off", - "no-console": "error", - "no-constant-binary-expression": "error", - "no-constructor-return": "error", - "no-duplicate-imports": "error", - "no-empty-static-block": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-extra-parens": ["error", "all", { "nestedBinaryExpressions": false }], - "no-fallthrough": "off", - "no-floating-decimal": "error", - "no-implicit-globals": "error", - "no-invalid-this": "error", - "no-iterator": "error", - "no-loop-func": "error", - "no-multi-spaces": "error", - "no-multiple-empty-lines": "error", - "no-new-native-nonconstructor": "error", - "no-object-constructor": "error", - "no-promise-executor-return": "error", - "no-proto": "error", - "no-return-assign": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-tabs": "error", - "no-template-curly-in-string": "error", - "no-throw-literal": "error", - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-unmodified-loop-condition": "error", - "no-unused-private-class-members": "error", - "no-unused-vars": ["error", { "argsIgnorePattern": "_.*" }], - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-rename": "error", - "no-whitespace-before-property": "error", - "object-curly-newline": "error", - "object-curly-spacing": ["error", "always"], - "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], - "operator-linebreak": ["error", "before"], - "padded-blocks": ["error", "never"], - "prefer-arrow-callback": "error", - "prefer-const": ["error", { "destructuring": "all" }], - "prefer-numeric-literals": "error", - "prefer-object-has-own": "error", - "prefer-object-spread": "error", - "prefer-promise-reject-errors": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "quotes": ["error", "double", { "allowTemplateLiterals": true }], - "radix": "error", - "rest-spread-spacing": "error", - "semi": "error", - "semi-spacing": "error", - "semi-style": "error", - "space-before-blocks": "error", - "space-before-function-paren": ["error", { "anonymous": "always", "named": "never", "asyncArrow": "always" }], - "space-in-parens": "error", - "space-infix-ops": "error", - "space-unary-ops": "error", - "strict": "error", - "switch-colon-spacing": "error", - "template-curly-spacing": "error", - "template-tag-spacing": "error", - "unicode-bom": "error", - "wrap-iife": "error", - "yield-star-spacing": "error", - "yoda": "error", - "import/extensions": ["error", "always", { "js": "always", "ignorePackages": true }], - "import/newline-after-import": ["error", { "count": 2 }] - }, - "overrides": [ - { - "files": ["**/*.ts"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking" - ], - "parserOptions": { - "project": "./tsconfig.json" - }, - "settings": { - "import/resolver": "typescript" - }, - "rules": { - "no-prototype-builtins": ["off"], - "import/extensions": ["error", "always", { "ts": "never" }], - "@typescript-eslint/array-type": "error", - "@typescript-eslint/consistent-type-assertions": "error", - "@typescript-eslint/consistent-type-definitions": ["error", "type"], - "@typescript-eslint/consistent-type-imports": "error", - "default-param-last": "off", - "@typescript-eslint/default-param-last": "error", - "@typescript-eslint/method-signature-style": "error", - "no-duplicate-imports": "off", - "@typescript-eslint/no-base-to-string": "error", - "@typescript-eslint/no-confusing-void-expression": "error", - "no-loss-of-precision": "off", - "@typescript-eslint/no-loss-of-precision": "error", - "@typescript-eslint/no-meaningless-void-operator": "error", - "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", - "@typescript-eslint/no-unnecessary-condition": "error", - "@typescript-eslint/no-unnecessary-qualifier": "error", - "@typescript-eslint/no-unnecessary-type-arguments": "error", - "@typescript-eslint/no-unnecessary-type-constraint": "error", - "@typescript-eslint/no-unsafe-argument": "warn", - "@typescript-eslint/no-unsafe-assignment": "warn", - "@typescript-eslint/no-unsafe-call": "warn", - "@typescript-eslint/no-unsafe-member-access": "warn", - "@typescript-eslint/no-unsafe-return": "warn", - "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "_.*" }], - "no-unused-expressions": "off", - "@typescript-eslint/no-unused-expressions": "error", - "@typescript-eslint/non-nullable-type-assertion-style": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-reduce-type-parameter": "error", - "no-return-await": "off", - "@typescript-eslint/require-await": ["off"], - "@typescript-eslint/return-await": "error" - } - } - ] -} diff --git a/bundle/test-utils.d.ts b/bundle/test-utils.d.ts index eef7c186..b10a1fa0 100644 --- a/bundle/test-utils.d.ts +++ b/bundle/test-utils.d.ts @@ -12,8 +12,8 @@ type TestCase = { }; type Test = { - description: string, - instance: Json + description: string; + instance: Json; }; export const testSuite: (path: string) => TestCase[]; @@ -22,6 +22,6 @@ export const isCompatible: (compatibility: string | undefined, versionUnderTest: export const loadSchemas: (testCase: TestCase, retrievalUri: string, dialect: string) => void; export const unloadSchemas: (testCase: TestCase, retrievalUri: string, dialect: string) => void; export const toOutput: (instance: JsonNode) => Record, - annotations: Record> + errors: Record; + annotations: Record>; }>; diff --git a/draft-04/json-schema-test-suite.spec.ts b/draft-04/json-schema-test-suite.spec.ts index 9e51e3e0..7e7a8e22 100644 --- a/draft-04/json-schema-test-suite.spec.ts +++ b/draft-04/json-schema-test-suite.spec.ts @@ -23,7 +23,7 @@ type Test = { // is usually because there has been some tradeoff I've made to not support // something that doesn't come up in real schemas in favor of something that has // value. -const skip: Set = new Set([ +const skip = new Set([ // Skip tests for pointers that cross schema resource boundaries. There might // be a way to solve this, but because this functionality has been removed // from the spec and there is no good reason to do this, it will probably not diff --git a/draft-06/json-schema-test-suite.spec.ts b/draft-06/json-schema-test-suite.spec.ts index 9e341fb3..86a2d8c2 100644 --- a/draft-06/json-schema-test-suite.spec.ts +++ b/draft-06/json-schema-test-suite.spec.ts @@ -23,7 +23,7 @@ type Test = { // is usually because there has been some tradeoff I've made to not support // something that doesn't come up in real schemas in favor of something that has // value. -const skip: Set = new Set([ +const skip = new Set([ // Skip tests for pointers that cross schema resource boundaries. There might // be a way to solve this, but because this functionality has been removed // from the spec and there is no good reason to do this, it will probably not diff --git a/draft-07/json-schema-test-suite.spec.ts b/draft-07/json-schema-test-suite.spec.ts index 2feab26c..8f859a87 100644 --- a/draft-07/json-schema-test-suite.spec.ts +++ b/draft-07/json-schema-test-suite.spec.ts @@ -23,7 +23,7 @@ type Test = { // is usually because there has been some tradeoff I've made to not support // something that doesn't come up in real schemas in favor of something that has // value. -const skip: Set = new Set([ +const skip = new Set([ // Skip tests for pointers that cross schema resource boundaries. There might // be a way to solve this, but because this functionality has been removed // from the spec and there is no good reason to do this, it will probably not diff --git a/draft-2019-09/json-schema-test-suite.spec.ts b/draft-2019-09/json-schema-test-suite.spec.ts index a768459c..ca43c578 100644 --- a/draft-2019-09/json-schema-test-suite.spec.ts +++ b/draft-2019-09/json-schema-test-suite.spec.ts @@ -22,7 +22,7 @@ type Test = { // This package is indended to be a compatibility mode from stable JSON Schema. // Some edge cases might not work exactly as specified, but it should work for // any real-life schema. -const skip: Set = new Set([ +const skip = new Set([ // Self-identifying with a `file:` URI is not allowed for security reasons. "|draft2019-09|ref.json|$id with file URI still resolves pointers - *nix", "|draft2019-09|ref.json|$id with file URI still resolves pointers - windows" diff --git a/draft-2020-12/json-schema-test-suite.spec.ts b/draft-2020-12/json-schema-test-suite.spec.ts index 3e988229..2e4af1e6 100644 --- a/draft-2020-12/json-schema-test-suite.spec.ts +++ b/draft-2020-12/json-schema-test-suite.spec.ts @@ -22,7 +22,7 @@ type Test = { // This package is indended to be a compatibility mode from stable JSON Schema. // Some edge cases might not work exactly as specified, but it should work for // any real-life schema. -const skip: Set = new Set([ +const skip = new Set([ // Self-identifying with a `file:` URI is not allowed for security reasons. "|draft2020-12|ref.json|$id with file URI still resolves pointers - *nix", "|draft2020-12|ref.json|$id with file URI still resolves pointers - windows" diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..d5f3f34c --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,66 @@ +import js from "@eslint/js"; +import stylistic from "@stylistic/eslint-plugin"; +import importPlugin from "eslint-plugin-import"; +import globals from "globals"; +import tseslint from "typescript-eslint"; + + +export default [ + js.configs.recommended, + ...tseslint.configs.recommendedTypeChecked, + ...tseslint.configs.stylisticTypeChecked, + importPlugin.flatConfigs.recommended, + stylistic.configs.customize({ + arrowParens: true, + braceStyle: "1tbs", + commaDangle: "never", + flat: true, + jsx: false, + quotes: "double", + semi: true + }), + { + languageOptions: { + ecmaVersion: "latest", + globals: { + ...globals.node + }, + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname + } + }, + settings: { + "import/resolver": { + node: {}, + typescript: {} + } + }, + rules: { + // JavaScript + "no-console": ["error"], + "no-empty-function": "off", + "no-fallthrough": "off", + + // TypeScript + "@typescript-eslint/no-unused-vars": ["error", { caughtErrorsIgnorePattern: "^_" }], + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/consistent-type-definitions": ["error", "type"], + + // Imports + "import/extensions": ["error", "ignorePackages"], + "import/newline-after-import": ["error", { count: 2, exactCount: false, considerComments: true }], + + // Stylistic + "@stylistic/multiline-ternary": "off", + "@stylistic/no-mixed-operators": "off", + "@stylistic/no-multiple-empty-lines": ["error", { max: 2, maxEOF: 0, maxBOF: 0 }], // Allow max=2 for imports + "@stylistic/quote-props": ["error", "consistent"], + "@stylistic/yield-star-spacing": ["error", "after"] + } + }, + { + files: ["**/*.js"], + ...tseslint.configs.disableTypeChecked + } +]; diff --git a/lib/common.js b/lib/common.js index 489be571..28183cdf 100644 --- a/lib/common.js +++ b/lib/common.js @@ -19,9 +19,10 @@ export const jsonTypeOf = (value) => { } else if (Object.getPrototypeOf(value) === Object.prototype) { return "object"; } - default: + default: { const type = jsType === "object" ? Object.getPrototypeOf(value).constructor.name || "anonymous" : jsType; throw Error(`Not a JSON compatible type: ${type}`); + } } }; diff --git a/lib/experimental.d.ts b/lib/experimental.d.ts index ad91e9a7..4c1127e3 100644 --- a/lib/experimental.d.ts +++ b/lib/experimental.d.ts @@ -59,8 +59,8 @@ export const getKeywordName: (dialectId: string, keywordId: string) => string; export const getKeyword: (id: string) => Keyword; export const getKeywordByName: (keywordName: string, dialectId: string) => Keyword; export const getKeywordId: (keywordName: string, dialectId: string) => string; -export const defineVocabulary: (id: string, keywords: { [keyword: string]: string }) => void; -export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]: boolean }, allowUnknownKeywords?: boolean) => void; +export const defineVocabulary: (id: string, keywords: Record) => void; +export const loadDialect: (dialectId: string, dialect: Record, allowUnknownKeywords?: boolean) => void; export const unloadDialect: (dialectId: string) => void; export const hasDialect: (dialectId: string) => boolean; diff --git a/lib/index.d.ts b/lib/index.d.ts index f3192711..e27071e1 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -2,7 +2,7 @@ import type { Json } from "@hyperjump/json-pointer"; export type SchemaFragment = string | number | boolean | null | SchemaObject | SchemaFragment[]; -export type SchemaObject = { +export type SchemaObject = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style [keyword: string]: SchemaFragment; }; diff --git a/lib/instance.js b/lib/instance.js index 6bc6ad4b..72a8f163 100644 --- a/lib/instance.js +++ b/lib/instance.js @@ -34,9 +34,10 @@ export const fromJs = (value, uri = "", pointer = "", parent = undefined) => { } else if (value instanceof Reference) { return fromJs(value.toJSON(), uri, pointer, parent); } - default: + default: { const type = jsType === "object" ? Object.getPrototypeOf(value).constructor.name || "anonymous" : jsType; throw Error(`Not a JSON compatible type: ${type}`); + } } }; @@ -77,14 +78,16 @@ export const has = (key, node) => key in node.value; export const step = (key, node) => { switch (node.type) { - case "object": + case "object": { const property = node.children.find((propertyNode) => { return value(propertyNode.children[0]) === key; }); return property?.children[1]; - case "array": + } + case "array": { const index = parseInt(key, 10); return node.children[index]; + } default: return; } diff --git a/lib/schema.js b/lib/schema.js index 57a01455..98d6dac5 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -14,7 +14,7 @@ export const schemaPlugin = { return buildSchemaDocument(await response.json(), response.url, contextDialectId); }, - fileMatcher: (path) => /(\.|\/)schema\.json$/.test(path) + fileMatcher: async (path) => /(\.|\/)schema\.json$/.test(path) }; const schemaRegistry = {}; diff --git a/lib/schema.spec.ts b/lib/schema.spec.ts index 9f316328..0ee02de6 100644 --- a/lib/schema.spec.ts +++ b/lib/schema.spec.ts @@ -18,19 +18,19 @@ describe("Schema Parsing", () => { unregisterSchema(`https://example.com/schema`); }); - it("boolean schema without context dialect", async () => { + it("boolean schema without context dialect", () => { expect(() => { registerSchema(true, `${testDomain}/schema`); }).to.throw(Error, "Unable to determine a dialect for the schema"); }); - it("schema without context dialect", async () => { + it("schema without context dialect", () => { expect(() => { registerSchema({}, `${testDomain}/schema`); }).to.throw(Error, "Unable to determine a dialect for the schema"); }); - it("schema with unknown dialect", async () => { + it("schema with unknown dialect", () => { expect(() => { registerSchema({ $schema: `${testDomain}/unknown-dialect` @@ -47,7 +47,7 @@ describe("Schema Parsing", () => { expect(browser.document.root).to.not.haveOwnProperty("$schema"); }); - it("schema with no identifier", async () => { + it("schema with no identifier", () => { expect(() => { registerSchema({ $schema: "https://json-schema.org/validation" }); }).to.throw(Error, "Unable to determine an identifier for the schema"); @@ -64,7 +64,7 @@ describe("Schema Parsing", () => { expect(browser.document.baseUri).to.equal(`https://example.com/schema`); }); - it("relative self-identifying schema without retrieval URI", async () => { + it("relative self-identifying schema without retrieval URI", () => { expect(() => { registerSchema({ $schema: "https://json-schema.org/validation", @@ -84,7 +84,7 @@ describe("Schema Parsing", () => { expect(browser.document.baseUri).to.equal(`${testDomain}/relative-schema`); }); - it("self-identifying schema with file scheme", async () => { + it("self-identifying schema with file scheme", () => { expect(() => { registerSchema({ $schema: "https://json-schema.org/validation", @@ -459,7 +459,7 @@ describe("Schema Parsing", () => { expect(browser.document.dynamicAnchors).to.eql({ "": `${testDomain}/schema#` }); }); - it("registering a dialect schema", async () => { + it("registering a dialect schema", () => { registerSchema({ $schema: "https://json-schema.org/validation", $vocabulary: { @@ -470,7 +470,7 @@ describe("Schema Parsing", () => { expect(hasDialect(`${testDomain}/schema`)).to.equal(true); }); - it("unregistering a dialect schema", async () => { + it("unregistering a dialect schema", () => { registerSchema({ $schema: "https://json-schema.org/validation", $vocabulary: { @@ -482,7 +482,7 @@ describe("Schema Parsing", () => { expect(hasDialect(`${testDomain}/schema`)).to.equal(false); }); - it("duplicate registered schema", async () => { + it("duplicate registered schema", () => { const schema = { $schema: "https://json-schema.org/validation" }; diff --git a/lib/to-schema.spec.ts b/lib/to-schema.spec.ts index b3dd90bc..91dea4ca 100644 --- a/lib/to-schema.spec.ts +++ b/lib/to-schema.spec.ts @@ -26,21 +26,21 @@ describe("JSON Schema - toString", () => { schema = await getSchema(`${testDomain}/schema`); }); - test("default options", async () => { + test("default options", () => { expect(toSchema(schema)).to.eql({ $schema: contextDialectId, $id: `${testDomain}/schema` }); }); - test("contextDialectId: stable", async () => { + test("contextDialectId: stable", () => { const options = { contextDialectId: contextDialectId }; expect(toSchema(schema, options)).to.eql({ $id: `${testDomain}/schema` }); }); - test("contextDialectId: 2020-12", async () => { + test("contextDialectId: 2020-12", () => { const options = { contextDialectId: "https://json-schema.org/draft/2020-12/schema" }; expect(toSchema(schema, options)).to.eql({ $schema: contextDialectId, @@ -48,7 +48,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextDialectId: stable, includeDialect: auto", async () => { + test("contextDialectId: stable, includeDialect: auto", () => { const options: ToSchemaOptions = { contextDialectId: contextDialectId, includeDialect: "auto" @@ -58,7 +58,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextDialectId: 2020-12, includeDialect: auto", async () => { + test("contextDialectId: 2020-12, includeDialect: auto", () => { const options: ToSchemaOptions = { contextDialectId: "https://json-schema.org/draft/2020-12/schema", includeDialect: "auto" @@ -69,7 +69,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextDialectId: stable, includeDialect: always", async () => { + test("contextDialectId: stable, includeDialect: always", () => { const options: ToSchemaOptions = { contextDialectId: contextDialectId, includeDialect: "always" @@ -80,7 +80,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextDialectId: stable, includeDialect: never", async () => { + test("contextDialectId: stable, includeDialect: never", () => { const options: ToSchemaOptions = { contextDialectId: contextDialectId, includeDialect: "never" @@ -90,7 +90,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextUri: same as baseURI", async () => { + test("contextUri: same as baseURI", () => { const options: ToSchemaOptions = { contextUri: `${testDomain}/schema` }; @@ -99,7 +99,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextUri: testDomain", async () => { + test("contextUri: testDomain", () => { const options: ToSchemaOptions = { contextUri: testDomain }; @@ -109,7 +109,7 @@ describe("JSON Schema - toString", () => { }); }); - test("contextUri: not relative to baseURI", async () => { + test("contextUri: not relative to baseURI", () => { const options: ToSchemaOptions = { selfIdentify: true, contextUri: "urn:example:example" diff --git a/lib/yaml-schema.spec.ts b/lib/yaml-schema.spec.ts index 3c237386..77fc85a9 100644 --- a/lib/yaml-schema.spec.ts +++ b/lib/yaml-schema.spec.ts @@ -6,7 +6,7 @@ import { MockAgent, setGlobalDispatcher } from "undici"; import contentTypeParser from "content-type"; import { addMediaTypePlugin, value } from "@hyperjump/browser"; import { toAbsoluteIri } from "@hyperjump/uri"; -import { When, Then } from "./gherkin.js"; +import { When, Then } from "./gherkin.ts"; import YAML from "yaml"; import "../stable/index.js"; import { getSchema, buildSchemaDocument } from "./experimental.js"; @@ -23,13 +23,13 @@ const testDomain = "http://test.jsc.hyperjump.io"; addMediaTypePlugin("application/schema+yaml", { parse: async (response) => { const contentType = contentTypeParser.parse(response.headers.get("content-type") ?? ""); - const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile; // eslint-disable-line @typescript-eslint/no-unnecessary-condition + const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile; const json = YAML.parse(await response.text()) as SchemaObject | boolean; return buildSchemaDocument(json, response.url, contextDialectId ? toAbsoluteIri(contextDialectId) : contextDialectId); }, - fileMatcher: async (path) => path.endsWith(".schema.yml") + fileMatcher: async (path) => path.endsWith(".schema.yml") // eslint-disable-line @typescript-eslint/require-await }); describe("Schema.get with YAML", () => { diff --git a/openapi-3-0/index.d.ts b/openapi-3-0/index.d.ts index 5c42ffa8..8aca1866 100644 --- a/openapi-3-0/index.d.ts +++ b/openapi-3-0/index.d.ts @@ -69,7 +69,7 @@ type OpenApi = { }; type Reference = { - $ref: "string" + $ref: "string"; }; type Info = { diff --git a/openapi-3-0/json-schema-test-suite.spec.ts b/openapi-3-0/json-schema-test-suite.spec.ts index bccdefef..e091f3b4 100644 --- a/openapi-3-0/json-schema-test-suite.spec.ts +++ b/openapi-3-0/json-schema-test-suite.spec.ts @@ -21,7 +21,7 @@ type Test = { // This package is indended to be a compatibility mode from stable JSON Schema. // Some edge cases might not work exactly as specified, but it should work for // any real-life schema. -const skip: Set = new Set([ +const skip = new Set([ // Skip tests that ignore keywords in places that are not schemas such as a // $ref in a const. Because this implementation is dialect agnostic, there's // no way to know whether a location is a schema or not. Especially since this @@ -31,7 +31,7 @@ const skip: Set = new Set([ ]); // Ignore tests with keywords that OpenAPI 3.0 doesn't support -const ignore: Set = new Set([ +const ignore = new Set([ "|draft4|additionalItems.json", "|draft4|additionalProperties.json|additionalProperties being false does not allow other properties", "|draft4|additionalProperties.json|non-ASCII pattern with additionalProperties", diff --git a/openapi-3-1/index.d.ts b/openapi-3-1/index.d.ts index 876bab5b..1566196a 100644 --- a/openapi-3-1/index.d.ts +++ b/openapi-3-1/index.d.ts @@ -86,11 +86,11 @@ type Xml = { }; export type OpenApi = { - openapi: string + openapi: string; info: Info; jsonSchemaDialect?: string; servers?: Server[]; - security?: SecurityRequirement[] + security?: SecurityRequirement[]; tags?: Tag[]; externalDocs?: ExternalDocumentation; paths?: Record; @@ -227,7 +227,7 @@ type Callbacks = Record; type Example = { summary?: string; description?: string; - value?: Json, + value?: Json; externalValue?: string; }; diff --git a/openapi-3-1/json-schema-test-suite.spec.ts b/openapi-3-1/json-schema-test-suite.spec.ts index ba524bec..97400111 100644 --- a/openapi-3-1/json-schema-test-suite.spec.ts +++ b/openapi-3-1/json-schema-test-suite.spec.ts @@ -22,7 +22,7 @@ type Test = { // This package is indended to be a compatibility mode from stable JSON Schema. // Some edge cases might not work exactly as specified, but it should work for // any real-life schema. -const skip: Set = new Set([ +const skip = new Set([ // Self-identifying with a `file:` URI is not allowed for security reasons. "|draft2020-12|ref.json|$id with file URI still resolves pointers - *nix", "|draft2020-12|ref.json|$id with file URI still resolves pointers - windows" diff --git a/package.json b/package.json index 416bd6ac..869ffb28 100644 --- a/package.json +++ b/package.json @@ -50,19 +50,16 @@ "url": "https://github.com/sponsors/jdesrosiers" }, "devDependencies": { + "@stylistic/eslint-plugin": "*", "@types/content-type": "*", "@types/node": "*", "@types/uuid": "*", - "@typescript-eslint/eslint-plugin": "*", - "@typescript-eslint/parser": "*", "@vitest/coverage-v8": "*", - "eslint": "*", - "eslint-import-resolver-exports": "*", - "eslint-import-resolver-node": "*", "eslint-import-resolver-typescript": "*", "eslint-plugin-import": "*", "json-schema-test-suite": "github:json-schema-org/JSON-Schema-Test-Suite", "typescript": "*", + "typescript-eslint": "*", "undici": "*", "vitest": "*", "yaml": "*" diff --git a/stable/json-schema-test-suite.spec.ts b/stable/json-schema-test-suite.spec.ts index cc738974..6486818e 100644 --- a/stable/json-schema-test-suite.spec.ts +++ b/stable/json-schema-test-suite.spec.ts @@ -22,7 +22,7 @@ type Test = { // is usually because there has been some tradeoff I've made to not support // something that doesn't come up in real schemas in favor of something that has // value. -const skip: Set = new Set([ +const skip = new Set([ // "filename.json|description" ]); diff --git a/tsconfig.json b/tsconfig.json index dbd3d97e..7447f7b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,9 @@ "moduleResolution": "Node16", "esModuleInterop": true, "strict": true, + "strictNullChecks": true, "allowJs": true, + "allowImportingTsExtensions": true, "skipLibCheck": true } }