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

index.ts

52 lines1.4 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​
7export interface 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.Config>
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/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 '@tanstack/query/infinite-query-property-order': 'error',
33 },
34 },
35 'flat/recommended': [
36 {
37 name: 'tanstack/query/flat/recommended',
38 plugins: {
39 '@tanstack/query': plugin,
40 },
41 rules: {
42 '@tanstack/query/exhaustive-deps': 'error',
43 '@tanstack/query/no-rest-destructuring': 'warn',
44 '@tanstack/query/stable-query-client': 'error',
45 '@tanstack/query/no-unstable-deps': 'error',
46 '@tanstack/query/infinite-query-property-order': 'error',
47 },
48 },
49 ],
50})
51​
52export default plugin