Skip to content
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

fix: sync vitest compatible rules with jest rules #241

Merged
merged 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: sync vitest compatible rules with jest rules
  • Loading branch information
Sysix committed Nov 9, 2024
commit e4eda3c0039074610b1c8ec180e6c6a25335a971
42 changes: 42 additions & 0 deletions src/__snapshots__/configs.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1286,15 +1286,51 @@ exports[`contains all the oxlint rules 1`] = `
"valid-typeof": [
0,
],
"vitest/consistent-test-it": [
0,
],
"vitest/expect-expect": [
0,
],
"vitest/no-alias-methods": [
0,
],
"vitest/no-commented-out-tests": [
0,
],
"vitest/no-conditional-expect": [
0,
],
"vitest/no-conditional-in-test": [
0,
],
"vitest/no-conditional-tests": [
0,
],
"vitest/no-disabled-tests": [
0,
],
"vitest/no-focused-tests": [
0,
],
"vitest/no-identical-title": [
0,
],
"vitest/no-import-node-test": [
0,
],
"vitest/no-restricted-jest-methods": [
0,
],
"vitest/no-test-prefixes": [
0,
],
"vitest/prefer-each": [
0,
],
"vitest/prefer-hooks-in-order": [
0,
],
"vitest/prefer-to-be-falsy": [
0,
],
Expand All @@ -1307,5 +1343,11 @@ exports[`contains all the oxlint rules 1`] = `
"vitest/require-local-test-context-for-concurrent-snapshots": [
0,
],
"vitest/valid-describe-callback": [
0,
],
"vitest/valid-expect": [
0,
],
}
`;
22 changes: 21 additions & 1 deletion src/build-from-oxlint-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
import fs from 'node:fs';
import { execSync } from 'node:child_process';
import type { Linter } from 'eslint';
import { typescriptRulesExtendEslintRules } from './constants.js';
import {
typescriptRulesExtendEslintRules,
viteTestCompatibleRules,
} from './constants.js';

describe('buildFromOxlintConfig', () => {
describe('rule values', () => {
Expand Down Expand Up @@ -184,6 +187,23 @@ describe('buildFromOxlintConfig', () => {
expect('unknown' in configs[0].rules!).toBe(false);
expect('@next/next/no-img-element' in configs[0].rules!).toBe(false);
});

for (const alias of viteTestCompatibleRules) {
it(`disables matching vitest and jest rules for ${alias}`, () => {
for (const rule of [alias, `jest/${alias}`, `vitest/${alias}`]) {
const rules = buildFromOxlintConfig({
rules: {
[rule]: 'warn',
},
});

expect(rules.length).toBe(1);
expect(rules[0].rules).not.toBeUndefined();
expect(`vitest/${alias}` in rules[0].rules!).toBe(true);
expect(`jest/${alias}` in rules[0].rules!).toBe(true);
}
});
}
});

const createConfigFileAndBuildFromIt = (
Expand Down
Loading