@@ -25,6 +25,9 @@ const ReactRefreshAllowConstantExportPackages = ["vite"];
2525const RemixPackages = [ "@remix-run/node" , "@remix-run/react" , "@remix-run/serve" , "@remix-run/dev" ] ;
2626const NextJsPackages = [ "next" ] ;
2727const ReactRouterPackages = [ "@react-router/node" , "@react-router/react" , "@react-router/serve" , "@react-router/dev" ] ;
28+ // TanStack Router/Start route files export Route objects and server functions — not just components.
29+ // react-refresh HMR rule does not apply to these patterns.
30+ const TanstackRouterPackages = [ "@tanstack/react-router" , "@tanstack/router" , "@tanstack/start" , "@tanstack/react-start" ] ;
2831
2932type PluginReactCompiler = {
3033 configs : {
@@ -124,6 +127,7 @@ export default createConfig<
124127 const isUsingRemix = hasPackageJsonAnyDependency ( packageJson , RemixPackages ) ;
125128 const isUsingNext = hasPackageJsonAnyDependency ( packageJson , NextJsPackages ) ;
126129 const isUsingReactRouter = hasPackageJsonAnyDependency ( packageJson , ReactRouterPackages ) ;
130+ const isUsingTanstack = hasPackageJsonAnyDependency ( packageJson , TanstackRouterPackages ) ;
127131
128132 const { plugins } = pluginReactX . configs . all as {
129133 plugins : Record < string , unknown > ;
@@ -297,34 +301,38 @@ export default createConfig<
297301 "react-naming-convention/use-state" : "error" ,
298302
299303 // react refresh
300- "react-refresh/only-export-components" : [
301- "error" ,
302- {
303- allowConstantExport : isAllowConstantExport ,
304- allowExportNames : [
305- ...isUsingNext
306- ? [
307- "dynamic" ,
308- "dynamicParams" ,
309- "revalidate" ,
310- "fetchCache" ,
311- "runtime" ,
312- "preferredRegion" ,
313- "maxDuration" ,
314- "config" ,
315- "generateStaticParams" ,
316- "metadata" ,
317- "generateMetadata" ,
318- "viewport" ,
319- "generateViewport" ,
320- ]
321- : [ ] ,
322- ...isUsingRemix || isUsingReactRouter
323- ? [ "meta" , "links" , "headers" , "loader" , "action" , "clientLoader" , "clientAction" , "handle" , "shouldRevalidate" ]
324- : [ ] ,
325- ] ,
326- } ,
327- ] ,
304+ // Disabled for TanStack Router/Start: route files export Route objects,
305+ // loaders, server functions and other non-component values by design.
306+ "react-refresh/only-export-components" : isUsingTanstack
307+ ? "off"
308+ : [
309+ "error" ,
310+ {
311+ allowConstantExport : isAllowConstantExport ,
312+ allowExportNames : [
313+ ...isUsingNext
314+ ? [
315+ "dynamic" ,
316+ "dynamicParams" ,
317+ "revalidate" ,
318+ "fetchCache" ,
319+ "runtime" ,
320+ "preferredRegion" ,
321+ "maxDuration" ,
322+ "config" ,
323+ "generateStaticParams" ,
324+ "metadata" ,
325+ "generateMetadata" ,
326+ "viewport" ,
327+ "generateViewport" ,
328+ ]
329+ : [ ] ,
330+ ...isUsingRemix || isUsingReactRouter
331+ ? [ "meta" , "links" , "headers" , "loader" , "action" , "clientLoader" , "clientAction" , "handle" , "shouldRevalidate" ]
332+ : [ ] ,
333+ ] ,
334+ } ,
335+ ] ,
328336
329337 // Prevents leaked addEventListener in a component or custom hook
330338 // https://eslint-react.xyz/docs/rules/web-api-no-leaked-event-listener
@@ -1193,6 +1201,10 @@ export default createConfig<
11931201 // Prevent missing parentheses around multilines JSX
11941202 // https://github.com/jsx-eslint/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md
11951203 "react/no-typos" : "error" ,
1204+
1205+ // React uses null as a first-class value: return null (render nothing),
1206+ // useRef<T>(null) (DOM refs), and external APIs/JSON all require null.
1207+ "unicorn/no-null" : "off" ,
11961208 } ,
11971209 settings : {
11981210 extensions : [ ".jsx" ] ,
@@ -1207,6 +1219,10 @@ export default createConfig<
12071219 "react/jsx-filename-extension" : "off" ,
12081220 "react/prop-types" : "off" ,
12091221 "react/require-default-props" : "off" ,
1222+
1223+ // React uses null as a first-class value: return null (render nothing),
1224+ // useRef<T>(null) (DOM refs), and external APIs/JSON all require null.
1225+ "unicorn/no-null" : "off" ,
12101226 } ,
12111227 } ,
12121228 {
0 commit comments