Skip to content

Commit

Permalink
Merge branch 'main' into fix/insertAtPositions-no-shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo authored Oct 9, 2024
2 parents 4dea945 + cae2524 commit 3910b12
Show file tree
Hide file tree
Showing 39 changed files with 380 additions and 122 deletions.
6 changes: 3 additions & 3 deletions examples/react/algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"dependencies": {
"@algolia/client-search": "5.2.1",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.59.1",
"@tanstack/eslint-plugin-query": "^5.59.2",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/auto-refetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-graphql-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"graphql": "^16.9.0",
"graphql-request": "^7.1.0",
"react": "19.0.0-rc-4c2e457c7c-20240522",
Expand Down
8 changes: 4 additions & 4 deletions examples/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.59.0",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query-persist-client": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"@tanstack/react-query-persist-client": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.59.1",
"@tanstack/eslint-plugin-query": "^5.59.2",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/default-query-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/devtools-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/infinite-query-with-max-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/load-more-infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs-app-prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^15.0.0-rc.0",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
Expand Down
6 changes: 3 additions & 3 deletions examples/react/nextjs-suspense-streaming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query-next-experimental": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"@tanstack/react-query-next-experimental": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/react/offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.59.0",
"@tanstack/react-location": "^3.7.4",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query-persist-client": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"@tanstack/react-query-persist-client": "^5.59.3",
"msw": "^2.3.4",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@react-native-community/netinfo": "^11.3.2",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"expo": "^51.0.22",
"expo-constants": "^16.0.2",
"expo-status-bar": "^1.12.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"localforage": "^1.10.0",
"match-sorter": "^6.3.4",
"react": "19.0.0-rc-4c2e457c7c-20240522",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/rick-morty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.0.0",
"@mui/styles": "^6.0.0",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522",
"react-router": "^6.25.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/shadow-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/star-wars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.0.0",
"@mui/styles": "^6.0.0",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522",
"react-router": "^6.25.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/suspense/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/react-query": "^5.59.3",
"@tanstack/react-query-devtools": "^5.59.3",
"font-awesome": "^4.7.0",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522",
Expand Down
2 changes: 1 addition & 1 deletion examples/solid/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"solid-js": "^1.8.19"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.59.1",
"@tanstack/eslint-plugin-query": "^5.59.2",
"typescript": "5.3.3",
"vite": "^5.3.5",
"vite-plugin-solid": "^2.10.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-query/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/eslint-plugin-query",
"version": "5.59.1",
"version": "5.59.2",
"description": "ESLint plugin for TanStack Query",
"author": "Eliya Cohen",
"license": "MIT",
Expand Down
47 changes: 47 additions & 0 deletions packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,53 @@ ruleTester.run('exhaustive-deps', rule, {
}
`,
},
{
name: 'should not fail when queryFn uses nullish coalescing operator',
code: normalizeIndent`
useQuery({
queryKey: ["foo", options],
queryFn: () => options?.params ?? options
});
`,
},
{
name: 'should not fail when queryKey uses arrow function to produce a key',
code: normalizeIndent`
const obj = reactive<{ boo?: string }>({});
const query = useQuery({
queryKey: ['foo', () => obj.boo],
queryFn: () => fetch(\`/mock/getSomething/\${obj.boo}\`),
enable: () => !!obj.boo,
});
`,
},
{
name: 'should not fail when queryKey uses arrow function to produce a key as the body return',
code: normalizeIndent`
const obj = reactive<{ boo?: string }>({});
const query = useQuery({
queryKey: ['foo', () => { return obj.boo }],
queryFn: () => fetch(\`/mock/getSomething/\${obj.boo}\`),
enable: () => !!obj.boo,
});
`,
},
{
name: 'should not fail when queryKey uses function expression to produce a key as the body return',
code: normalizeIndent`
const obj = reactive<{ boo?: string }>({});
const query = useQuery({
queryKey: ['foo', function() {
return obj.boo
}],
queryFn: () => fetch(\`/mock/getSomething/\${obj.boo}\`),
enable: () => !!obj.boo,
});
`,
},
],
invalid: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const rule = createRule({
!ref.isTypeReference &&
!ASTUtils.isAncestorIsCallee(ref.identifier) &&
!existingKeys.some((existingKey) => existingKey === text) &&
!existingKeys.includes(text.split('.')[0] ?? '')
!existingKeys.includes(text.split(/[?.]/)[0] ?? '')
)
})
.map(({ ref, text }) => ({
Expand Down
18 changes: 18 additions & 0 deletions packages/eslint-plugin-query/src/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ export const ASTUtils = {
identifiers.push(...ASTUtils.getNestedIdentifiers(node.expression))
}

if (node.type === AST_NODE_TYPES.ArrowFunctionExpression) {
identifiers.push(...ASTUtils.getNestedIdentifiers(node.body))
}

if (node.type === AST_NODE_TYPES.FunctionExpression) {
identifiers.push(...ASTUtils.getNestedIdentifiers(node.body))
}

if (node.type === AST_NODE_TYPES.BlockStatement) {
identifiers.push(
...node.body.map((body) => ASTUtils.getNestedIdentifiers(body)).flat(),
)
}

if (node.type === AST_NODE_TYPES.ReturnStatement && node.argument) {
identifiers.push(...ASTUtils.getNestedIdentifiers(node.argument))
}

return identifiers
},
isAncestorIsCallee(identifier: TSESTree.Node) {
Expand Down
Loading

0 comments on commit 3910b12

Please sign in to comment.