Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tanstack/router/llms.txt
Use this file to discover all available pages before exploring further.
ESLint Plugin
The TanStack Router ESLint plugin provides linting rules to catch common mistakes and enforce best practices when using TanStack Router.Installation
Setup
Flat Config (ESLint 9+)
For ESLint 9+ using the flat config format:Legacy Config (ESLint 8)
For ESLint 8 using.eslintrc.js:
Rules
The plugin includes the following rules:create-route-property-order
Severity: warn (in recommended config)
Ensures correct order of inference-sensitive properties for createRoute functions.
TanStack Router uses TypeScript’s type inference, and the order of properties in route configurations affects type inference. This rule enforces the correct order.
Incorrect:
createRoute()createRootRoute()createFileRoute()()createRootRouteWithContext()()createLazyRoute()()createLazyFileRoute()()
route-param-names
Severity: error (in recommended config)
Ensures route param names are valid JavaScript identifiers.
Route parameters are extracted and used as object properties in your code. They must be valid JavaScript identifiers to avoid runtime errors.
Incorrect:
- Must start with a letter, underscore (
_), or dollar sign ($) - Can contain letters, numbers, underscores, and dollar signs
- Cannot contain hyphens, dots, or other special characters
- Cannot start with a number
- Regex pattern:
/[a-zA-Z_$][a-zA-Z0-9_$]*/
createRoute({ path: '...' })createFileRoute('...')(...)createRootRoute({ path: '...' })createLazyRoute({ path: '...' })createLazyFileRoute('...')(...)
Configuration
You can customize rule severity in your ESLint config:Flat Config
Legacy Config
Framework Support
The plugin automatically detects TanStack Router imports from:@tanstack/react-router@tanstack/solid-router@tanstack/vue-router- Any custom package with
routerin the name
Examples
Full Flat Config Example
Full Legacy Config Example
With React and TypeScript
IDE Integration
VS Code
Install the ESLint extension. The plugin’s auto-fix forcreate-route-property-order will work with VS Code’s “Fix on Save” feature:
IntelliJ IDEA / WebStorm
ESLint integration is built-in. Enable it in: Settings → Languages & Frameworks → JavaScript → Code Quality Tools → ESLintTroubleshooting
Rules Not Running
If rules aren’t running, check:- ESLint is installed and configured correctly
- The plugin is added to your ESLint config
- Your files are included in ESLint’s file patterns
- You’re importing from a TanStack Router package
False Positives
If you get warnings/errors when not using TanStack Router:- The plugin should auto-detect imports
- Make sure you’re not using function names like
createRoutewithout importing from TanStack Router - If needed, disable specific rules for certain files using overrides
Auto-fix Not Working
Forcreate-route-property-order, auto-fix should work automatically. If it doesn’t:
- Check your ESLint version is compatible
- Make sure your IDE’s ESLint integration is enabled
- Try running
eslint --fixfrom the command line
TypeScript Errors
The ESLint plugin is independent of TypeScript. If you have TypeScript errors after auto-fixing:- The auto-fix may have revealed existing type issues
- Run
tsc --noEmitto check for type errors - The correct property order often improves type inference
Versioning
The plugin follows TanStack Router’s versioning. Use matching major versions:@tanstack/router-plugin@1.x→@tanstack/eslint-plugin-router@1.x@tanstack/react-router@1.x→@tanstack/eslint-plugin-router@1.x
Contributing
To suggest new rules or report issues:- Visit the TanStack Router GitHub repository
- Search existing issues
- Create a new issue with:
- Description of the problem
- Example code that should be caught
- Suggested error message