-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for flat config (#923)
- Loading branch information
Showing
6 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,7 +1,44 @@ | ||
import type { TSESLint } from '@typescript-eslint/utils'; | ||
|
||
import configs from './configs'; | ||
import rules from './rules'; | ||
import { SupportedTestingFramework } from './utils'; | ||
|
||
// we can't natively import package.json as tsc will copy it into dist/ | ||
const { | ||
name: packageName, | ||
version: packageVersion, | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
} = require('../package.json') as { name: string; version: string }; | ||
|
||
export = { | ||
configs, | ||
const plugin = { | ||
meta: { | ||
name: packageName, | ||
version: packageVersion, | ||
}, | ||
// ugly cast for now to keep TypeScript happy since | ||
// we don't have types for flat config yet | ||
configs: {} as Record< | ||
SupportedTestingFramework | `flat/${SupportedTestingFramework}`, | ||
Pick<Required<TSESLint.Linter.Config>, 'rules'> | ||
>, | ||
rules, | ||
}; | ||
|
||
plugin.configs = { | ||
...configs, | ||
...(Object.fromEntries( | ||
Object.entries(configs).map(([framework, config]) => [ | ||
`flat/${framework}`, | ||
{ | ||
plugins: { 'testing-library': plugin }, | ||
rules: config.rules, | ||
}, | ||
]) | ||
) as Record< | ||
`flat/${SupportedTestingFramework}`, | ||
Pick<Required<TSESLint.Linter.Config>, 'rules'> & { plugins: unknown } | ||
>), | ||
}; | ||
|
||
export = plugin; |
This file contains 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 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