Configure Analyzer
ESLint React reads analyzer properties from the react-x
key within ESLint's settings
object.
You can provide the following properties to customize the analyzer behavior:
Properties
Prop | Type | Default |
---|---|---|
additionalHooks? | Record<ReactBuiltInHookName, string[]> | {} |
additionalComponents? | CustomComponent[] | [] |
polymorphicPropName? | string | "as" |
importSource? | string | "react" |
version? | string | "detect" |
Property Specifications
version
Defines the React version for semantic analysis.
detect
: Auto-detects from project dependencies (defaults to19.1.0
if undetectable)string
: Explicit version specification (e.g.,"18.3.1"
)
importSource
Customizes the React module import source. Useful for non-standard distributions.
Example for using @pika/react
instead of react
:
polymorphicPropName
Defines the prop used for polymorphic components. Helps rules determine element types for semantic context.
Example with polymorphicPropName
set to as
:
additionalComponents
(Experimental)
Consider using polymorphicPropName
instead when possible, as it's simpler
and more efficient.
Experimental feature that may lack stability and documentation.
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.