Skip to content

refactor: use actively maintained json-schema-migrate-x instead #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-dolphins-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-json-schema-validator": minor
---

refactor: use actively maintained [`json-schema-migrate-x`](https://github.com/un-ts/json-schema-migrate-x) instead
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"plugins": ["prettier-plugin-pkg"]
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"author": "Yosuke Ota",
"funding": "https://github.com/sponsors/ota-meshi",
"license": "MIT",
"packageManager": "[email protected]",
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
Expand All @@ -28,18 +29,19 @@
"build:ts": "tsc --project ./tsconfig.build.json",
"clean": "rimraf .nyc_output dist coverage",
"cover": "nyc --reporter=lcov yarn test",
"docs:watch": "vitepress dev docs",
"docs:build": "yarn build && vitepress build docs",
"docs:build-and-preview": "yarn docs:build && npx http-server docs/.vitepress/dist",
"docs:watch": "vitepress dev docs",
"lint": "eslint .",
"lint-fix": "yarn lint --fix",
"mocha": "yarn ts node_modules/mocha/bin/mocha",
"new": "yarn ts ./tools/new-rule",
"prebuild": "yarn -s clean",
"predocs:watch": "yarn build",
"prelint": "yarn build",
"prerelease": "yarn test && yarn build",
"preversion": "yarn test && git add .",
"release": "changeset publish",
"release": "clean-pkg-json && changeset publish",
"test": "env-cmd -e test yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
"ts": "env-cmd -e base node -r esbuild-register",
"update": "yarn ts ./tools/update && yarn lint-fix",
Expand All @@ -53,9 +55,9 @@
"@eslint-community/eslint-utils": "^4.3.0",
"ajv": "^8.0.0",
"debug": "^4.3.1",
"eslint-compat-utils": "^0.6.0",
"eslint-compat-utils": "^0.6.5",
"eslint-json-compat-utils": "^0.2.1",
"json-schema-migrate": "^2.0.0",
"json-schema-migrate-x": "^2.1.0",
"jsonc-eslint-parser": "^2.0.0",
"minimatch": "^9.0.0 || ^10.0.0",
"synckit": "^0.11.1",
Expand Down Expand Up @@ -89,7 +91,7 @@
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-eslint-plugin": "^6.0.0",
"eslint-plugin-jsdoc": "^50.0.0",
"eslint-plugin-json-schema-validator": "^5.0.0",
"eslint-plugin-json-schema-validator": "link:.",
"eslint-plugin-jsonc": "^2.0.0",
"eslint-plugin-markdown": "^5.0.0",
"eslint-plugin-n": "^17.2.0",
Expand Down Expand Up @@ -121,6 +123,5 @@
},
"publishConfig": {
"access": "public"
},
"packageManager": "[email protected]"
}
}
12 changes: 7 additions & 5 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import path from "path";
import debugBuilder from "debug";
import fs from "fs";
import { draft7 as migrateToDraft7 } from "json-schema-migrate-x";
import path from "path";

import type { RuleContext } from "../types";
import { syncGet, get } from "./http-client";
import debugBuilder from "debug";
import type { SchemaObject } from "./types";
import { draft7 as migrateToDraft7 } from "json-schema-migrate";
import { getCwd } from "./compat";
import { get, syncGet } from "./http-client";
import type { SchemaObject } from "./types";

const debug = debugBuilder("eslint-plugin-json-schema-validator:utils-schema");

const TTL = 1000 * 60 * 60 * 24;
Expand Down
7 changes: 4 additions & 3 deletions src/utils/validator-factory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { draft7 as migrateToDraft7 } from "json-schema-migrate-x";

import type { RuleContext } from "../types";
import type {
DefinedError,
ErrorObject,
RegExpEngine,
SchemaObject,
ValidateFunction,
RegExpEngine,
} from "./ajv";
import type { RuleContext } from "../types";
import Ajv from "./ajv";
import { draft7 as migrateToDraft7 } from "json-schema-migrate";
import { loadSchema } from "./schema";

// eslint-disable-next-line func-style -- ignore
Expand Down
2 changes: 0 additions & 2 deletions tests/src/eslint-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ describe("Integration with eslint-plugin-json-schema-validator", () => {
if (semver.satisfies(ESLint.version, "<7.0.0")) return;
const engine = new ESLint({
cwd: path.join(TEST_FIXTURES_ROOT, "flat-config-test01"),
// @ts-expect-error -- typing bug
overrideConfigFile: true,
// @ts-expect-error -- typing bug
overrideConfig: plugin.configs["flat/recommended"],
});
const results = await engine.lintFiles(["src"]);
Expand Down
3 changes: 0 additions & 3 deletions tests/src/rules/no-invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ tester.run(
{
filename: path.join(__dirname, ".eslintrc.js"),
code: 'module.exports = { "extends": [ require.resolve("eslint-config-foo") ] }',
// @ts-expect-error -- typeerror
languageOptions: {
// eslint-disable-next-line n/no-extraneous-require -- test
parser: require("espree"),
Expand Down Expand Up @@ -74,7 +73,6 @@ tester.run(
{
filename: path.join(__dirname, ".eslintrc.js"),
code: 'module.exports = { "extends": [ 42 ] }',
// @ts-expect-error -- typeerror
languageOptions: {
// eslint-disable-next-line n/no-extraneous-require -- test
parser: require("espree"),
Expand Down Expand Up @@ -289,7 +287,6 @@ trailingComma = "es3"
tabWidth = 4
semi = false
singleQuote = true`,
// @ts-expect-error -- typeerror
languageOptions: {
parser: require("toml-eslint-parser"),
},
Expand Down
Loading