Configurations
ESLint React provides the following configurations:
Settings
version
React version to perform the analysis, "detect" means auto detect React version from the project's dependencies.
If failed to detect, it will use the 19.0.0 version.
importSource
importSource is specified, an equivalent version of React should be provided to the version setting.The source where React is imported from.
This allows to specify a custom import location for React when not using the official distribution.
For example, if you are using @pika/react instead of react, you can set the importSource to @pika/react:
polymorphicPropName
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:
will be evaluated as an h3.
If no polymorphicPropName is set, then the component will be evaluated as Box.
additionalComponents
additionalComponents, consider whether polymorphicPropName can be used instead, as it simpler and more efficient.An array of components and its attributes mapping. It allows the related rules to do even more comprehensive analysis. You can also provide default values for attributes here, that will be used when that attribute is not present.
For example, if you set the additionalComponents to:
then this element:
will be evaluated as an:
So that both the dom/no-missing-iframe-sandbox and dom/no-unsafe-iframe-sandbox rules can perform checks on it.
additionalHooks
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.
For example, if you set the additionalHooks to:
then the React Hook call:
will be evaluated as an:
So that the hooks-extra/no-direct-set-state-in-use-layout-effect rule can perform checks on it.