-
-
Notifications
You must be signed in to change notification settings - Fork 12
Automatically sync Vitest-compatible rules list from oxc repo #344
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cd267a9
Generate the list of vitest-compatible rules by fetching them from th…
connorshea 0038111
refactor: Use the JSON file for traverse-rules.ts.
connorshea 04a5057
Simplify the generate action in CI.
connorshea f91fdf9
Update the script to use a version tag.
connorshea c9aefa6
Remove the version flag, use the package version instead.
connorshea f4e8bf4
Fix version tag.
connorshea 6fc42d4
Move vitest-compatible-jest-rules to scripts directory.
connorshea 0b3120b
temporarily set the ref to main so the script works without failing
connorshea d29945f
Add back the removal of generated files to generate.yml.
connorshea bdd13c2
Split `pnpm generate` into two separate scripts so the import of the …
connorshea afbcee7
Use the correct gitRef.
connorshea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,53 +14,6 @@ export const aliasPluginNames: Record<string, string> = { | |
| 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: <https://github.com/oxc-project/oxc/blob/94320ab6f60ef6aaedeb901b04ccb57e953f66bf/crates/oxc_linter/src/utils/mod.rs> | ||
| export const viteTestCompatibleRules = [ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed that this is identical to the JSON file (except that require-hook is alphabetically sorted in the JSON file and it was out of order here) |
||
| '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` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 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; | ||
| // `<repo>/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 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.' | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| [ | ||
|
connorshea marked this conversation as resolved.
|
||
| "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" | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.