Skip to content

Commit c84a7ac

Browse files
committed
Convert react/jsx-no-leaked-render to warning due to many false positives
1 parent 155bb01 commit c84a7ac

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/react.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Config for **React** projects.
2424

2525
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).
2626
27-
### 🚨 Errors (44)
27+
### 🚨 Errors (43)
2828

2929
| Plugin | Rule | Options | Autofix | Overrides |
3030
| :------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :-----: | :-------: |
@@ -38,7 +38,6 @@ Config for **React** projects.
3838
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md)<br />Disallow comments from being inserted as text nodes | | | |
3939
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md)<br />Disallows JSX context provider values from taking values that will cause needless rerenders | | | |
4040
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md)<br />Disallow duplicate properties in JSX | | | |
41-
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md)<br />Disallow problematic leaked values from being rendered | | 🔧 | |
4241
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md)<br />Disallow usage of `javascript:` URLs | | | |
4342
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md)<br />Disallow `target="_blank"` attribute without `rel="noreferrer"` | | 🔧 | |
4443
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md)<br />Disallow undeclared variables in JSX | | | |
@@ -73,7 +72,7 @@ Config for **React** projects.
7372
| [![react-hooks](./icons/material/react_ts.png)](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [exhaustive-deps](https://github.com/facebook/react/issues/14920)<br />verifies the list of dependencies for Hooks like useEffect and similar | | 🔧, 💡 | |
7473
| [![react-hooks](./icons/material/react_ts.png)](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [rules-of-hooks](https://reactjs.org/docs/hooks-rules.html)<br />enforces the Rules of Hooks | | | |
7574

76-
### ⚠️ Warnings (25)
75+
### ⚠️ Warnings (26)
7776

7877
| Plugin | Rule | Options | Autofix | Overrides |
7978
| :----------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: |
@@ -87,6 +86,7 @@ Config for **React** projects.
8786
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md)<br />Enforce shorthand or standard form for React fragments | | 🔧 | |
8887
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md)<br />Enforce event handler naming conventions in JSX | | | |
8988
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md)<br />Enforce JSX maximum depth | <details><summary>max: 10</summary><pre lang="json"><code>{&#13; "max": 10&#13;}</code></pre></details> | | |
89+
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md)<br />Disallow problematic leaked values from being rendered | | 🔧 | |
9090
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md)<br />Disallow unnecessary fragments | | 🔧 | |
9191
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md)<br />Enforce PascalCase for user-defined JSX components | | | |
9292
| [![react](./icons/material/react.png)](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-props-no-spread-multi](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spread-multi.md)<br />Disallow JSX prop spreading the same identifier multiple times | | | |

src/configs/react.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export default tseslint.config({
5656
'react/jsx-max-depth': ['warn', { max: 10 }],
5757
'react/jsx-no-bind': 'error',
5858
'react/jsx-no-constructed-context-values': 'error',
59-
'react/jsx-no-leaked-render': 'error',
59+
// jsx-no-leaked-render produces false positives because it doesn't check for safe types: https://github.com/jsx-eslint/eslint-plugin-react/issues/3292
60+
// eslint-plugin-jsx-expressions is more accurate, but blocked by v9 support: https://github.com/hluisson/eslint-plugin-jsx-expressions/pull/19
61+
'react/jsx-no-leaked-render': 'warn',
6062
'react/jsx-no-script-url': 'error',
6163
'react/jsx-no-useless-fragment': 'warn',
6264
'react/jsx-pascal-case': 'warn',

0 commit comments

Comments
 (0)