From 4b854b6ec64b17bae22c00e79e7f43e3bf6a99e9 Mon Sep 17 00:00:00 2001 From: JangHwanPark Date: Sun, 22 Mar 2026 22:59:06 +0900 Subject: [PATCH 1/2] test(eslint-plugin-query/stable-query-client): add tests for uncovered branches Add 3 test cases to improve branch coverage of 'stable-query-client' rule from 78.57% to 92.85%. - add valid case for arrow function component where fnAncestor has no id - add valid case for async server component with @tanstack/react-query import - add invalid case for destructuring pattern where autofix is not applicable The existing valid tests for line 58 (non-component function, async component) used @tanstack/solid-query imports, causing early return at the import check (line 44) and never reaching the target branch. --- .../src/__tests__/stable-query-client.test.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts b/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts index 0ceda63523d..008063a4123 100644 --- a/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts +++ b/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts @@ -106,6 +106,28 @@ ruleTester.run('stable-query-client', rule, { } `, }, + { + name: 'QueryClient is not flagged in an arrow function component', + code: normalizeIndent` + import { QueryClient } from "@tanstack/react-query"; + + const Component = () => { + const queryClient = new QueryClient(); + return; + }; + `, + }, + { + name: 'QueryClient is not flagged in an async react-query server component', + code: normalizeIndent` + import { QueryClient } from "@tanstack/react-query"; + + async function ServerComponent() { + const queryClient = new QueryClient(); + return; + } + `, + }, ], invalid: [ { @@ -188,5 +210,18 @@ ruleTester.run('stable-query-client', rule, { `, errors: [{ messageId: 'unstable' }], }, + { + name: 'QueryClient with destructuring pattern reports error without autofix', + code: normalizeIndent` + import { QueryClient } from "@tanstack/react-query"; + + function Component() { + const { defaultOptions } = new QueryClient(); + return; + } + `, + output: null, + errors: [{ messageId: 'unstable' }], + }, ], }) From 71153052996772a09a0ed277606235c2e7110ebd Mon Sep 17 00:00:00 2001 From: JangHwanPark Date: Sun, 22 Mar 2026 23:29:40 +0900 Subject: [PATCH 2/2] test(eslint-plugin-query/stable-query-client): remove arrow function component valid case Remove the arrow function component test case from valid cases. The current rule does not detect `new QueryClient()` inside arrow function components because `fnAncestor.id` is undefined for arrow functions. This is a false negative (known limitation), not intended behavior. Adding it as a valid case would bake that bug into the test suite and cause failures when the rule is fixed in the future. --- .../src/__tests__/stable-query-client.test.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts b/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts index 008063a4123..0f0bfbc6838 100644 --- a/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts +++ b/packages/eslint-plugin-query/src/__tests__/stable-query-client.test.ts @@ -106,17 +106,6 @@ ruleTester.run('stable-query-client', rule, { } `, }, - { - name: 'QueryClient is not flagged in an arrow function component', - code: normalizeIndent` - import { QueryClient } from "@tanstack/react-query"; - - const Component = () => { - const queryClient = new QueryClient(); - return; - }; - `, - }, { name: 'QueryClient is not flagged in an async react-query server component', code: normalizeIndent`