Skip to content

Commit

Permalink
chore(legacy): add support for legacy configs (#434)
Browse files Browse the repository at this point in the history
* chore(legacy): add support for legacy configs

* chore(deps): upgrade dependancies
  • Loading branch information
veritem committed Apr 23, 2024
1 parent 0535b89 commit 2696f0d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 70 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -42,12 +42,12 @@
},
"devDependencies": {
"@stylistic/eslint-plugin": "^1.7.2",
"@types/eslint": "^8.56.9",
"@types/eslint": "^8.56.10",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/rule-tester": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/rule-tester": "^7.7.1",
"@veritem/eslint-config": "^0.0.11",
"bumpp": "^9.4.0",
"concurrently": "^8.2.2",
Expand Down Expand Up @@ -79,6 +79,6 @@
}
},
"dependencies": {
"@typescript-eslint/utils": "^7.7.0"
"@typescript-eslint/utils": "^7.7.1"
}
}
126 changes: 61 additions & 65 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 2696f0d

Please sign in to comment.