@tanstack/eslint-plugin-query 5.0.0-alpha.88 → 5.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/__tests__/configs.test.cjs +21 -0
- package/build/legacy/__tests__/configs.test.cjs.map +1 -0
- package/build/legacy/__tests__/configs.test.d.cts +2 -0
- package/build/legacy/__tests__/configs.test.d.ts +2 -0
- package/build/legacy/__tests__/configs.test.js +19 -0
- package/build/legacy/__tests__/configs.test.js.map +1 -0
- package/build/legacy/__tests__/exhaustive-deps.test.cjs +722 -0
- package/build/legacy/__tests__/exhaustive-deps.test.cjs.map +1 -0
- package/build/legacy/__tests__/exhaustive-deps.test.d.cts +2 -0
- package/build/legacy/__tests__/exhaustive-deps.test.d.ts +2 -0
- package/build/legacy/__tests__/exhaustive-deps.test.js +720 -0
- package/build/legacy/__tests__/exhaustive-deps.test.js.map +1 -0
- package/build/legacy/configs.cjs +46 -0
- package/build/legacy/configs.cjs.map +1 -0
- package/build/legacy/configs.d.cts +8 -0
- package/build/legacy/configs.d.ts +8 -0
- package/build/legacy/configs.js +21 -0
- package/build/legacy/configs.js.map +1 -0
- package/build/legacy/index.cjs +28 -431
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +3 -14
- package/build/legacy/index.d.ts +3 -14
- package/build/legacy/index.js +3 -432
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/rules/exhaustive-deps.rule.cjs +141 -0
- package/build/legacy/rules/exhaustive-deps.rule.cjs.map +1 -0
- package/build/legacy/rules/exhaustive-deps.rule.d.cts +6 -0
- package/build/legacy/rules/exhaustive-deps.rule.d.ts +6 -0
- package/build/legacy/rules/exhaustive-deps.rule.js +115 -0
- package/build/legacy/rules/exhaustive-deps.rule.js.map +1 -0
- package/build/legacy/rules/exhaustive-deps.utils.cjs +52 -0
- package/build/legacy/rules/exhaustive-deps.utils.cjs.map +1 -0
- package/build/legacy/rules/exhaustive-deps.utils.d.cts +12 -0
- package/build/legacy/rules/exhaustive-deps.utils.d.ts +12 -0
- package/build/legacy/rules/exhaustive-deps.utils.js +27 -0
- package/build/legacy/rules/exhaustive-deps.utils.js.map +1 -0
- package/build/legacy/rules.cjs +44 -0
- package/build/legacy/rules.cjs.map +1 -0
- package/build/legacy/rules.d.cts +7 -0
- package/build/legacy/rules.d.ts +7 -0
- package/build/legacy/rules.js +9 -0
- package/build/legacy/rules.js.map +1 -0
- package/build/legacy/utils/ast-utils.cjs +247 -0
- package/build/legacy/utils/ast-utils.cjs.map +1 -0
- package/build/legacy/utils/ast-utils.d.cts +41 -0
- package/build/legacy/utils/ast-utils.d.ts +41 -0
- package/build/legacy/utils/ast-utils.js +222 -0
- package/build/legacy/utils/ast-utils.js.map +1 -0
- package/build/legacy/utils/create-rule.cjs +39 -0
- package/build/legacy/utils/create-rule.cjs.map +1 -0
- package/build/legacy/utils/create-rule.d.cts +10 -0
- package/build/legacy/utils/create-rule.d.ts +10 -0
- package/build/legacy/utils/create-rule.js +14 -0
- package/build/legacy/utils/create-rule.js.map +1 -0
- package/build/legacy/utils/detect-react-query-imports.cjs +70 -0
- package/build/legacy/utils/detect-react-query-imports.cjs.map +1 -0
- package/build/legacy/utils/detect-react-query-imports.d.cts +12 -0
- package/build/legacy/utils/detect-react-query-imports.d.ts +12 -0
- package/build/legacy/utils/detect-react-query-imports.js +45 -0
- package/build/legacy/utils/detect-react-query-imports.js.map +1 -0
- package/build/legacy/utils/object-utils.cjs +33 -0
- package/build/legacy/utils/object-utils.cjs.map +1 -0
- package/build/legacy/utils/object-utils.d.cts +3 -0
- package/build/legacy/utils/object-utils.d.ts +3 -0
- package/build/legacy/utils/object-utils.js +8 -0
- package/build/legacy/utils/object-utils.js.map +1 -0
- package/build/legacy/utils/test-utils.cjs +36 -0
- package/build/legacy/utils/test-utils.cjs.map +1 -0
- package/build/legacy/utils/test-utils.d.cts +3 -0
- package/build/legacy/utils/test-utils.d.ts +3 -0
- package/build/legacy/utils/test-utils.js +11 -0
- package/build/legacy/utils/test-utils.js.map +1 -0
- package/build/legacy/utils/unique-by.cjs +33 -0
- package/build/legacy/utils/unique-by.cjs.map +1 -0
- package/build/legacy/utils/unique-by.d.cts +3 -0
- package/build/legacy/utils/unique-by.d.ts +3 -0
- package/build/legacy/utils/unique-by.js +8 -0
- package/build/legacy/utils/unique-by.js.map +1 -0
- package/package.json +2 -2
- package/src/{configs/index.test.ts → __tests__/configs.test.ts} +1 -1
- package/src/{rules/exhaustive-deps → __tests__}/exhaustive-deps.test.ts +2 -2
- package/src/{configs/index.ts → configs.ts} +1 -1
- package/src/rules/{exhaustive-deps/exhaustive-deps.rule.ts → exhaustive-deps.rule.ts} +3 -3
- package/src/rules/{exhaustive-deps/exhaustive-deps.utils.ts → exhaustive-deps.utils.ts} +1 -1
- package/src/rules.ts +5 -0
- package/src/rules/index.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/exhaustive-deps.test.ts"],"sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\nimport { normalizeIndent } from '../utils/test-utils'\nimport { rule } from '../rules/exhaustive-deps.rule'\n\nconst ruleTester = new ESLintUtils.RuleTester({\n parser: '@typescript-eslint/parser',\n settings: {},\n})\n\nruleTester.run('exhaustive-deps', rule, {\n valid: [\n {\n name: 'should pass when deps are passed in array (react)',\n code: 'useQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array (solid)',\n code: 'createQuery({ queryKey: [\"todos\"], queryFn: fetchTodos });',\n },\n {\n name: 'should pass when deps are passed in array',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should pass when deps are passed in template literal',\n // eslint-disable-next-line no-template-curly-in-string\n code: 'useQuery({ queryKey: [`entity/${id}`], queryFn: () => api.getEntity(id) });',\n },\n {\n name: 'should not pass fetch',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => fetch(id) });',\n },\n {\n name: 'should not pass axios.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => axios.get(id) });',\n },\n {\n name: 'should not pass api.entity.get',\n code: 'useQuery({ queryKey: [\"entity\", id], queryFn: () => api.entity.get(id) });',\n },\n {\n name: 'should not pass api when is being used for calling a function',\n code: `\n import useApi from './useApi'\n\n const useFoo = () => {\n const api = useApi();\n return useQuery({\n queryKey: ['foo'],\n queryFn: () => api.fetchFoo(),\n })\n }\n `,\n },\n {\n name: 'should pass props.src',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props.src], queryFn: () => api.entity.get(props.src) });\n }\n `,\n },\n {\n name: 'identify !!props.id (unary expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", !!props.id], queryFn: () => api.entity.get(props.id) });\n }\n `,\n },\n {\n name: 'identify props?.id (chain expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props?.id], queryFn: () => api.entity.get(props?.id) });\n }\n `,\n },\n {\n name: 'identify props!.id (ts non null expression)',\n code: `\n function MyComponent(props) {\n useQuery({ queryKey: [\"entity\", props!.id], queryFn: () => api.entity.get(props!.id) });\n }\n `,\n },\n {\n name: 'should ignore keys from callback',\n code: `\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep1],\n queryFn: ({ queryKey: [, dep] }) => fetch(dep),\n });\n }\n `,\n },\n {\n name: 'should ignore type identifiers',\n code: `\n type Result = {};\n function MyComponent(props) {\n useQuery({\n queryKey: [\"foo\", dep],\n queryFn: () => api.get<Result>(dep),\n });\n }\n `,\n },\n {\n name: 'should add \"...args\" to deps',\n code: `\n function foo(...args) {}\n function useData(arg, ...args) {\n return useQuery({\n queryKey: ['foo', arg, ...args],\n queryFn: async () => foo([arg, ...args])\n });\n }\n `,\n },\n {\n name: 'should not add class to deps',\n code: `\n class Foo {}\n useQuery({ queryKey: ['foo'], queryFn: async () => new Foo() });\n `,\n },\n {\n name: 'should not add `undefined` to deps',\n code: `\n useQuery({\n queryKey: [],\n queryFn: async () => {\n if (undefined) {\n return null;\n }\n return 1\n },\n });\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep as first arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ x: num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in object 2',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo({ num }),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in array',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo([num]),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep in second arg',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(1, num),\n queryFn: () => Promise.resolve(num),\n })\n `,\n },\n {\n name: 'should not fail when queryKey is a queryKeyFactory while having a dep is object prop',\n code: normalizeIndent`\n const fooQueryKeyFactory = {\n foo: () => ['foo'] as const,\n num: (num: number) => [...fooQueryKeyFactory.foo(), num] as const,\n }\n \n const useFoo = (obj: { num: number }) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(obj.num),\n queryFn: () => Promise.resolve(obj.num),\n })\n `,\n },\n {\n name: 'should not treat new Error as missing dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: ['foo'],\n queryFn: () => Promise.reject(new Error('1')),\n })\n `,\n },\n {\n name: 'should see id when there is a const assertion',\n code: normalizeIndent`\n const useX = (id: number) => {\n return useQuery({\n queryKey: ['foo', id] as const,\n queryFn: async () => id,\n })\n }\n `,\n },\n {\n name: 'should not fail if queryKey is having the whole object while queryFn uses some props of it',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n },\n {\n name: 'should not fail if queryKey does not include an internal dependency',\n code: normalizeIndent`\n useQuery({\n queryKey: [\"api\"],\n queryFn: async () => {\n const response = Promise.resolve([]);\n const data = await response.json();\n return data[0].name;\n },\n });\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function declaration)',\n code: `\n const CONST_VAL = 1\n function MyComponent() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, function expression)',\n code: `\n const CONST_VAL = 1\n const MyComponent = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react component, anonymous function)',\n code: `\n const CONST_VAL = 1\n const MyComponent = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (non react component/hook function)',\n code: `\n const CONST_VAL = 1\n function fn() {\n return {\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n }\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function declaration)',\n code: `\n const CONST_VAL = 1\n function useHook() {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, function expression)',\n code: `\n const CONST_VAL = 1\n const useHook = () => {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore constants defined out of scope (react hook, anonymous function)',\n code: `\n const CONST_VAL = 1\n const useHook = function () {\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => CONST_VAL\n });\n }\n `,\n },\n {\n name: 'should ignore references of the queryClient',\n code: `\n const CONST_VAL = 1\n function useHook() {\n const queryClient = useQueryClient()\n const kueryKlient = useQueryClient()\n useQuery({\n queryKey: [\"foo\"],\n queryFn: () => {\n doSomething(queryClient)\n queryClient.invalidateQueries()\n doSomethingSus(kueryKlient)\n }\n });\n }\n `,\n },\n ],\n invalid: [\n {\n name: 'should fail when deps are missing in query factory',\n code: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity'], queryFn: () => fetchEntity(id) })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: \"['entity', id]\" },\n output: normalizeIndent`\n const todoQueries = {\n list: () => ({ queryKey: ['entity'], queryFn: fetchEntities }),\n detail: (id) => ({ queryKey: ['entity', id], queryFn: () => fetchEntity(id) })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (react)',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when no deps are passed (solid)',\n code: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const id = 1;\n createQuery({ queryKey: [\"entity\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when deps are passed incorrectly',\n code: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\"], queryFn: () => api.getEntity(id) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[\"entity/${id}\", id]' },\n output: normalizeIndent`\n const id = 1;\n useQuery({ queryKey: [\"entity/\\${id}\", id], queryFn: () => api.getEntity(id) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should pass missing dep while key has a template literal',\n code: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`], queryFn: () => api.getEntity(a, b) });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'b' },\n suggestions: [\n {\n messageId: 'fixTo',\n // eslint-disable-next-line no-template-curly-in-string\n data: { result: '[`entity/${a}`, b]' },\n output: normalizeIndent`\n const a = 1;\n const b = 2;\n useQuery({ queryKey: [\\`entity/\\${a}\\`, b], queryFn: () => api.getEntity(a, b) });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep exists inside setter and missing in queryKey',\n code: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\"],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'id' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", id]' },\n output: normalizeIndent`\n const [id] = React.useState(1);\n useQuery({\n queryKey: [\"entity\", id],\n queryFn: () => {\n const { data } = axios.get(\\`.../\\${id}\\`);\n return data;\n }\n });\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey',\n code: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'd, e' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: { result: '[\"entity\", a, [b], { c }, 1, true, d, e]' },\n output: normalizeIndent`\n const todoQueries = {\n key: (a, b, c, d, e) => ({\n queryKey: [\"entity\", a, [b], { c }, 1, true, d, e],\n queryFn: () => api.getEntity(a, b, c, d, e)\n })\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when dep does not exist while having a complex queryKey #2',\n code: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7]],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'dep8' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result:\n \"['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8]\",\n },\n output: normalizeIndent`\n const todoQueries = {\n key: (dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8) => ({\n queryKey: ['foo', {dep1, dep2: dep2, bar: dep3, baz: [dep4, dep5]}, [dep6, dep7], dep8],\n queryFn: () => api.getEntity(dep1, dep2, dep3, dep4, dep5, dep6, dep7, dep8),\n }),\n };\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when two deps that depend on each other are missing',\n code: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\"], queryFn: () => api.get(map[key]) });\n }\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'map[key]' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: '[\"key\", map[key]]',\n },\n output: normalizeIndent`\n function Component({ map, key }) {\n useQuery({ queryKey: [\"key\", map[key]], queryFn: () => api.get(map[key]) });\n }\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when a queryKey is a reference of an array expression with a missing dep',\n code: normalizeIndent`\n const x = 5;\n const queryKey = ['foo']\n useQuery({ queryKey, queryFn: () => x })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'x' },\n suggestions: [\n {\n messageId: 'fixTo',\n data: {\n result: \"['foo', x]\",\n },\n output: normalizeIndent`\n const x = 5;\n const queryKey = ['foo', x]\n useQuery({ queryKey, queryFn: () => x })\n `,\n },\n ],\n },\n ],\n },\n {\n name: 'should fail when queryKey is a queryKeyFactory while having missing dep',\n code: normalizeIndent`\n const fooQueryKeyFactory = { foo: () => ['foo'] as const }\n\n const useFoo = (num: number) =>\n useQuery({\n queryKey: fooQueryKeyFactory.foo(),\n queryFn: () => Promise.resolve(num),\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'num' },\n },\n ],\n },\n {\n name: 'should fail if queryFn is using multiple object props when only one of them is in the queryKey',\n code: normalizeIndent`\n const state = { foo: 'foo', bar: 'bar' }\n \n useQuery({\n queryKey: ['state', state.foo],\n queryFn: () => Promise.resolve({ foo: state.foo, bar: state.bar })\n })\n `,\n errors: [\n {\n messageId: 'missingDeps',\n data: { deps: 'state.bar' },\n },\n ],\n },\n ],\n})\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,YAAY;AAErB,IAAM,aAAa,IAAI,YAAY,WAAW;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU,CAAC;AACb,CAAC;AAED,WAAW,IAAI,mBAAmB,MAAM;AAAA,EACtC,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA;AAAA,MAEN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;A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ACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,MAKN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,IAAI;AAAA,UAClB,aAAa;AAAA,YACX;AAAA,cACE,WAAW;AAAA,cACX,MAAM;AAAA,gBACJ,QAAQ;AAAA,cACV;AAAA,cACA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,YAKV;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,MAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,QAAQ;AAAA,QACN;AAAA,UACE,WAAW;AAAA,UACX,MAAM,EAAE,MAAM,YAAY;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/configs.ts
|
|
21
|
+
var configs_exports = {};
|
|
22
|
+
__export(configs_exports, {
|
|
23
|
+
configs: () => configs
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(configs_exports);
|
|
26
|
+
var import_rules = require("./rules.cjs");
|
|
27
|
+
function generateRecommendedConfig(allRules) {
|
|
28
|
+
return Object.entries(allRules).reduce((memo, [name, rule]) => {
|
|
29
|
+
const { recommended } = rule.meta.docs || {};
|
|
30
|
+
return {
|
|
31
|
+
...memo,
|
|
32
|
+
...recommended ? { [`@tanstack/query/${name}`]: recommended } : {}
|
|
33
|
+
};
|
|
34
|
+
}, {});
|
|
35
|
+
}
|
|
36
|
+
var configs = {
|
|
37
|
+
recommended: {
|
|
38
|
+
plugins: ["@tanstack/eslint-plugin-query"],
|
|
39
|
+
rules: generateRecommendedConfig(import_rules.rules)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
configs
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=configs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/configs.ts"],"sourcesContent":["import { rules } from './rules'\nimport type { TSESLint } from '@typescript-eslint/utils'\n\nfunction generateRecommendedConfig(\n allRules: Record<string, TSESLint.RuleModule<any, any>>,\n) {\n return Object.entries(allRules).reduce((memo, [name, rule]) => {\n const { recommended } = rule.meta.docs || {}\n\n return {\n ...memo,\n ...(recommended ? { [`@tanstack/query/${name}`]: recommended } : {}),\n }\n }, {} as Record<string, 'strict' | 'error' | 'warn'>)\n}\n\nexport const configs = {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-query'],\n rules: generateRecommendedConfig(rules),\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAGtB,SAAS,0BACP,UACA;AACA,SAAO,OAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM;AAC7D,UAAM,EAAE,YAAY,IAAI,KAAK,KAAK,QAAQ,CAAC;AAE3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmB,IAAI,EAAE,GAAG,YAAY,IAAI,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,CAAgD;AACtD;AAEO,IAAM,UAAU;AAAA,EACrB,aAAa;AAAA,IACX,SAAS,CAAC,+BAA+B;AAAA,IACzC,OAAO,0BAA0B,kBAAK;AAAA,EACxC;AACF;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/configs.ts
|
|
2
|
+
import { rules } from "./rules.js";
|
|
3
|
+
function generateRecommendedConfig(allRules) {
|
|
4
|
+
return Object.entries(allRules).reduce((memo, [name, rule]) => {
|
|
5
|
+
const { recommended } = rule.meta.docs || {};
|
|
6
|
+
return {
|
|
7
|
+
...memo,
|
|
8
|
+
...recommended ? { [`@tanstack/query/${name}`]: recommended } : {}
|
|
9
|
+
};
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
var configs = {
|
|
13
|
+
recommended: {
|
|
14
|
+
plugins: ["@tanstack/eslint-plugin-query"],
|
|
15
|
+
rules: generateRecommendedConfig(rules)
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
configs
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/configs.ts"],"sourcesContent":["import { rules } from './rules'\nimport type { TSESLint } from '@typescript-eslint/utils'\n\nfunction generateRecommendedConfig(\n allRules: Record<string, TSESLint.RuleModule<any, any>>,\n) {\n return Object.entries(allRules).reduce((memo, [name, rule]) => {\n const { recommended } = rule.meta.docs || {}\n\n return {\n ...memo,\n ...(recommended ? { [`@tanstack/query/${name}`]: recommended } : {}),\n }\n }, {} as Record<string, 'strict' | 'error' | 'warn'>)\n}\n\nexport const configs = {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-query'],\n rules: generateRecommendedConfig(rules),\n },\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAGtB,SAAS,0BACP,UACA;AACA,SAAO,OAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM;AAC7D,UAAM,EAAE,YAAY,IAAI,KAAK,KAAK,QAAQ,CAAC;AAE3C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAI,cAAc,EAAE,CAAC,mBAAmB,IAAI,EAAE,GAAG,YAAY,IAAI,CAAC;AAAA,IACpE;AAAA,EACF,GAAG,CAAC,CAAgD;AACtD;AAEO,IAAM,UAAU;AAAA,EACrB,aAAa;AAAA,IACX,SAAS,CAAC,+BAA+B;AAAA,IACzC,OAAO,0BAA0B,KAAK;AAAA,EACxC;AACF;","names":[]}
|
package/build/legacy/index.cjs
CHANGED
|
@@ -1,437 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// src/utils/ast-utils.ts
|
|
13
|
-
var ASTUtils = {
|
|
14
|
-
isNodeOfOneOf(node, types) {
|
|
15
|
-
return types.includes(node.type);
|
|
16
|
-
},
|
|
17
|
-
isIdentifier(node) {
|
|
18
|
-
return node.type === _utils.AST_NODE_TYPES.Identifier;
|
|
19
|
-
},
|
|
20
|
-
isIdentifierWithName(node, name2) {
|
|
21
|
-
return ASTUtils.isIdentifier(node) && node.name === name2;
|
|
22
|
-
},
|
|
23
|
-
isIdentifierWithOneOfNames(node, name2) {
|
|
24
|
-
return ASTUtils.isIdentifier(node) && name2.includes(node.name);
|
|
25
|
-
},
|
|
26
|
-
isProperty(node) {
|
|
27
|
-
return node.type === _utils.AST_NODE_TYPES.Property;
|
|
28
|
-
},
|
|
29
|
-
isObjectExpression(node) {
|
|
30
|
-
return node.type === _utils.AST_NODE_TYPES.ObjectExpression;
|
|
31
|
-
},
|
|
32
|
-
isPropertyWithIdentifierKey(node, key) {
|
|
33
|
-
return ASTUtils.isProperty(node) && ASTUtils.isIdentifierWithName(node.key, key);
|
|
34
|
-
},
|
|
35
|
-
findPropertyWithIdentifierKey(properties, key) {
|
|
36
|
-
return properties.find(
|
|
37
|
-
(x) => ASTUtils.isPropertyWithIdentifierKey(x, key)
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
getNestedIdentifiers(node) {
|
|
41
|
-
const identifiers = [];
|
|
42
|
-
if (ASTUtils.isIdentifier(node)) {
|
|
43
|
-
identifiers.push(node);
|
|
44
|
-
}
|
|
45
|
-
if ("arguments" in node) {
|
|
46
|
-
node.arguments.forEach((x) => {
|
|
47
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(x));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if ("elements" in node) {
|
|
51
|
-
node.elements.forEach((x) => {
|
|
52
|
-
if (x !== null) {
|
|
53
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(x));
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if ("properties" in node) {
|
|
58
|
-
node.properties.forEach((x) => {
|
|
59
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(x));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if ("expressions" in node) {
|
|
63
|
-
node.expressions.forEach((x) => {
|
|
64
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(x));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (node.type === _utils.AST_NODE_TYPES.Property) {
|
|
68
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.value));
|
|
69
|
-
}
|
|
70
|
-
if (node.type === _utils.AST_NODE_TYPES.SpreadElement) {
|
|
71
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
|
|
72
|
-
}
|
|
73
|
-
if (node.type === _utils.AST_NODE_TYPES.MemberExpression) {
|
|
74
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.object));
|
|
75
|
-
}
|
|
76
|
-
if (node.type === _utils.AST_NODE_TYPES.UnaryExpression) {
|
|
77
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument));
|
|
78
|
-
}
|
|
79
|
-
if (node.type === _utils.AST_NODE_TYPES.ChainExpression) {
|
|
80
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
|
|
81
|
-
}
|
|
82
|
-
if (node.type === _utils.AST_NODE_TYPES.TSNonNullExpression) {
|
|
83
|
-
identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression));
|
|
84
|
-
}
|
|
85
|
-
return identifiers;
|
|
86
|
-
},
|
|
87
|
-
isAncestorIsCallee(identifier) {
|
|
88
|
-
let previousNode = identifier;
|
|
89
|
-
let currentNode = identifier.parent;
|
|
90
|
-
while (currentNode !== void 0) {
|
|
91
|
-
if (currentNode.type === _utils.AST_NODE_TYPES.CallExpression && currentNode.callee === previousNode) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
if (currentNode.type !== _utils.AST_NODE_TYPES.MemberExpression) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
previousNode = currentNode;
|
|
98
|
-
currentNode = currentNode.parent;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
},
|
|
102
|
-
traverseUpOnly(identifier, allowedNodeTypes) {
|
|
103
|
-
const parent = identifier.parent;
|
|
104
|
-
if (parent !== void 0 && allowedNodeTypes.includes(parent.type)) {
|
|
105
|
-
return ASTUtils.traverseUpOnly(parent, allowedNodeTypes);
|
|
106
|
-
}
|
|
107
|
-
return identifier;
|
|
108
|
-
},
|
|
109
|
-
isDeclaredInNode(params) {
|
|
110
|
-
const { functionNode, reference, scopeManager } = params;
|
|
111
|
-
const scope = scopeManager.acquire(functionNode);
|
|
112
|
-
if (scope === null) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
return scope.set.has(reference.identifier.name);
|
|
116
|
-
},
|
|
117
|
-
getExternalRefs(params) {
|
|
118
|
-
const { scopeManager, sourceCode, node } = params;
|
|
119
|
-
const scope = scopeManager.acquire(node);
|
|
120
|
-
if (scope === null) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
const references = scope.references.filter((x) => x.isRead() && !scope.set.has(x.identifier.name)).map((x) => {
|
|
124
|
-
const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [
|
|
125
|
-
_utils.AST_NODE_TYPES.MemberExpression,
|
|
126
|
-
_utils.AST_NODE_TYPES.Identifier
|
|
127
|
-
]);
|
|
128
|
-
return {
|
|
129
|
-
variable: x,
|
|
130
|
-
node: referenceNode,
|
|
131
|
-
text: sourceCode.getText(referenceNode)
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
const localRefIds = new Set(
|
|
135
|
-
[...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0]))
|
|
136
|
-
);
|
|
137
|
-
const externalRefs = references.filter(
|
|
138
|
-
(x) => x.variable.resolved === null || !localRefIds.has(x.text)
|
|
139
|
-
);
|
|
140
|
-
return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable);
|
|
141
|
-
},
|
|
142
|
-
mapKeyNodeToText(node, sourceCode) {
|
|
143
|
-
return sourceCode.getText(
|
|
144
|
-
ASTUtils.traverseUpOnly(node, [
|
|
145
|
-
_utils.AST_NODE_TYPES.MemberExpression,
|
|
146
|
-
_utils.AST_NODE_TYPES.Identifier
|
|
147
|
-
])
|
|
148
|
-
);
|
|
149
|
-
},
|
|
150
|
-
isValidReactComponentOrHookName(identifier) {
|
|
151
|
-
return identifier !== null && /^(use|[A-Z])/.test(identifier.name);
|
|
152
|
-
},
|
|
153
|
-
getFunctionAncestor(context) {
|
|
154
|
-
return context.getAncestors().find((x) => {
|
|
155
|
-
var _a;
|
|
156
|
-
if (x.type === _utils.AST_NODE_TYPES.FunctionDeclaration) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
return ((_a = x.parent) == null ? void 0 : _a.type) === _utils.AST_NODE_TYPES.VariableDeclarator && x.parent.id.type === _utils.AST_NODE_TYPES.Identifier && ASTUtils.isNodeOfOneOf(x, [
|
|
160
|
-
_utils.AST_NODE_TYPES.FunctionDeclaration,
|
|
161
|
-
_utils.AST_NODE_TYPES.FunctionExpression,
|
|
162
|
-
_utils.AST_NODE_TYPES.ArrowFunctionExpression
|
|
163
|
-
]);
|
|
164
|
-
});
|
|
165
|
-
},
|
|
166
|
-
getReferencedExpressionByIdentifier(params) {
|
|
167
|
-
var _a, _b, _c;
|
|
168
|
-
const { node, context } = params;
|
|
169
|
-
const resolvedNode = (_c = (_b = (_a = context.getScope().references.find((ref) => ref.identifier === node)) == null ? void 0 : _a.resolved) == null ? void 0 : _b.defs[0]) == null ? void 0 : _c.node;
|
|
170
|
-
if ((resolvedNode == null ? void 0 : resolvedNode.type) !== _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
return resolvedNode.init;
|
|
174
|
-
},
|
|
175
|
-
getNestedReturnStatements(node) {
|
|
176
|
-
const returnStatements = [];
|
|
177
|
-
if (node.type === _utils.AST_NODE_TYPES.ReturnStatement) {
|
|
178
|
-
returnStatements.push(node);
|
|
179
|
-
}
|
|
180
|
-
if ("body" in node && node.body !== void 0 && node.body !== null) {
|
|
181
|
-
Array.isArray(node.body) ? node.body.forEach((x) => {
|
|
182
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
|
|
183
|
-
}) : returnStatements.push(
|
|
184
|
-
...ASTUtils.getNestedReturnStatements(node.body)
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
if ("consequent" in node) {
|
|
188
|
-
Array.isArray(node.consequent) ? node.consequent.forEach((x) => {
|
|
189
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
|
|
190
|
-
}) : returnStatements.push(
|
|
191
|
-
...ASTUtils.getNestedReturnStatements(node.consequent)
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
if ("alternate" in node && node.alternate !== null) {
|
|
195
|
-
Array.isArray(node.alternate) ? node.alternate.forEach((x) => {
|
|
196
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
|
|
197
|
-
}) : returnStatements.push(
|
|
198
|
-
...ASTUtils.getNestedReturnStatements(node.alternate)
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
if ("cases" in node) {
|
|
202
|
-
node.cases.forEach((x) => {
|
|
203
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(x));
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if ("block" in node) {
|
|
207
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(node.block));
|
|
208
|
-
}
|
|
209
|
-
if ("handler" in node && node.handler !== null) {
|
|
210
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(node.handler));
|
|
211
|
-
}
|
|
212
|
-
if ("finalizer" in node && node.finalizer !== null) {
|
|
213
|
-
returnStatements.push(
|
|
214
|
-
...ASTUtils.getNestedReturnStatements(node.finalizer)
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
if ("expression" in node && node.expression !== true && node.expression !== false) {
|
|
218
|
-
returnStatements.push(
|
|
219
|
-
...ASTUtils.getNestedReturnStatements(node.expression)
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
if ("test" in node && node.test !== null) {
|
|
223
|
-
returnStatements.push(...ASTUtils.getNestedReturnStatements(node.test));
|
|
224
|
-
}
|
|
225
|
-
return returnStatements;
|
|
226
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
227
9
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
function detectTanstackQueryImports(create) {
|
|
234
|
-
return (context, optionsWithDefault) => {
|
|
235
|
-
const tanstackQueryImportSpecifiers = [];
|
|
236
|
-
const helpers = {
|
|
237
|
-
isTanstackQueryImport(node) {
|
|
238
|
-
return !!tanstackQueryImportSpecifiers.find((specifier) => {
|
|
239
|
-
if (specifier.type === "ImportSpecifier") {
|
|
240
|
-
return node.name === specifier.local.name;
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
const detectionInstructions = {
|
|
247
|
-
ImportDeclaration(node) {
|
|
248
|
-
if (node.specifiers.length > 0 && node.importKind === "value" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-query")) {
|
|
249
|
-
tanstackQueryImportSpecifiers.push(...node.specifiers);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
const ruleInstructions = create(context, optionsWithDefault, helpers);
|
|
254
|
-
const enhancedRuleInstructions = {};
|
|
255
|
-
const allKeys = new Set(
|
|
256
|
-
Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
|
|
257
|
-
);
|
|
258
|
-
allKeys.forEach((instruction) => {
|
|
259
|
-
enhancedRuleInstructions[instruction] = (node) => {
|
|
260
|
-
var _a, _b;
|
|
261
|
-
if (instruction in detectionInstructions) {
|
|
262
|
-
(_a = detectionInstructions[instruction]) == null ? void 0 : _a.call(detectionInstructions, node);
|
|
263
|
-
}
|
|
264
|
-
if (ruleInstructions[instruction]) {
|
|
265
|
-
return (_b = ruleInstructions[instruction]) == null ? void 0 : _b.call(ruleInstructions, node);
|
|
266
|
-
}
|
|
267
|
-
return void 0;
|
|
268
|
-
};
|
|
269
|
-
});
|
|
270
|
-
return enhancedRuleInstructions;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// src/utils/create-rule.ts
|
|
275
|
-
var getDocsUrl = (ruleName) => `https://tanstack.com/query/v4/docs/eslint/${ruleName}`;
|
|
276
|
-
function createRule({ create, ...rest }) {
|
|
277
|
-
return _utils.ESLintUtils.RuleCreator(getDocsUrl)({
|
|
278
|
-
...rest,
|
|
279
|
-
create: detectTanstackQueryImports(create)
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// src/rules/exhaustive-deps/exhaustive-deps.utils.ts
|
|
284
|
-
|
|
285
|
-
var ExhaustiveDepsUtils = {
|
|
286
|
-
isRelevantReference(params) {
|
|
287
|
-
var _a;
|
|
288
|
-
const { reference, scopeManager, context } = params;
|
|
289
|
-
const component = ASTUtils.getFunctionAncestor(context);
|
|
290
|
-
if (component !== void 0 && !ASTUtils.isDeclaredInNode({
|
|
291
|
-
scopeManager,
|
|
292
|
-
reference,
|
|
293
|
-
functionNode: component
|
|
294
|
-
})) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
return reference.identifier.name !== "undefined" && ((_a = reference.identifier.parent) == null ? void 0 : _a.type) !== _utils.AST_NODE_TYPES.NewExpression && !ExhaustiveDepsUtils.isQueryClientReference(reference);
|
|
298
|
-
},
|
|
299
|
-
isQueryClientReference(reference) {
|
|
300
|
-
var _a, _b, _c;
|
|
301
|
-
const declarator = (_b = (_a = reference.resolved) == null ? void 0 : _a.defs[0]) == null ? void 0 : _b.node;
|
|
302
|
-
return (declarator == null ? void 0 : declarator.type) === _utils.AST_NODE_TYPES.VariableDeclarator && ((_c = declarator.init) == null ? void 0 : _c.type) === _utils.AST_NODE_TYPES.CallExpression && declarator.init.callee.type === _utils.AST_NODE_TYPES.Identifier && declarator.init.callee.name === "useQueryClient";
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
303
15
|
}
|
|
16
|
+
return to;
|
|
304
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
305
19
|
|
|
306
|
-
// src/
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
missingDeps: `The following dependencies are missing in your queryKey: {{deps}}`,
|
|
320
|
-
fixTo: "Fix to {{result}}"
|
|
321
|
-
},
|
|
322
|
-
hasSuggestions: true,
|
|
323
|
-
fixable: "code",
|
|
324
|
-
schema: []
|
|
325
|
-
},
|
|
326
|
-
defaultOptions: [],
|
|
327
|
-
create(context) {
|
|
328
|
-
return {
|
|
329
|
-
Property(node) {
|
|
330
|
-
if (node.parent === void 0 || !ASTUtils.isObjectExpression(node.parent) || !ASTUtils.isIdentifierWithName(node.key, QUERY_KEY)) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const scopeManager = context.getSourceCode().scopeManager;
|
|
334
|
-
const queryKey = ASTUtils.findPropertyWithIdentifierKey(
|
|
335
|
-
node.parent.properties,
|
|
336
|
-
QUERY_KEY
|
|
337
|
-
);
|
|
338
|
-
const queryFn = ASTUtils.findPropertyWithIdentifierKey(
|
|
339
|
-
node.parent.properties,
|
|
340
|
-
QUERY_FN
|
|
341
|
-
);
|
|
342
|
-
if (scopeManager === null || queryKey === void 0 || queryFn === void 0 || queryFn.value.type !== _utils.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
let queryKeyNode = queryKey.value;
|
|
346
|
-
if (queryKeyNode.type === _utils.AST_NODE_TYPES.TSAsExpression && queryKeyNode.expression.type === _utils.AST_NODE_TYPES.ArrayExpression) {
|
|
347
|
-
queryKeyNode = queryKeyNode.expression;
|
|
348
|
-
}
|
|
349
|
-
if (queryKeyNode.type === _utils.AST_NODE_TYPES.Identifier) {
|
|
350
|
-
const expression = ASTUtils.getReferencedExpressionByIdentifier({
|
|
351
|
-
context,
|
|
352
|
-
node: queryKeyNode
|
|
353
|
-
});
|
|
354
|
-
if ((expression == null ? void 0 : expression.type) === _utils.AST_NODE_TYPES.ArrayExpression) {
|
|
355
|
-
queryKeyNode = expression;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
const sourceCode = context.getSourceCode();
|
|
359
|
-
const queryKeyValue = queryKeyNode;
|
|
360
|
-
const externalRefs = ASTUtils.getExternalRefs({
|
|
361
|
-
scopeManager,
|
|
362
|
-
sourceCode,
|
|
363
|
-
node: queryFn.value
|
|
364
|
-
});
|
|
365
|
-
const relevantRefs = externalRefs.filter(
|
|
366
|
-
(reference) => ExhaustiveDepsUtils.isRelevantReference({
|
|
367
|
-
context,
|
|
368
|
-
reference,
|
|
369
|
-
scopeManager
|
|
370
|
-
})
|
|
371
|
-
);
|
|
372
|
-
const existingKeys = ASTUtils.getNestedIdentifiers(queryKeyValue).map(
|
|
373
|
-
(identifier) => ASTUtils.mapKeyNodeToText(identifier, sourceCode)
|
|
374
|
-
);
|
|
375
|
-
const missingRefs = relevantRefs.map((ref) => ({
|
|
376
|
-
ref,
|
|
377
|
-
text: ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode)
|
|
378
|
-
})).filter(({ ref, text }) => {
|
|
379
|
-
return !ref.isTypeReference && !ASTUtils.isAncestorIsCallee(ref.identifier) && !existingKeys.some((existingKey) => existingKey === text) && !existingKeys.includes(_nullishCoalesce(text.split(".")[0], () => ( "")));
|
|
380
|
-
}).map(({ ref, text }) => ({
|
|
381
|
-
identifier: ref.identifier,
|
|
382
|
-
text
|
|
383
|
-
}));
|
|
384
|
-
const uniqueMissingRefs = uniqueBy(missingRefs, (x) => x.text);
|
|
385
|
-
if (uniqueMissingRefs.length > 0) {
|
|
386
|
-
const missingAsText = uniqueMissingRefs.map((ref) => ASTUtils.mapKeyNodeToText(ref.identifier, sourceCode)).join(", ");
|
|
387
|
-
const existingWithMissing = sourceCode.getText(queryKeyValue).replace(/\]$/, `, ${missingAsText}]`);
|
|
388
|
-
const suggestions = [];
|
|
389
|
-
if (queryKeyNode.type === _utils.AST_NODE_TYPES.ArrayExpression) {
|
|
390
|
-
suggestions.push({
|
|
391
|
-
messageId: "fixTo",
|
|
392
|
-
data: { result: existingWithMissing },
|
|
393
|
-
fix(fixer) {
|
|
394
|
-
return fixer.replaceText(queryKeyValue, existingWithMissing);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
context.report({
|
|
399
|
-
node,
|
|
400
|
-
messageId: "missingDeps",
|
|
401
|
-
data: {
|
|
402
|
-
deps: uniqueMissingRefs.map((ref) => ref.text).join(", ")
|
|
403
|
-
},
|
|
404
|
-
suggest: suggestions
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
}
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
configs: () => import_configs.configs,
|
|
24
|
+
rules: () => import_rules.rules
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
var import_configs = require("./configs.cjs");
|
|
28
|
+
var import_rules = require("./rules.cjs");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
configs,
|
|
32
|
+
rules
|
|
410
33
|
});
|
|
411
|
-
|
|
412
|
-
// src/rules/index.ts
|
|
413
|
-
var rules = {
|
|
414
|
-
[name]: rule
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
// src/configs/index.ts
|
|
418
|
-
function generateRecommendedConfig(allRules) {
|
|
419
|
-
return Object.entries(allRules).reduce((memo, [name2, rule2]) => {
|
|
420
|
-
const { recommended } = rule2.meta.docs || {};
|
|
421
|
-
return {
|
|
422
|
-
...memo,
|
|
423
|
-
...recommended ? { [`@tanstack/query/${name2}`]: recommended } : {}
|
|
424
|
-
};
|
|
425
|
-
}, {});
|
|
426
|
-
}
|
|
427
|
-
var configs = {
|
|
428
|
-
recommended: {
|
|
429
|
-
plugins: ["@tanstack/eslint-plugin-query"],
|
|
430
|
-
rules: generateRecommendedConfig(rules)
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
exports.configs = configs; exports.rules = rules;
|
|
437
34
|
//# sourceMappingURL=index.cjs.map
|