DocumentationConfiguration

Configuration

ESLint React provides the following configurations:

Settings

importSource

(type: string, default: "react")

The source where React is imported from.
This allows to specify a custom import location for React when not using the official distribution (e.g. @pika/react, etc).

jsxPragma

(type: string, default: "createElement")

The identifier that’s used for JSX Element creation.
This should not be a member expression (i.e. use "createElement" instead of "React.createElement").

jsxPragmaFrag

(type: string, default: "Fragment")

The identifier that’s used for JSX fragment elements.
This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").

version

(type: string, default: "detect")

React version to use, "detect" means auto detect React version from the project’s dependencies.
If importSource is specified, an equivalent version of React should be provided here.

polymorphicPropName

(type: string)

⚠️
Polymorphic components can make code harder to maintain; please use this feature with caution.

You can optionally use the polymorphicPropName setting to define the prop your code uses to create polymorphic components. This setting will be used determine the element type in rules that require semantic context.

For example, if you set the polymorphicPropName setting to as then this element:

<Box as="h3">Configurations </Box>

will be evaluated as an h3. If no polymorphicPropName is set, then the component will be evaluated as Box.

additionalHooks

(type: [key: string]: string[])

⚠️
This is intended to cover edge cases. We suggest to use this option very sparingly, if at all.

A object of aliases for React built-in hooks. ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.

(e.g. { useLayoutEffect: ["useIsomorphicLayoutEffect"] }).

additionalComponents

(type: { name: string; as: string; attributes: { name: string; as?: string; defaultValue?: string }[] }[])

⚠️
This is an experimental feature that can be unstable and lacks comprehensive documentation.

An array of user-defined components, used to inform the ESLint React plugins how to treat these components during checks.

Examples

eslint.config.js
import 
const react: {
    readonly meta: {
        readonly name: string;
        readonly version: string;
    };
    readonly configs: {
        readonly all: typeof allConfig;
        readonly core: typeof coreConfig;
        readonly debug: typeof debugConfig;
        readonly "disable-debug": typeof disableDebugConfig;
        readonly "disable-dom": typeof disableDomConfig;
        readonly "disable-type-checked": typeof disableTypeCheckedConfig;
        readonly "disable-web-api": typeof disableWebApiConfig;
        readonly dom: typeof domConfig;
        readonly off: typeof offConfig;
        readonly recommended: typeof recommendedConfig;
        readonly "recommended-type-checked": typeof recommendedTypeCheckedConfig;
        readonly "recommended-typescript": typeof recommendedTypeScriptConfig;
        readonly "all-legacy": typeof allConfig & {
            name: string;
            plugins: string[];
        };
        readonly "core-legacy": typeof coreConfig & {
            name: string;
            plugins: string[];
        };
        readonly "debug-legacy": typeof debugConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-debug-legacy": typeof disableDebugConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-dom-legacy": typeof disableDomConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-type-checked-legacy": typeof disableTypeCheckedConfig & {
            name: string;
            plugins: string[];
        };
        readonly ...
react
from "@eslint-react/eslint-plugin";
export default [ // ... { files: string[]files: ["**/*.{ts,tsx}"], ...
const react: {
    readonly meta: {
        readonly name: string;
        readonly version: string;
    };
    readonly configs: {
        readonly all: typeof allConfig;
        readonly core: typeof coreConfig;
        readonly debug: typeof debugConfig;
        readonly "disable-debug": typeof disableDebugConfig;
        readonly "disable-dom": typeof disableDomConfig;
        readonly "disable-type-checked": typeof disableTypeCheckedConfig;
        readonly "disable-web-api": typeof disableWebApiConfig;
        readonly dom: typeof domConfig;
        readonly off: typeof offConfig;
        readonly recommended: typeof recommendedConfig;
        readonly "recommended-type-checked": typeof recommendedTypeCheckedConfig;
        readonly "recommended-typescript": typeof recommendedTypeScriptConfig;
        readonly "all-legacy": typeof allConfig & {
            name: string;
            plugins: string[];
        };
        readonly "core-legacy": typeof coreConfig & {
            name: string;
            plugins: string[];
        };
        readonly "debug-legacy": typeof debugConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-debug-legacy": typeof disableDebugConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-dom-legacy": typeof disableDomConfig & {
            name: string;
            plugins: string[];
        };
        readonly "disable-type-checked-legacy": typeof disableTypeCheckedConfig & {
            name: string;
            plugins: string[];
        };
        readonly ...
react
.
configs: {
    readonly all: typeof allConfig;
    readonly core: typeof coreConfig;
    readonly debug: typeof debugConfig;
    ... 22 more ...;
    readonly "off-dom-legacy": typeof disableDomConfig & {
        name: string;
        plugins: string[];
    };
}
configs
.recommended: typeof recommendedConfigrecommended,
settings: {
    "react-x": {
        importSource: string;
        jsxPragma: string;
        jsxPragmaFrag: string;
        additionalHooks: {
            useLayoutEffect: string[];
        };
        additionalComponents: {
            name: string;
            as: string;
            attributes: ({
                name: string;
                as: string;
            } | {
                ...;
            })[];
        }[];
        version: string;
    };
}
settings
: {
"react-x": { importSource: stringimportSource: "react", jsxPragma: stringjsxPragma: "createElement", jsxPragmaFrag: stringjsxPragmaFrag: "Fragment",
additionalHooks: {
    useLayoutEffect: string[];
}
additionalHooks
: {
useLayoutEffect: string[]useLayoutEffect: ["useIsomorphicLayoutEffect"], },
additionalComponents: {
    name: string;
    as: string;
    attributes: ({
        name: string;
        as: string;
    } | {
        name: string;
        defaultValue: string;
    })[];
}[]
additionalComponents
: [
{ name: stringname: "Link", as: stringas: "a",
attributes: ({
    name: string;
    as: string;
} | {
    name: string;
    defaultValue: string;
})[]
attributes
: [
{ name: stringname: "to", as: stringas: "href" }, { name: stringname: "rel", defaultValue: stringdefaultValue: "noopener noreferrer" }, ], }, ], version: stringversion: "detect", }, }, }, ];