Skip to content
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
2 changes: 2 additions & 0 deletions apps/oxlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"build-napi-test": "pnpm run build-napi --features testing",
"build-napi-release": "pnpm run build-napi --release --features allocator",
"build-js": "node scripts/build.ts",
"generate-config-types": "node scripts/generate-config-types.ts",
"test": "vitest --dir ./test run",
"init-conformance": "cd conformance; ./init.sh",
"conformance": "cross-env NODE_DISABLE_COLORS=1 tsx ./conformance/src/index.ts"
Expand All @@ -54,6 +55,7 @@
"eslint-vitest-rule-tester": "^3.0.1",
"esquery": "^1.6.0",
"execa": "^9.6.0",
"json-schema-to-typescript": "^15.0.4",
"json-stable-stringify-without-jsonify": "^1.0.1",
"oxc-parser": "^0.111.0",
"rolldown": "catalog:",
Expand Down
31 changes: 31 additions & 0 deletions apps/oxlint/scripts/generate-config-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// oxlint-disable no-console

import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import { compile } from "json-schema-to-typescript";

const scriptDir = dirname(fileURLToPath(import.meta.url));
const oxlintDir = resolve(scriptDir, "..");
const repoRoot = resolve(oxlintDir, "..", "..");

const schemaPath = resolve(repoRoot, "npm/oxlint/configuration_schema.json");
const outputPath = resolve(oxlintDir, "src-js/package/config.generated.ts");

if (!existsSync(schemaPath)) {
throw new Error(`Missing schema at ${schemaPath}. Run just linter-schema-json first.`);
}

const schema = JSON.parse(readFileSync(schemaPath, "utf8"));

const bannerComment =
"/*\n" +
" * This file is generated from npm/oxlint/configuration_schema.json.\n" +
" * Run `just linter-config-ts` to regenerate.\n" +
" */";

const ts = await compile(schema, "OxlintConfig", { bannerComment });

writeFileSync(outputPath, ts);
console.log(`Wrote ${outputPath}`);
Loading
Loading