pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/anolilab/javascript-style-guide/commit/2d719a15e760dd2033c71784d84df23808471fdd

crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-a469e846088cc1bf.css" /> fix(eslint-config): disable react-refresh/only-export-components for … · anolilab/javascript-style-guide@2d719a1 · GitHub
Skip to content

Commit 2d719a1

Browse files
prisisclaude
andcommitted
fix(eslint-config): disable react-refresh/only-export-components for TanStack and unicorn/no-null for JSX/TSX
- Detect TanStack Router/Start packages and disable `react-refresh/only-export-components` entirely, since route files export Route objects, loaders, and server functions by design - Add per-route-file override in tanstack-router config as additional safety net - Disable `unicorn/no-null` for .jsx and .tsx files — React uses null as a first-class value for rendering, DOM refs, and external APIs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent aed345c commit 2d719a1

File tree

2 files changed

+49
-28
lines changed

2 files changed

+49
-28
lines changed

packages/eslint-config/src/config/plugins/react.ts

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const ReactRefreshAllowConstantExportPackages = ["vite"];
2525
const RemixPackages = ["@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev"];
2626
const NextJsPackages = ["next"];
2727
const 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

2932
type 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
{

packages/eslint-config/src/config/plugins/tanstack-router.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export default createConfig<OptionsFiles & OptionsOverrides>("all", async (confi
2323
rules: {
2424
// Tanstack Router uses a custom sort order for objects
2525
"perfectionist/sort-objects": "off",
26+
27+
// TanStack Router route files export a `Route` object (createFileRoute result),
28+
// loaders, and other non-component values — not just React components.
29+
// Disabling avoids false positives from react-refresh HMR rule.
30+
"react-refresh/only-export-components": "off",
2631
},
2732
},
2833
];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy