Skip to content

Commit 83346cb

Browse files
authored
refactor: use actively maintained json-schema-migrate-x instead (#378)
* refactor: use actively maintained `@unts/json-schema-migrate` instead * Create poor-dolphins-exist.md * Update poor-dolphins-exist.md * chore: enable `prettier-plugin-pkg` correctly * chore: migrate to `json-schema-migrate-x`
1 parent c00ded6 commit 83346cb

File tree

7 files changed

+27
-21
lines changed

7 files changed

+27
-21
lines changed

.changeset/poor-dolphins-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-json-schema-validator": minor
3+
---
4+
5+
refactor: use actively maintained [`json-schema-migrate-x`](https://github.com/un-ts/json-schema-migrate-x) instead

.prettierrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"plugins": ["prettier-plugin-pkg"]
3+
}

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"author": "Yosuke Ota",
88
"funding": "https://github.com/sponsors/ota-meshi",
99
"license": "MIT",
10+
"packageManager": "[email protected]",
1011
"engines": {
1112
"node": "^14.18.0 || >=16.0.0"
1213
},
@@ -28,18 +29,19 @@
2829
"build:ts": "tsc --project ./tsconfig.build.json",
2930
"clean": "rimraf .nyc_output dist coverage",
3031
"cover": "nyc --reporter=lcov yarn test",
31-
"docs:watch": "vitepress dev docs",
3232
"docs:build": "yarn build && vitepress build docs",
3333
"docs:build-and-preview": "yarn docs:build && npx http-server docs/.vitepress/dist",
34+
"docs:watch": "vitepress dev docs",
3435
"lint": "eslint .",
3536
"lint-fix": "yarn lint --fix",
3637
"mocha": "yarn ts node_modules/mocha/bin/mocha",
3738
"new": "yarn ts ./tools/new-rule",
3839
"prebuild": "yarn -s clean",
3940
"predocs:watch": "yarn build",
41+
"prelint": "yarn build",
4042
"prerelease": "yarn test && yarn build",
4143
"preversion": "yarn test && git add .",
42-
"release": "changeset publish",
44+
"release": "clean-pkg-json && changeset publish",
4345
"test": "env-cmd -e test yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
4446
"ts": "env-cmd -e base node -r esbuild-register",
4547
"update": "yarn ts ./tools/update && yarn lint-fix",
@@ -53,9 +55,9 @@
5355
"@eslint-community/eslint-utils": "^4.3.0",
5456
"ajv": "^8.0.0",
5557
"debug": "^4.3.1",
56-
"eslint-compat-utils": "^0.6.0",
58+
"eslint-compat-utils": "^0.6.5",
5759
"eslint-json-compat-utils": "^0.2.1",
58-
"json-schema-migrate": "^2.0.0",
60+
"json-schema-migrate-x": "^2.1.0",
5961
"jsonc-eslint-parser": "^2.0.0",
6062
"minimatch": "^9.0.0 || ^10.0.0",
6163
"synckit": "^0.11.1",
@@ -89,7 +91,7 @@
8991
"eslint-config-prettier": "^10.0.0",
9092
"eslint-plugin-eslint-plugin": "^6.0.0",
9193
"eslint-plugin-jsdoc": "^50.0.0",
92-
"eslint-plugin-json-schema-validator": "^5.0.0",
94+
"eslint-plugin-json-schema-validator": "link:.",
9395
"eslint-plugin-jsonc": "^2.0.0",
9496
"eslint-plugin-markdown": "^5.0.0",
9597
"eslint-plugin-n": "^17.2.0",
@@ -121,6 +123,5 @@
121123
},
122124
"publishConfig": {
123125
"access": "public"
124-
},
125-
"packageManager": "[email protected]"
126+
}
126127
}

src/utils/schema.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import path from "path";
1+
import debugBuilder from "debug";
22
import fs from "fs";
3+
import { draft7 as migrateToDraft7 } from "json-schema-migrate-x";
4+
import path from "path";
5+
36
import type { RuleContext } from "../types";
4-
import { syncGet, get } from "./http-client";
5-
import debugBuilder from "debug";
6-
import type { SchemaObject } from "./types";
7-
import { draft7 as migrateToDraft7 } from "json-schema-migrate";
87
import { getCwd } from "./compat";
8+
import { get, syncGet } from "./http-client";
9+
import type { SchemaObject } from "./types";
10+
911
const debug = debugBuilder("eslint-plugin-json-schema-validator:utils-schema");
1012

1113
const TTL = 1000 * 60 * 60 * 24;

src/utils/validator-factory.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import { draft7 as migrateToDraft7 } from "json-schema-migrate-x";
2+
3+
import type { RuleContext } from "../types";
14
import type {
25
DefinedError,
36
ErrorObject,
7+
RegExpEngine,
48
SchemaObject,
59
ValidateFunction,
6-
RegExpEngine,
710
} from "./ajv";
8-
import type { RuleContext } from "../types";
911
import Ajv from "./ajv";
10-
import { draft7 as migrateToDraft7 } from "json-schema-migrate";
1112
import { loadSchema } from "./schema";
1213

1314
// eslint-disable-next-line func-style -- ignore

tests/src/eslint-plugin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ describe("Integration with eslint-plugin-json-schema-validator", () => {
3535
if (semver.satisfies(ESLint.version, "<7.0.0")) return;
3636
const engine = new ESLint({
3737
cwd: path.join(TEST_FIXTURES_ROOT, "flat-config-test01"),
38-
// @ts-expect-error -- typing bug
3938
overrideConfigFile: true,
40-
// @ts-expect-error -- typing bug
4139
overrideConfig: plugin.configs["flat/recommended"],
4240
});
4341
const results = await engine.lintFiles(["src"]);

tests/src/rules/no-invalid.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ tester.run(
2424
{
2525
filename: path.join(__dirname, ".eslintrc.js"),
2626
code: 'module.exports = { "extends": [ require.resolve("eslint-config-foo") ] }',
27-
// @ts-expect-error -- typeerror
2827
languageOptions: {
2928
// eslint-disable-next-line n/no-extraneous-require -- test
3029
parser: require("espree"),
@@ -74,7 +73,6 @@ tester.run(
7473
{
7574
filename: path.join(__dirname, ".eslintrc.js"),
7675
code: 'module.exports = { "extends": [ 42 ] }',
77-
// @ts-expect-error -- typeerror
7876
languageOptions: {
7977
// eslint-disable-next-line n/no-extraneous-require -- test
8078
parser: require("espree"),
@@ -289,7 +287,6 @@ trailingComma = "es3"
289287
tabWidth = 4
290288
semi = false
291289
singleQuote = true`,
292-
// @ts-expect-error -- typeerror
293290
languageOptions: {
294291
parser: require("toml-eslint-parser"),
295292
},

0 commit comments

Comments
 (0)