Skip to content

Commit

Permalink
chore(legacy): add support for legacy configs
Browse files Browse the repository at this point in the history
  • Loading branch information
veritem committed Apr 23, 2024
1 parent 0535b89 commit 51b1bf3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.ts
Expand Up @@ -63,6 +63,16 @@ const createConfig = <R extends Linter.RulesRecord>(rules: R) => (
[K in keyof R as `vitest/${Extract<K, string>}`]: R[K]
}

const createConfigLegacy = (rules: Record<string, string>) => ({
plugins: ['vitest'],
rules: Object.keys(rules).reduce((acc, ruleName) => {
return {
...acc,
[`vitest/${ruleName}`]: rules[ruleName]
}
}, {})
})

const allRules = {
[lowerCaseTitleName]: 'warn',
[maxNestedDescribeName]: 'warn',
Expand Down Expand Up @@ -181,6 +191,8 @@ const plugin = {
[preferExpectAssertionsName]: preferExpectAssertions
},
configs: {
'legacy-recommended': createConfigLegacy(recommended),
'legacy-all': createConfigLegacy(allRules),
recommended: {
plugins: {
get vitest(): ESLint.Plugin {
Expand Down

0 comments on commit 51b1bf3

Please sign in to comment.