diff --git a/examples/react/algolia/package.json b/examples/react/algolia/package.json index 892e6d3540..a847ecd798 100644 --- a/examples/react/algolia/package.json +++ b/examples/react/algolia/package.json @@ -18,7 +18,7 @@ "react-dom": "19.0.0-rc-4c2e457c7c-20240522" }, "devDependencies": { - "@tanstack/eslint-plugin-query": "^5.51.9", + "@tanstack/eslint-plugin-query": "^5.51.10", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", "@vitejs/plugin-react": "^4.3.1", diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json index 479bd84d12..30f8c640de 100644 --- a/examples/react/basic/package.json +++ b/examples/react/basic/package.json @@ -17,7 +17,7 @@ "react-dom": "19.0.0-rc-4c2e457c7c-20240522" }, "devDependencies": { - "@tanstack/eslint-plugin-query": "^5.51.9", + "@tanstack/eslint-plugin-query": "^5.51.10", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", "@vitejs/plugin-react": "^4.3.1", diff --git a/examples/solid/simple/package.json b/examples/solid/simple/package.json index 363315b321..80ae38ce24 100644 --- a/examples/solid/simple/package.json +++ b/examples/solid/simple/package.json @@ -14,7 +14,7 @@ "solid-js": "^1.8.17" }, "devDependencies": { - "@tanstack/eslint-plugin-query": "^5.51.9", + "@tanstack/eslint-plugin-query": "^5.51.10", "typescript": "5.3.3", "vite": "^5.3.3", "vite-plugin-solid": "^2.10.2" diff --git a/packages/eslint-plugin-query/package.json b/packages/eslint-plugin-query/package.json index 0ac018879b..c920e783e0 100644 --- a/packages/eslint-plugin-query/package.json +++ b/packages/eslint-plugin-query/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/eslint-plugin-query", - "version": "5.51.9", + "version": "5.51.10", "description": "ESLint plugin for TanStack Query", "author": "Eliya Cohen", "license": "MIT", diff --git a/packages/eslint-plugin-query/src/utils/ast-utils.ts b/packages/eslint-plugin-query/src/utils/ast-utils.ts index fcdbe97539..71dce0730f 100644 --- a/packages/eslint-plugin-query/src/utils/ast-utils.ts +++ b/packages/eslint-plugin-query/src/utils/ast-utils.ts @@ -248,10 +248,16 @@ export const ASTUtils = { }) { const { node, context } = params - const resolvedNode = context - .getScope() - .references.find((ref) => ref.identifier === node)?.resolved?.defs[0] - ?.node + // we need the fallbacks for backwards compat with eslint < 8.37.0 + // eslint-disable-next-line ts/no-unnecessary-condition + const sourceCode = context.sourceCode ?? context.getSourceCode() + // eslint-disable-next-line ts/no-unnecessary-condition + const scope = context.sourceCode.getScope(node) + ? sourceCode.getScope(node) + : context.getScope() + + const resolvedNode = scope.references.find((ref) => ref.identifier === node) + ?.resolved?.defs[0]?.node if (resolvedNode?.type !== AST_NODE_TYPES.VariableDeclarator) { return null diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf9f4c1060..8993152e0a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -351,7 +351,7 @@ importers: version: 19.0.0-rc-4c2e457c7c-20240522(react@19.0.0-rc-4c2e457c7c-20240522) devDependencies: '@tanstack/eslint-plugin-query': - specifier: ^5.51.9 + specifier: ^5.51.10 version: link:../../../packages/eslint-plugin-query '@types/react': specifier: npm:types-react@rc @@ -419,7 +419,7 @@ importers: version: 19.0.0-rc-4c2e457c7c-20240522(react@19.0.0-rc-4c2e457c7c-20240522) devDependencies: '@tanstack/eslint-plugin-query': - specifier: ^5.51.9 + specifier: ^5.51.10 version: link:../../../packages/eslint-plugin-query '@types/react': specifier: npm:types-react@rc @@ -1235,7 +1235,7 @@ importers: version: 1.8.17 devDependencies: '@tanstack/eslint-plugin-query': - specifier: ^5.51.9 + specifier: ^5.51.10 version: link:../../../packages/eslint-plugin-query typescript: specifier: 5.3.3