Skip to content

Commit

Permalink
fix: sync vitest compatible rules with jest rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix committed Dec 6, 2024
1 parent 3e295bb commit 33bfa32
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/build-from-oxlint-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,17 @@ describe('buildFromOxlintConfig', () => {
});

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({
it(`disables vitest jest alias rules for ${alias}`, () => {
for (const rule of [`jest/${alias}`, `vitest/${alias}`]) {
const configs = 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);
expect(configs.length).toBe(1);
expect(configs[0].rules).not.toBeUndefined();
expect(rule in configs[0].rules!).toBe(true);
}
});
}
Expand Down Expand Up @@ -426,6 +425,13 @@ describe('integration test with oxlint', () => {
).length;
}

// special case for vitest / jest alias rules
if (config.plugins?.includes('vitest')) {
expectedCount += viteTestCompatibleRules.filter(
(aliasRule) => `vitest/${aliasRule}` in configs[0].rules!
).length;
}

expect(Object.keys(configs[0].rules!).length).toBe(expectedCount);
});
}
Expand Down

0 comments on commit 33bfa32

Please sign in to comment.