Configurations
ESLint React reads configurations from the react-x
key within ESLint's settings
object. Configure these properties in your ESLint configuration file:
Configuration Properties
Prop | Type | Default |
---|---|---|
version? | string | detect |
importSource? | string | react |
skipImportCheck? | boolean | true |
polymorphicPropName? | string | as |
additionalComponents? | CustomComponent[] | [] |
additionalHooks? | Record<ReactBuiltInHookName, string[]> | {} |
Property Specifications
version
Defines the React version for semantic analysis.
"detect"
: Auto-detects from project dependencies (defaults to19.0.0
if undetectable)string
: Explicit version specification (e.g.,"18.2.0"
)
importSource
Customizes the React module import source. Useful for non-standard distributions.
Example for using @pika/react
instead of react
:
skipImportCheck
Controls whether to verify the import source when identifying React APIs.
Default is true
(checks only API shape). When false
, both shape and import source are verified, preventing false positives from third-party libraries with similar APIs.
polymorphicPropName
Defines the prop used for polymorphic components. Helps rules determine element types for semantic context.
Example with polymorphicPropName
set to as
:
additionalComponents
(Experimental)
polymorphicPropName
instead when possible, as it's simpler and more efficient.Maps components and their attributes for comprehensive analysis. Supports default attribute values.
Example configuration:
This makes <EmbedContent src="https://eslint-react.xyz" />
evaluate as <iframe src="https://eslint-react.xyz" sandbox="" />
.
additionalHooks
(Experimental)
Intended for edge cases. We suggest to use this option very sparingly, if at all. Generally saying, we recommend most custom Hooks do not vary the built-in React Hooks, and instead provide a higher-level API that is more focused around a specific use case.
Alias variants to built-in React Hooks for rule compatibility:
Treats useIsomorphicLayoutEffect
as both useEffect
and useLayoutEffect
in rule checks.