chore(eslint): resolve eslint errors in hydrateStart #5521
main fromrefs/pull/5521/head·merged by nlynzaad(GitHub profile, opens in a new tab) Showing 1 changed file with 4 additions and 2 deletions.
⚠️ Potential issue | 🟠 Major
Incorrect ESLint rule disabled—errors are not actually resolved.
The eslint-disable-next-line comments reference import/no-duplicates, but the actual ESLint errors are about import/order. This means the linting errors remain unfixed.
According to the static analysis, these imports should occur after the type imports (lines 8-9). The proper fix is to reorder the imports rather than suppress them.
Apply this diff to properly resolve the ESLint errors by reordering imports:
import { hydrate } from '@tanstack/router-core/ssr/client'
-
-// eslint-disable-next-line import/no-duplicates
-import { startInstance } from '#tanstack-start-entry'
-// eslint-disable-next-line import/no-duplicates
-import { getRouter } from '#tanstack-router-entry'
import { ServerFunctionSerializationAdapter } from './ServerFunctionSerializationAdapter'
import type { AnyStartInstanceOptions } from '../createStart'
import type { AnyRouter, AnySerializationAdapter } from '@tanstack/router-core'
+import { startInstance } from '#tanstack-start-entry'
+import { getRouter } from '#tanstack-router-entry'
Alternatively, if there's a specific reason these imports must remain at the top, use the correct rule:
-// eslint-disable-next-line import/no-duplicates
+// eslint-disable-next-line import/order
import { startInstance } from '#tanstack-start-entry'
-// eslint-disable-next-line import/no-duplicates
+// eslint-disable-next-line import/order
import { getRouter } from '#tanstack-router-entry'
📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// eslint-disable-next-line import/order
import { startInstance } from '#tanstack-start-entry'
// eslint-disable-next-line import/order
import { getRouter } from '#tanstack-router-entry'
🧰 Tools
🪛 ESLint
[error] 4-4: #tanstack-start-entry import should occur after type import of @tanstack/router-core
(import/order)
[error] 6-6: #tanstack-router-entry import should occur after type import of @tanstack/router-core
(import/order)
🤖 Prompt for AI Agents
In packages/start-client-core/src/client/hydrateStart.ts around lines 3 to 6,
the current eslint-disable-next-line comments target import/no-duplicates but
the real lint errors are import/order; fix by moving the two runtime imports
(startInstance and getRouter) so they come after the type-only imports on lines
8-9 (i.e., reorder imports to place type imports first), or if those runtime
imports truly must remain before the type imports, replace the incorrect
eslint-disable-next-line rule with eslint-disable-next-line import/order to
suppress the correct rule.
this suggestion causes the import order to break. this places the imports below the type imports that breaks the order.
there are 2 errors in the original code, one is the order which is resolved and the second is due to duplicate imports which is addressed with the comments
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the full git diff for this file to see what was originally there
git diff main...HEAD -- packages/start-client-core/src/client/hydrateStart.ts
Length of output: 33
🏁 Script executed:
#!/bin/bash
# Check ESLint configuration files for import/order and import/no-duplicates rules
fd -e json -e js -e cjs -e mjs "eslint" --exec cat {}
Length of output: 10852
🏁 Script executed:
#!/bin/bash
# Search for any other imports of these modules in the file to check for duplicates
rg -n "from '#tanstack-start-entry'|from '#tanstack-router-entry'" packages/start-client-core/src/client/hydrateStart.ts
Length of output: 108
🏁 Script executed:
#!/bin/bash
# Get the PR diff to see what the original code looked like
gh pr view 5521 --json files --jq '.files[] | select(.path == "packages/start-client-core/src/client/hydrateStart.ts") | .patch'
Length of output: 0
🏁 Script executed:
#!/bin/bash
# Get the base version of the file to see if there were duplicate imports
gh pr diff 5521 -- packages/start-client-core/src/client/hydrateStart.ts
Length of output: 36
🏁 Script executed:
#!/bin/bash
# Check the root ESLint config to understand import/order and import/no-duplicates rules
cat eslint.config.js
Length of output: 711
🏁 Script executed:
#!/bin/bash
# Fetch the PR diff directly
gh pr diff 5521
Length of output: 1005
🏁 Script executed:
#!/bin/bash
# Get the file content from the base branch
gh api repos/TanStack/router/contents/packages/start-client-core/src/client/hydrateStart.ts?ref=main | jq -r '.content' | base64 -d
Length of output: 44
🏁 Script executed:
#!/bin/bash
# Search the entire codebase for where startInstance and getRouter might be imported
rg -n "import.*startInstance.*from|import.*getRouter.*from" packages/start-client-core/
Length of output: 216
🏁 Script executed:
#!/bin/bash
# Check TypeScript config for path mappings to understand the # imports
fd "tsconfig" --type f -e json --exec cat {}
Length of output: 58195
🏁 Script executed:
#!/bin/bash
# Look for any package.json imports field that might define these # paths
fd "package.json" --type f --max-depth 2 --exec sh -c 'echo "=== $1 ===" && cat "$1" | jq -r ".imports // empty"' _ {}
Length of output: 22
🏁 Script executed:
#!/bin/bash
# Check if there are any other files that import from both of these modules
rg -l "#tanstack-start-entry" packages/start-client-core/ | xargs -I {} sh -c 'echo "=== {} ===" && rg -n "#tanstack-router-entry|#tanstack-start-entry" {}'
Length of output: 554
@nlynzaad, thank you for the clarification. However, I need to respectfully point out that the evidence doesn't support the presence of duplicate import errors. Let me explain what I'm seeing:
From the PR diff:
- Original code: The imports were positioned after the type imports (at the bottom of the import block)
- Current code: The imports were moved before the type imports (near the top)
This move actually goes in the opposite direction of what ESLint's import/order rule requires.
Regarding duplicate imports: My search of the file shows only one import statement for each module:
- Line 4:
import { startInstance } from '#tanstack-start-entry' - Line 6:
import { getRouter } from '#tanstack-router-entry'
There are no duplicate import statements in this file. The import/no-duplicates rule would only trigger if you had multiple import statements from the same module, which isn't the case here.
The actual error:
The static analysis tools are reporting import/order violations, not import/no-duplicates. This means ESLint expects these runtime imports to come after the type-only imports, not before them.
To properly resolve this:
- Option 1 (Recommended): Move the imports back to their original position (after type imports):
import { hydrate } from '@tanstack/router-core/ssr/client'
import { ServerFunctionSerializationAdapter } from './ServerFunctionSerializationAdapter'
import type { AnyStartInstanceOptions } from '../createStart'
import type { AnyRouter, AnySerializationAdapter } from '@tanstack/router-core'
import { startInstance } from '#tanstack-start-entry'
import { getRouter } from '#tanstack-router-entry'
- Option 2: If these imports must stay at the top for a specific reason, use the correct disable rule:
// eslint-disable-next-line import/order
import { startInstance } from '#tanstack-start-entry'
// eslint-disable-next-line import/order
import { getRouter } from '#tanstack-router-entry'
Could you clarify what specific duplicate import errors you were seeing? I'd like to understand the issue better.
🧬 Code Graph Analysis Results
: packages/start-client-core/src/client/hydrateStart.ts[relevant_code_snippets]
File: packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts Lines: 5-16 Content: export const ServerFunctionSerializationAdapter = createSerializationAdapter({ key: '$TSS/serverfn', test: (v): v is { functionId: string } => { if (typeof v !== 'function') return false
if (!(TSS_SERVER_FUNCTION in v)) return false
return !!v[TSS_SERVER_FUNCTION] }, toSerializable: ({ functionId }) => ({ functionId }), fromSerializable: ({ functionId }) => createClientRpc(functionId), })
File: packages/router-core/src/index.ts Lines: 416-416 Content: AnySerializationAdapter
File: packages/router-core/src/router.ts Lines: 766-766 Content: export type AnyRouter = RouterCore<any, any, any, any, any>
File: packages/solid-start/src/default-entry/start.ts Lines: 1-1 Content: export const startInstance = undefined
File: packages/react-start/src/default-entry/start.ts Lines: 1-1 Content: export const startInstance = undefined