Skip to content

Commit 4867f4c

Browse files
committed
feat: add react-x/no-nested-lazy-component-declarations rule to plugins and presets
1 parent e6bda0a commit 4867f4c

File tree

10 files changed

+13
-7
lines changed

10 files changed

+13
-7
lines changed

apps/website/content/docs/rules/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"no-missing-key",
3535
"no-misused-capture-owner-stack",
3636
"no-nested-component-definitions",
37+
"no-nested-lazy-component-declarations",
3738
"no-prop-types",
3839
"no-redundant-should-component-update",
3940
"no-set-state-in-component-did-mount",

apps/website/content/docs/rules/overview.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Linter rules can have false positives, false negatives, and some rules are depen
5757
| [`no-missing-key`](./no-missing-key) | 2️⃣ | | Disallow missing `key` on items in list rendering | |
5858
| [`no-misused-capture-owner-stack`](./no-misused-capture-owner-stack) | 0️⃣ | `🧪` | Prevents incorrect usage of `captureOwnerStack` | |
5959
| [`no-nested-component-definitions`](./no-nested-component-definitions) | 2️⃣ | | Disallow nesting component definitions inside other components | |
60+
| [`no-nested-lazy-component-declarations`](./no-nested-lazy-component-declarations) | 2️⃣ | | Disallow nesting lazy component declarations inside other components | |
6061
| [`no-prop-types`](./no-prop-types) | 2️⃣ | | Disallow `propTypes` in favor of TypeScript or another type-checking solution | |
6162
| [`no-redundant-should-component-update`](./no-redundant-should-component-update) | 2️⃣ | | Disallow `shouldComponentUpdate` when extending `React.PureComponent` | |
6263
| [`no-set-state-in-component-did-mount`](./no-set-state-in-component-did-mount) | 1️⃣ | | Disallow calling `this.setState` in `componentDidMount` outside of functions, such as callbacks | |

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-unnecessary-use-callback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ react-hooks-extra/no-unnecessary-use-callback
2020

2121
## Description
2222

23-
Disallows unnecessary usage of `useCallback`.
23+
Disallow unnecessary usage of `useCallback`.
2424

2525
React Hooks `useCallback` has empty dependencies array like what's in the examples, are unnecessary. The hook can be removed and it's value can be created in the component body or hoisted to the outer scope of the component.
2626

packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const rules = {
2929
"react-x/no-missing-key": "error",
3030
"react-x/no-misused-capture-owner-stack": "error",
3131
"react-x/no-nested-component-definitions": "error",
32+
"react-x/no-nested-lazy-component-declarations": "warn",
3233
"react-x/no-prop-types": "error",
3334
"react-x/no-redundant-should-component-update": "error",
3435
"react-x/no-set-state-in-component-did-mount": "warn",

packages/plugins/eslint-plugin-react-x/src/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import noMissingContextDisplayName from "./rules/no-missing-context-display-name
3333
import noMissingKey from "./rules/no-missing-key";
3434
import noMisusedCaptureOwnerStack from "./rules/no-misused-capture-owner-stack";
3535
import noNestedComponentDefinitions from "./rules/no-nested-component-definitions";
36+
import noNestedLazyComponentDeclarations from "./rules/no-nested-lazy-component-declarations";
3637
import noPropTypes from "./rules/no-prop-types";
3738
import noRedundantShouldComponentUpdate from "./rules/no-redundant-should-component-update";
3839
import noSetStateInComponentDidMount from "./rules/no-set-state-in-component-did-mount";
@@ -91,6 +92,7 @@ export const plugin = {
9192
"no-missing-key": noMissingKey,
9293
"no-misused-capture-owner-stack": noMisusedCaptureOwnerStack,
9394
"no-nested-component-definitions": noNestedComponentDefinitions,
95+
"no-nested-lazy-component-declarations": noNestedLazyComponentDeclarations,
9496
"no-prop-types": noPropTypes,
9597
"no-redundant-should-component-update": noRedundantShouldComponentUpdate,
9698
"no-set-state-in-component-did-mount": noSetStateInComponentDidMount,

packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ react-x/no-access-state-in-setstate
2323

2424
## Description
2525

26-
Disallows accessing `this.state` inside `setState` calls.
26+
Disallow accessing `this.state` inside `setState` calls.
2727

2828
Usage of `this.state` inside `setState` calls might result in errors when two state calls are called in batch and thus referencing old state and not the current state.
2929

packages/plugins/eslint-plugin-react-x/src/rules/no-nested-lazy-component-declarations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: no-nested-lazy-component-declarations
33
---
44

5-
**Full Name in `eslint-plugin-react-x`**
5+
**Full Name in `eslint-plugin-react-x@beta`**
66

77
```plain copy
88
react-x/no-nested-lazy-component-declarations
99
```
1010

11-
**Full Name in `@eslint-react/eslint-plugin`**
11+
**Full Name in `@eslint-react/eslint-plugin@beta`**
1212

1313
```plain copy
1414
@eslint-react/no-nested-lazy-component-declarations
@@ -23,7 +23,7 @@ react-x/no-nested-lazy-component-declarations
2323

2424
## Description
2525

26-
Disallows nesting lazy component declarations inside other components.
26+
Disallow nesting lazy component declarations inside other components.
2727

2828
When a lazy component is declared inside another component, it will be re-created on every render of the parent component. This can lead to unexpected behavior, such as resetting the state of the lazy component.
2929

packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ react-x/no-set-state-in-component-did-update
2323

2424
## Description
2525

26-
Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.
26+
Disallow calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks.
2727

2828
Updating the state after a component mount will trigger a second `render()` call and can lead to property/layout thrashing.
2929

packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ react-x/no-set-state-in-component-will-update
2323

2424
## Description
2525

26-
Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.
26+
Disallow calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks.
2727

2828
Updating the state after a component mount will trigger a second `render()` call and can lead to property/layout thrashing.
2929

packages/plugins/eslint-plugin/src/configs/x.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const rules = {
3030
"@eslint-react/no-missing-key": "error",
3131
"@eslint-react/no-misused-capture-owner-stack": "error",
3232
"@eslint-react/no-nested-component-definitions": "error",
33+
"@eslint-react/no-nested-lazy-component-declarations": "warn",
3334
"@eslint-react/no-prop-types": "error",
3435
"@eslint-react/no-redundant-should-component-update": "error",
3536
"@eslint-react/no-set-state-in-component-did-mount": "warn",

0 commit comments

Comments
 (0)