You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/website/content/docs/faq.mdx
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,33 @@ For a comprehensive migration guide with a complete rule comparison table, see o
77
77
78
78
To smoothly transition, we suggest reviewing the rules in ESLint React and running a comprehensive linting check on your codebase to identify and address any discrepancies introduced by the migration.
79
79
80
+
## How can I help ESLint React analyze my code more accurately?
81
+
82
+
ESLint React performs static analysis on your source code, so it can only reason about values and calls that are visible at compile time. Computed property access such as `obj["foo"]()` or `React["createElement"]()` hides the actual member name from the analyzer, which may cause rules to miss calls they would otherwise detect.
83
+
84
+
To keep code analyzer-friendly, we recommend enabling the following TypeScript ESLint rules alongside ESLint React:
85
+
86
+
-[`@typescript-eslint/dot-notation`](https://typescript-eslint.io/rules/dot-notation/) — prefers `obj.foo` over `obj["foo"]` when the property name is a valid identifier, making method calls easier for rules to resolve.
87
+
-[`@typescript-eslint/no-unnecessary-template-expression`](https://typescript-eslint.io/rules/no-unnecessary-template-expression/) — removes unnecessary template literals such as `` `foo` ``, keeping callee names plain strings where possible.
88
+
89
+
Using these rules together reduces reliance on computed member expressions and helps ESLint React rules match calls consistently.
90
+
91
+
Additionally, configuring ESLint React and your project settings correctly ensures the analyzer understands your specific environment:
92
+
93
+
-**Configure Analyzer Settings**: Customize static analysis behavior via the `react-x` key in your ESLint `settings` object:
94
+
-**React Version**: Set `version` (e.g., `"detect"` or `"19.2.7"`) to ensure semantic analysis matches your available React features.
95
+
-**React Compiler**: Align `compilationMode` with your React Compiler configuration so rules respect its optimization strategies.
96
+
-**Custom Hooks**: Use `additionalStateHooks` and `additionalEffectHooks` regex patterns to help the analyzer recognize and validate your custom hooks as standard state or effect hooks.
97
+
-**Polymorphic Components**: Define `polymorphicPropName` (e.g., `"as"`) so rules can correctly infer the rendered underlying element type.
98
+
-**Custom Import Sources**: Specify `importSource` if you use non-standard distributions (like `"@pika/react"`).
99
+
100
+
See [Configure Analyzer](/docs/configuration/configure-analyzer) for more details.
101
+
102
+
-**Leverage Type Information**:
103
+
- Set up `parserOptions.project` or `parserOptions.projectService` in your ESLint config to enable powerful type-aware rules (like `react-x/no-leaked-conditional-rendering` and `react-x/no-implicit-children`).
104
+
- Enable `strictNullChecks` in your `tsconfig.json` or `jsconfig.json` to significantly improve the accuracy of these type-aware rules.
105
+
- Ensure your JSX transform options (`jsx`, `jsxImportSource`, etc.) are properly defined in your TypeScript config so ESLint React can automatically detect them.
106
+
80
107
## What does 90% human-written mean?
81
108
82
109
Of every 100 rules, 10 are written or ported by LLMs and reviewed by humans, while 90 are written or ported by humans and reviewed by LLMs.
0 commit comments