Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

index.ts

49 lines1.3 KB

1import { rules } from './rules'
2import type { ESLint, Linter } from 'eslint'
3import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'
4​
5type RuleKey = keyof typeof rules
6​
7interface Plugin extends Omit<ESLint.Plugin, 'rules'> {
8 rules: Record<RuleKey, RuleModule<any, any, any>>
9 configs: {
10 recommended: ESLint.ConfigData
11 'flat/recommended': Array<Linter.FlatConfig>
12 }
14​
15const plugin: Plugin = {
16 meta: {
17 name: '@tanstack/eslint-plugin-query',
18 },
19 configs: {} as Plugin['configs'],
20 rules,
22​
23// Assign configs here so we can reference `plugin`
24Object.assign(plugin.configs, {
25 recommended: {
26 plugins: ['@tanstack/eslint-plugin-query'],
27 rules: {
28 '@tanstack/query/exhaustive-deps': 'error',
29 '@tanstack/query/no-rest-destructuring': 'warn',
30 '@tanstack/query/stable-query-client': 'error',
31 '@tanstack/query/no-unstable-deps': 'error',
32 },
33 },
34 'flat/recommended': [
35 {
36 plugins: {
37 '@tanstack/query': plugin,
38 },
39 rules: {
40 '@tanstack/query/exhaustive-deps': 'error',
41 '@tanstack/query/no-rest-destructuring': 'warn',
42 '@tanstack/query/stable-query-client': 'error',
43 '@tanstack/query/no-unstable-deps': 'error',
44 },
45 },
46 ],
47})
48​
49export default plugin