Open History to see the last commit
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 }
13}
14β
15export const plugin = {
16 meta: {
17 name: '@tanstack/eslint-plugin-query',
18 },
19 configs: {
20 recommended: {
21 plugins: ['@tanstack/query'],
22 rules: {
23 '@tanstack/query/exhaustive-deps': 'error',
24 '@tanstack/query/no-rest-destructuring': 'warn',
25 '@tanstack/query/stable-query-client': 'error',
26 '@tanstack/query/no-unstable-deps': 'error',
27 '@tanstack/query/infinite-query-property-order': 'error',
28 '@tanstack/query/no-void-query-fn': 'error',
29 '@tanstack/query/mutation-property-order': 'error',
30 },
31 },
32 'flat/recommended': [
33 {
34 name: 'tanstack/query/flat/recommended',
35 plugins: {
36 '@tanstack/query': {}, // Assigned after plugin object created
37 },
38 rules: {
39 '@tanstack/query/exhaustive-deps': 'error',
40 '@tanstack/query/no-rest-destructuring': 'warn',
41 '@tanstack/query/stable-query-client': 'error',
42 '@tanstack/query/no-unstable-deps': 'error',
43 '@tanstack/query/infinite-query-property-order': 'error',
44 '@tanstack/query/no-void-query-fn': 'error',
45 '@tanstack/query/mutation-property-order': 'error',
46 },
47 },
48 ],
49 },
50 rules,
51} satisfies Plugin
52β
53plugin.configs['flat/recommended'][0]!.plugins['@tanstack/query'] = plugin
54β
55export default plugin