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: Plugin = {
16 meta: {
17 name: '@tanstack/eslint-plugin-query',
18 },
19 configs: {} as Plugin['configs'],
20 rules,
21}
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 '@tanstack/query/no-void-query-fn': 'error',
34 '@tanstack/query/mutation-property-order': 'error',
35 },
36 },
37 'flat/recommended': [
38 {
39 name: 'tanstack/query/flat/recommended',
40 plugins: {
41 '@tanstack/query': plugin,
42 },
43 rules: {
44 '@tanstack/query/exhaustive-deps': 'error',
45 '@tanstack/query/no-rest-destructuring': 'warn',
46 '@tanstack/query/stable-query-client': 'error',
47 '@tanstack/query/no-unstable-deps': 'error',
48 '@tanstack/query/infinite-query-property-order': 'error',
49 '@tanstack/query/no-void-query-fn': 'error',
50 '@tanstack/query/mutation-property-order': 'error',
51 },
52 },
53 ],
54})
55β
56export default plugin