From cd267a9b27369c5c9180a9f0adb96117455f2c83 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Thu, 22 Jan 2026 17:46:04 -0700 Subject: [PATCH 01/11] Generate the list of vitest-compatible rules by fetching them from the oxc GitHub repo. And format the repo automatically when running pnpm generate, to avoid needing to do that manually. --- package.json | 2 +- scripts/generate.ts | 26 +++++++++++ .../vitest-compatible-jest-rules.json | 43 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/generated/vitest-compatible-jest-rules.json diff --git a/package.json b/package.json index 94aabe6b..0145fe8d 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "scripts": { "prepare": "husky", - "generate": "node --import @oxc-node/core/register ./scripts/generate.ts", + "generate": "node --import @oxc-node/core/register ./scripts/generate.ts && pnpm format", "format": "oxfmt", "lint": "oxlint --type-aware --type-check", "test": "vitest", diff --git a/scripts/generate.ts b/scripts/generate.ts index 3f6492ea..5c2eb9b7 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -14,3 +14,29 @@ if (!fs.existsSync(generateFolder)) { const generator = new RulesGenerator(result); await generator.generateRules(generateFolder); + +console.log('Rules generated successfully.'); + +// Generate the vitest-compatible-jest-rules.json file by pulling it from the main oxc repository. +// This keeps the two in sync. +// my commit on my branch, TODO: change to main +const gitRef = '7ece6ab1f325d419741c92980d65418c9222009f'; +const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; +const response = await fetch(githubURL); + +if (!response.ok) { + throw new Error( + `Failed to fetch vitest-compatible-jest-rules.json: ${response.status} ${response.statusText}` + ); +} + +const vitestRules = await response.text(); +const vitestRulesPath = path.resolve( + generateFolder, + 'vitest-compatible-jest-rules.json' +); +fs.writeFileSync(vitestRulesPath, vitestRules, 'utf-8'); + +console.log( + 'vitest-compatible-jest-rules.json copied successfully from the oxc repo.' +); diff --git a/src/generated/vitest-compatible-jest-rules.json b/src/generated/vitest-compatible-jest-rules.json new file mode 100644 index 00000000..80f61509 --- /dev/null +++ b/src/generated/vitest-compatible-jest-rules.json @@ -0,0 +1,43 @@ +[ + "consistent-test-it", + "expect-expect", + "max-expects", + "max-nested-describe", + "no-alias-methods", + "no-commented-out-tests", + "no-conditional-expect", + "no-conditional-in-test", + "no-disabled-tests", + "no-duplicate-hooks", + "no-focused-tests", + "no-hooks", + "no-identical-title", + "no-interpolation-in-snapshots", + "no-large-snapshots", + "no-mocks-import", + "no-restricted-jest-methods", + "no-restricted-matchers", + "no-standalone-expect", + "no-test-prefixes", + "no-test-return-statement", + "prefer-called-with", + "prefer-comparison-matcher", + "prefer-each", + "prefer-equality-matcher", + "prefer-expect-resolves", + "prefer-hooks-in-order", + "prefer-hooks-on-top", + "prefer-lowercase-title", + "prefer-mock-promise-shorthand", + "prefer-spy-on", + "prefer-strict-equal", + "prefer-to-be", + "prefer-to-contain", + "prefer-to-have-length", + "prefer-todo", + "require-hook", + "require-to-throw-message", + "require-top-level-describe", + "valid-describe-callback", + "valid-expect" +] From 00381111e4a353e3f3a33cb555d8fd435f489963 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Thu, 22 Jan 2026 17:49:26 -0700 Subject: [PATCH 02/11] refactor: Use the JSON file for traverse-rules.ts. And update the generator script to do the vitest update first, then the rules generation. Otherwise it may use outdated data to generate the rules list. Now we have a single source of truth for the vitest-compatible-jest-rules :) --- scripts/constants.ts | 47 --------------------------------------- scripts/generate.ts | 10 ++++----- scripts/traverse-rules.ts | 5 +++-- 3 files changed, 8 insertions(+), 54 deletions(-) diff --git a/scripts/constants.ts b/scripts/constants.ts index 9e32a2d4..d886a7bd 100644 --- a/scripts/constants.ts +++ b/scripts/constants.ts @@ -14,53 +14,6 @@ export const aliasPluginNames: Record = { jsx_a11y: 'jsx-a11y', }; -// Some vitest rules are re-implemented version of jest rules. -// Since oxlint supports these rules under jest/*, we need to remap them. -// remapping in source-code: -export const viteTestCompatibleRules = [ - 'consistent-test-it', - 'expect-expect', - 'max-expects', - 'max-nested-describe', - 'no-alias-methods', - 'no-commented-out-tests', - 'no-conditional-expect', - 'no-conditional-in-test', - 'no-disabled-tests', - 'no-duplicate-hooks', - 'no-focused-tests', - 'no-hooks', - 'no-identical-title', - 'no-interpolation-in-snapshots', - 'no-large-snapshots', - 'no-mocks-import', - 'no-restricted-jest-methods', - 'no-restricted-matchers', - 'no-standalone-expect', - 'no-test-prefixes', - 'no-test-return-statement', - 'prefer-called-with', - 'prefer-comparison-matcher', - 'prefer-each', - 'prefer-equality-matcher', - 'prefer-expect-resolves', - 'require-hook', - 'prefer-hooks-in-order', - 'prefer-hooks-on-top', - 'prefer-lowercase-title', - 'prefer-mock-promise-shorthand', - 'prefer-spy-on', - 'prefer-strict-equal', - 'prefer-to-be', - 'prefer-to-contain', - 'prefer-to-have-length', - 'prefer-todo', - 'require-to-throw-message', - 'require-top-level-describe', - 'valid-describe-callback', - 'valid-expect', -]; - export const unicornRulesExtendEslintRules = ['no-negated-condition']; // All rules from `eslint-plugin-react-hooks` diff --git a/scripts/generate.ts b/scripts/generate.ts index 5c2eb9b7..e5f2a039 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -12,11 +12,6 @@ if (!fs.existsSync(generateFolder)) { fs.mkdirSync(generateFolder); } -const generator = new RulesGenerator(result); -await generator.generateRules(generateFolder); - -console.log('Rules generated successfully.'); - // Generate the vitest-compatible-jest-rules.json file by pulling it from the main oxc repository. // This keeps the two in sync. // my commit on my branch, TODO: change to main @@ -40,3 +35,8 @@ fs.writeFileSync(vitestRulesPath, vitestRules, 'utf-8'); console.log( 'vitest-compatible-jest-rules.json copied successfully from the oxc repo.' ); + +const generator = new RulesGenerator(result); +await generator.generateRules(generateFolder); + +console.log('Rules generated successfully.'); diff --git a/scripts/traverse-rules.ts b/scripts/traverse-rules.ts index 882d5829..964d5ef7 100644 --- a/scripts/traverse-rules.ts +++ b/scripts/traverse-rules.ts @@ -3,8 +3,9 @@ import { aliasPluginNames, reactHookRulesInsideReactScope, unicornRulesExtendEslintRules, - viteTestCompatibleRules, } from './constants.js'; + +import vitestCompatibleRules from '../src/generated/vitest-compatible-jest-rules.json' with { type: 'json' }; import { typescriptRulesExtendEslintRules } from '../src/constants.js'; export type Rule = { @@ -70,7 +71,7 @@ function getAliasRules(rule: Rule): Rule | undefined { }; } - if (rule.scope === 'jest' && viteTestCompatibleRules.includes(rule.value)) { + if (rule.scope === 'jest' && vitestCompatibleRules.includes(rule.value)) { return { value: `vitest/${rule.value}`, scope: 'vitest', From 04a50576670b6878cb362eed1590d4fea17c3a2a Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Thu, 22 Jan 2026 17:55:56 -0700 Subject: [PATCH 03/11] Simplify the generate action in CI. No need to remove the existing files, and no need to format as that's done as part of `generate` now. --- .github/workflows/generate.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 89cf38ed..656d14a0 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -29,14 +29,8 @@ jobs: - uses: ./.github/actions/pnpm - - name: Remove current generated code - run: rm -r ./src/generated/ - - name: Generate from source code run: pnpm run generate - - name: Format generated code - run: pnpm run format - - name: Check for git diff run: git diff --exit-code From f91fdf9324c83db6a2118c90efeea43f4812e603 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Thu, 22 Jan 2026 19:50:24 -0700 Subject: [PATCH 04/11] Update the script to use a version tag. --- .github/workflows/bump_oxlint.yml | 3 +-- scripts/generate.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump_oxlint.yml b/.github/workflows/bump_oxlint.yml index 8203414a..1e2e697f 100644 --- a/.github/workflows/bump_oxlint.yml +++ b/.github/workflows/bump_oxlint.yml @@ -30,8 +30,7 @@ jobs: OXLINT_VERSION: ${{ inputs.version }} run: | pnpm install oxlint@${OXLINT_VERSION} - pnpm run generate # Generate rules - pnpm run format # run oxfmt over it + pnpm run generate --version=${OXLINT_VERSION} # Generate rules - name: Test and update snapshot continue-on-error: true # we check in PR why it fails diff --git a/scripts/generate.ts b/scripts/generate.ts index e5f2a039..045b7e05 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -12,10 +12,22 @@ if (!fs.existsSync(generateFolder)) { fs.mkdirSync(generateFolder); } -// Generate the vitest-compatible-jest-rules.json file by pulling it from the main oxc repository. +// Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. // This keeps the two in sync. -// my commit on my branch, TODO: change to main -const gitRef = '7ece6ab1f325d419741c92980d65418c9222009f'; +// Default to 'main' but allow overriding with --version (either --version= or --version ) +let gitRef = 'main'; +const versionArgIndex = process.argv.findIndex( + (a) => a === '--version' || a.startsWith('--version=') +); +if (versionArgIndex !== -1) { + const arg = process.argv[versionArgIndex]; + if (arg.startsWith('--version=')) { + gitRef = arg.split('=')[1] || 'main'; + } else { + gitRef = process.argv[versionArgIndex + 1] || 'main'; + } +} + const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; const response = await fetch(githubURL); From c9aefa6129b119afff15bcab264cfb4e8a9b96ba Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:16:19 -0700 Subject: [PATCH 05/11] Remove the version flag, use the package version instead. --- .github/workflows/bump_oxlint.yml | 12 ++++++------ scripts/generate.ts | 16 +++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/bump_oxlint.yml b/.github/workflows/bump_oxlint.yml index 1e2e697f..52046bea 100644 --- a/.github/workflows/bump_oxlint.yml +++ b/.github/workflows/bump_oxlint.yml @@ -23,6 +23,11 @@ jobs: with: persist-credentials: false # should be fine, we give another token for PR creation + - name: Bump Version + env: + OXLINT_VERSION: ${{ inputs.version }} + run: npm version ${OXLINT_VERSION} --no-git-tag-version + - uses: ./.github/actions/pnpm - name: Generate version ${{ inputs.version }} @@ -30,17 +35,12 @@ jobs: OXLINT_VERSION: ${{ inputs.version }} run: | pnpm install oxlint@${OXLINT_VERSION} - pnpm run generate --version=${OXLINT_VERSION} # Generate rules + pnpm run generate # Generate rules - name: Test and update snapshot continue-on-error: true # we check in PR why it fails run: pnpm run test -u # Update test snapshots - - name: Bump Version - env: - OXLINT_VERSION: ${{ inputs.version }} - run: npm version ${OXLINT_VERSION} --no-git-tag-version - - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 with: # bot account with PAT required for triggering workflow runs diff --git a/scripts/generate.ts b/scripts/generate.ts index 045b7e05..468be845 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -2,6 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { RulesGenerator } from './generator.js'; import { traverseRules } from './traverse-rules.js'; +import packageJson from '../package.json' with { type: 'json' }; const result = traverseRules(); @@ -14,19 +15,8 @@ if (!fs.existsSync(generateFolder)) { // Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. // This keeps the two in sync. -// Default to 'main' but allow overriding with --version (either --version= or --version ) -let gitRef = 'main'; -const versionArgIndex = process.argv.findIndex( - (a) => a === '--version' || a.startsWith('--version=') -); -if (versionArgIndex !== -1) { - const arg = process.argv[versionArgIndex]; - if (arg.startsWith('--version=')) { - gitRef = arg.split('=')[1] || 'main'; - } else { - gitRef = process.argv[versionArgIndex + 1] || 'main'; - } -} +// Use the version of the package to determine which git ref to pull from. +const gitRef = `v${packageJson.version}`; const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; const response = await fetch(githubURL); From f4e8bf462e011faa10f25c71996be3529d8bb89e Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:19:46 -0700 Subject: [PATCH 06/11] Fix version tag. --- scripts/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.ts b/scripts/generate.ts index 468be845..30c825a0 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -16,7 +16,7 @@ if (!fs.existsSync(generateFolder)) { // Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. // This keeps the two in sync. // Use the version of the package to determine which git ref to pull from. -const gitRef = `v${packageJson.version}`; +const gitRef = `oxlint_v${packageJson.version}`; const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; const response = await fetch(githubURL); From 6fc42d4ba3820514fdb9f345469e4f6652ae828c Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:22:52 -0700 Subject: [PATCH 07/11] Move vitest-compatible-jest-rules to scripts directory. --- scripts/generate.ts | 2 +- {src => scripts}/generated/vitest-compatible-jest-rules.json | 0 scripts/traverse-rules.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {src => scripts}/generated/vitest-compatible-jest-rules.json (100%) diff --git a/scripts/generate.ts b/scripts/generate.ts index 30c825a0..ed3bfd79 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -7,7 +7,7 @@ import packageJson from '../package.json' with { type: 'json' }; const result = traverseRules(); const __dirname = new URL('.', import.meta.url).pathname; -const generateFolder = path.resolve(__dirname, '..', `src/generated`); +const generateFolder = path.resolve(__dirname, `generated`); if (!fs.existsSync(generateFolder)) { fs.mkdirSync(generateFolder); diff --git a/src/generated/vitest-compatible-jest-rules.json b/scripts/generated/vitest-compatible-jest-rules.json similarity index 100% rename from src/generated/vitest-compatible-jest-rules.json rename to scripts/generated/vitest-compatible-jest-rules.json diff --git a/scripts/traverse-rules.ts b/scripts/traverse-rules.ts index 964d5ef7..4f8d277f 100644 --- a/scripts/traverse-rules.ts +++ b/scripts/traverse-rules.ts @@ -5,7 +5,7 @@ import { unicornRulesExtendEslintRules, } from './constants.js'; -import vitestCompatibleRules from '../src/generated/vitest-compatible-jest-rules.json' with { type: 'json' }; +import vitestCompatibleRules from './generated/vitest-compatible-jest-rules.json' with { type: 'json' }; import { typescriptRulesExtendEslintRules } from '../src/constants.js'; export type Rule = { From 0b3120b00796a081a88ff2c8354e279f70c9d598 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:29:52 -0700 Subject: [PATCH 08/11] temporarily set the ref to main so the script works without failing --- scripts/generate.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/generate.ts b/scripts/generate.ts index ed3bfd79..b3b7273d 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { RulesGenerator } from './generator.js'; import { traverseRules } from './traverse-rules.js'; -import packageJson from '../package.json' with { type: 'json' }; +// import packageJson from '../package.json' with { type: 'json' }; const result = traverseRules(); @@ -16,7 +16,8 @@ if (!fs.existsSync(generateFolder)) { // Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. // This keeps the two in sync. // Use the version of the package to determine which git ref to pull from. -const gitRef = `oxlint_v${packageJson.version}`; +// const gitRef = `oxlint_v${packageJson.version}`; +const gitRef = `main`; // temp so we can test that this works. DO NOT LEAVE THIS AS MAIN! const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; const response = await fetch(githubURL); From d29945f2463caa706ab2bf0b2784f986f843c968 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:36:44 -0700 Subject: [PATCH 09/11] Add back the removal of generated files to generate.yml. Needed to rereder generate.ts to have the vitest rules generation first, before the rules generation, otherwise the JSON file imported by traverseRules() won't work. --- .github/workflows/generate.yml | 3 +++ scripts/generate.ts | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 656d14a0..fe7b2710 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -29,6 +29,9 @@ jobs: - uses: ./.github/actions/pnpm + - name: Remove current generated code + run: rm -r ./src/generated/ && rm -r ./scripts/generated/ + - name: Generate from source code run: pnpm run generate diff --git a/scripts/generate.ts b/scripts/generate.ts index b3b7273d..bd45b586 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -4,13 +4,14 @@ import { RulesGenerator } from './generator.js'; import { traverseRules } from './traverse-rules.js'; // import packageJson from '../package.json' with { type: 'json' }; -const result = traverseRules(); +// --- Generate the vitest rules file --- const __dirname = new URL('.', import.meta.url).pathname; -const generateFolder = path.resolve(__dirname, `generated`); +// `/scripts/generated/` +const scriptsGenerateFolder = path.resolve(__dirname, `generated`); -if (!fs.existsSync(generateFolder)) { - fs.mkdirSync(generateFolder); +if (!fs.existsSync(scriptsGenerateFolder)) { + fs.mkdirSync(scriptsGenerateFolder); } // Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. @@ -30,7 +31,7 @@ if (!response.ok) { const vitestRules = await response.text(); const vitestRulesPath = path.resolve( - generateFolder, + scriptsGenerateFolder, 'vitest-compatible-jest-rules.json' ); fs.writeFileSync(vitestRulesPath, vitestRules, 'utf-8'); @@ -39,7 +40,17 @@ console.log( 'vitest-compatible-jest-rules.json copied successfully from the oxc repo.' ); +// --- Generate the rules files --- + +const result = traverseRules(); const generator = new RulesGenerator(result); + +// `/src/generated/` +const generateFolder = path.resolve(__dirname, '..', `src/generated`); +if (!fs.existsSync(generateFolder)) { + fs.mkdirSync(generateFolder); +} + await generator.generateRules(generateFolder); console.log('Rules generated successfully.'); From bdd13c243106ba4bc9998b418278fc109a22a315 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 24 Jan 2026 13:40:55 -0700 Subject: [PATCH 10/11] Split `pnpm generate` into two separate scripts so the import of the generated JSON file works. Otherwise, we get an error due to the import being resolved immediately upon execution of the file, before the JSON file exists (assuming it has been deleted). --- package.json | 2 +- scripts/generate-vitest-rules.ts | 39 ++++++++++++++++++++++++++++++++ scripts/generate.ts | 37 ------------------------------ 3 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 scripts/generate-vitest-rules.ts diff --git a/package.json b/package.json index 0145fe8d..4327df8f 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "scripts": { "prepare": "husky", - "generate": "node --import @oxc-node/core/register ./scripts/generate.ts && pnpm format", + "generate": "node --import @oxc-node/core/register ./scripts/generate-vitest-rules.ts && node --import @oxc-node/core/register ./scripts/generate.ts && pnpm format", "format": "oxfmt", "lint": "oxlint --type-aware --type-check", "test": "vitest", diff --git a/scripts/generate-vitest-rules.ts b/scripts/generate-vitest-rules.ts new file mode 100644 index 00000000..e4e6cdb5 --- /dev/null +++ b/scripts/generate-vitest-rules.ts @@ -0,0 +1,39 @@ +import fs from 'node:fs'; +import path from 'node:path'; +// import packageJson from '../package.json' with { type: 'json' }; + +// --- Generate the vitest rules file --- + +const __dirname = new URL('.', import.meta.url).pathname; +// `/scripts/generated/` +const scriptsGenerateFolder = path.resolve(__dirname, `generated`); + +if (!fs.existsSync(scriptsGenerateFolder)) { + fs.mkdirSync(scriptsGenerateFolder); +} + +// Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. +// This keeps the two in sync. +// Use the version of the package to determine which git ref to pull from. +// const gitRef = `oxlint_v${packageJson.version}`; +const gitRef = `main`; // temp so we can test that this works. DO NOT LEAVE THIS AS MAIN! + +const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; +const response = await fetch(githubURL); + +if (!response.ok) { + throw new Error( + `Failed to fetch vitest-compatible-jest-rules.json: ${response.status} ${response.statusText}` + ); +} + +const vitestRules = await response.text(); +const vitestRulesPath = path.resolve( + scriptsGenerateFolder, + 'vitest-compatible-jest-rules.json' +); +fs.writeFileSync(vitestRulesPath, vitestRules, 'utf-8'); + +console.log( + 'vitest-compatible-jest-rules.json copied successfully from the oxc repo.' +); diff --git a/scripts/generate.ts b/scripts/generate.ts index bd45b586..4e8a7617 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -2,45 +2,8 @@ import fs from 'node:fs'; import path from 'node:path'; import { RulesGenerator } from './generator.js'; import { traverseRules } from './traverse-rules.js'; -// import packageJson from '../package.json' with { type: 'json' }; - -// --- Generate the vitest rules file --- const __dirname = new URL('.', import.meta.url).pathname; -// `/scripts/generated/` -const scriptsGenerateFolder = path.resolve(__dirname, `generated`); - -if (!fs.existsSync(scriptsGenerateFolder)) { - fs.mkdirSync(scriptsGenerateFolder); -} - -// Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. -// This keeps the two in sync. -// Use the version of the package to determine which git ref to pull from. -// const gitRef = `oxlint_v${packageJson.version}`; -const gitRef = `main`; // temp so we can test that this works. DO NOT LEAVE THIS AS MAIN! - -const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; -const response = await fetch(githubURL); - -if (!response.ok) { - throw new Error( - `Failed to fetch vitest-compatible-jest-rules.json: ${response.status} ${response.statusText}` - ); -} - -const vitestRules = await response.text(); -const vitestRulesPath = path.resolve( - scriptsGenerateFolder, - 'vitest-compatible-jest-rules.json' -); -fs.writeFileSync(vitestRulesPath, vitestRules, 'utf-8'); - -console.log( - 'vitest-compatible-jest-rules.json copied successfully from the oxc repo.' -); - -// --- Generate the rules files --- const result = traverseRules(); const generator = new RulesGenerator(result); From afbcee71d01d50f1836f11ad3d073b64c2fe97aa Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Mon, 26 Jan 2026 16:45:48 -0700 Subject: [PATCH 11/11] Use the correct gitRef. --- scripts/generate-vitest-rules.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/generate-vitest-rules.ts b/scripts/generate-vitest-rules.ts index e4e6cdb5..58b640e1 100644 --- a/scripts/generate-vitest-rules.ts +++ b/scripts/generate-vitest-rules.ts @@ -1,6 +1,6 @@ import fs from 'node:fs'; import path from 'node:path'; -// import packageJson from '../package.json' with { type: 'json' }; +import packageJson from '../package.json' with { type: 'json' }; // --- Generate the vitest rules file --- @@ -15,8 +15,7 @@ if (!fs.existsSync(scriptsGenerateFolder)) { // Generate the vitest-compatible-jest-rules.json file by pulling it from the oxc repository. // This keeps the two in sync. // Use the version of the package to determine which git ref to pull from. -// const gitRef = `oxlint_v${packageJson.version}`; -const gitRef = `main`; // temp so we can test that this works. DO NOT LEAVE THIS AS MAIN! +const gitRef = `oxlint_v${packageJson.version}`; const githubURL = `https://raw.githubusercontent.com/oxc-project/oxc/${gitRef}/crates/oxc_linter/data/vitest_compatible_jest_rules.json`; const response = await fetch(githubURL);