Enable ValidateNoSetStateInRender in ESLint plugin
Same as previous: this rule is working accurately with no false positives, let's enable it.
Joe Savona committed
Nov 16, 2023 at 07:52 UTC
94348be2d96b769a961bafc368fc52b64a6ab62c
3 files changed
+4
-3
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md
+2
-2
@@ -2,7 +2,7 @@
2
## Input
3
4
```javascript
5
-//
5
+// @validateNoSetStateInRender
6
function Component(props) {
7
const logEvent = useLogging(props.appId);
8
const [currentStep, setCurrentStep] = useState(0);
@@ -33,7 +33,7 @@ function Component(props) {
33
## Code
34
35
```javascript
36
-import { unstable_useMemoCache as useMemoCache } from "react"; //
36
+import { unstable_useMemoCache as useMemoCache } from "react"; // @validateNoSetStateInRender
37
function Component(props) {
38
const $ = useMemoCache(3);
39
const logEvent = useLogging(props.appId);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js
+1
-1
@@ -1,4 +1,4 @@
1
-//
1
+// @validateNoSetStateInRender
2
function Component(props) {
3
const logEvent = useLogging(props.appId);
4
const [currentStep, setCurrentStep] = useState(0);
compiler/packages/eslint-plugin-react-forget/src/rules/ReactForgetDiagnostics.ts
+1
@@ -63,6 +63,7 @@ const COMPILER_OPTIONS: Partial<PluginOptions> = {
63
panicThreshold: "CRITICAL_ERRORS",
64
environment: {
65
validateHooksUsage: false,
66
+ validateNoSetStateInRender: true,
67
},
68
};
69