diff --git a/src/configs/react.ts b/src/configs/react.ts index 55d5c3f829..9091ceaea7 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -7,6 +7,15 @@ import { GLOB_TS, GLOB_TSX } from '../globs' const ReactRefreshAllowConstantExportPackages = [ 'vite', ] +const RemixPackages = [ + '@remix-run/node', + '@remix-run/react', + '@remix-run/serve', + '@remix-run/dev', +] +const NextJsPackages = [ + 'next', +] export async function react( options: OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles = {}, @@ -39,9 +48,9 @@ export async function react( interopDefault(import('@typescript-eslint/parser')), ] as const) - const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some( - i => isPackageExists(i), - ) + const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(i => isPackageExists(i)) + const isUsingRemix = RemixPackages.some(i => isPackageExists(i)) + const isUsingNext = NextJsPackages.some(i => isPackageExists(i)) const plugins = pluginReact.configs.all.plugins @@ -91,7 +100,30 @@ 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', + ] + : []), + ], + }, ], // recommended rules from @eslint-react