Skip to content

Commit

Permalink
fix: improve option for react-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Apr 19, 2024
1 parent 2367977 commit 4413bdd
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/configs/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import { GLOB_TS, GLOB_TSX } from '../globs'
const ReactRefreshAllowConstantExportPackages = [
'vite',
]
const RemixPackages = [
'@remix-run/node',
'@remix-run/react',
'@remix-run/serve',
'@remix-run/dev',
]

export async function react(
options: OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles = {},
Expand Down Expand Up @@ -42,6 +48,8 @@ export async function react(
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
i => isPackageExists(i),
)
const isUsingRemix = RemixPackages.some(i => isPackageExists(i))
const isUsingNext = isPackageExists('next')

const plugins = pluginReact.configs.all.plugins

Expand Down Expand Up @@ -91,7 +99,27 @@ export async function react(
// react refresh
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: isAllowConstantExport },
{
allowConstantExport: isAllowConstantExport,
allowExportNames: isUsingNext
? [
'config',
'generateStaticParams',
'metadata',
'generateMetadata',
'viewport',
'generateViewport',
]
: isUsingRemix
? [
'meta',
'links',
'headers',
'loader',
'action',
]
: undefined,
},
],

// recommended rules from @eslint-react
Expand Down

0 comments on commit 4413bdd

Please sign in to comment.