From 896d1b00273958ddad6cb8b1fafae3cd13cced5a Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Mon, 22 Apr 2024 08:14:35 -0700 Subject: [PATCH] [dx] Improve error message from InferReferenceEffects ghstack-source-id: 06265d9676b671a5b02ca05433a219dd219be4f1 Pull Request resolved: https://github.com/facebook/react-forget/pull/2883 --- .../src/Inference/InferReferenceEffects.ts | 24 ++++++++++--------- .../error.invalid-array-push-frozen.expect.md | 2 +- ...d-computed-store-to-frozen-value.expect.md | 2 +- ...omputed-property-of-frozen-value.expect.md | 2 +- ...-delete-property-of-frozen-value.expect.md | 2 +- ...pression-mutates-immutable-value.expect.md | 2 +- ...alid-mutate-after-aliased-freeze.expect.md | 2 +- ...rror.invalid-mutate-after-freeze.expect.md | 2 +- ...valid-mutate-context-in-callback.expect.md | 2 +- .../error.invalid-mutate-context.expect.md | 2 +- ...-mutate-props-in-effect-fixpoint.expect.md | 2 +- ...rror.invalid-mutation-in-closure.expect.md | 2 +- ...n-of-possible-props-phi-indirect.expect.md | 2 +- ...r.invalid-prop-mutation-indirect.expect.md | 2 +- ...d-property-store-to-frozen-value.expect.md | 2 +- ...rops-mutation-in-effect-indirect.expect.md | 2 +- .../compiler/error.modify-state-2.expect.md | 2 +- .../compiler/error.modify-state.expect.md | 2 +- .../error.mutate-function-property.expect.md | 2 +- .../error.mutate-hook-argument.expect.md | 2 +- ...rror.mutate-property-from-global.expect.md | 2 +- .../compiler/error.mutate-props.expect.md | 2 +- ...or.not-useEffect-external-mutate.expect.md | 2 +- .../error.store-property-in-global.expect.md | 2 +- .../ReactCompilerRuleTypescript-test.ts | 2 +- 25 files changed, 37 insertions(+), 35 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts index 33db413e41..cc818a20c3 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts @@ -541,8 +541,9 @@ class InferenceState { error: { reason, description: - place.identifier.name !== null - ? `Found mutation of ${place.identifier.name}` + place.identifier.name !== null && + place.identifier.name.kind === "named" + ? `Found mutation of \`${place.identifier.name.value}\`` : null, loc: place.loc, suggestions: null, @@ -575,8 +576,9 @@ class InferenceState { error: { reason, description: - place.identifier.name !== null - ? `Found mutation of ${place.identifier.name}` + place.identifier.name !== null && + place.identifier.name.kind === "named" + ? `Found mutation of \`${place.identifier.name.value}\`` : null, loc: place.loc, suggestions: null, @@ -1986,18 +1988,18 @@ function areArgumentsImmutableAndNonMutating( function getWriteErrorReason(abstractValue: AbstractValue): string { if (abstractValue.reason.has(ValueReason.Global)) { - return "Writing to a variable defined outside a component or hook is not allowed. Consider using an effect."; + return "Writing to a variable defined outside a component or hook is not allowed. Consider using an effect"; } else if (abstractValue.reason.has(ValueReason.JsxCaptured)) { - return "Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX."; + return "Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX"; } else if (abstractValue.reason.has(ValueReason.Context)) { - return `Mutating a value returned from 'useContext()', which should not be mutated.`; + return `Mutating a value returned from 'useContext()', which should not be mutated`; } else if (abstractValue.reason.has(ValueReason.KnownReturnSignature)) { - return "Mutating a value returned from a function that should not be mutated."; + return "Mutating a value returned from a function whose return value should not be mutated"; } else if (abstractValue.reason.has(ValueReason.ReactiveFunctionArgument)) { - return "Mutating props or hook arguments is not allowed. Consider using a local variable instead."; + return "Mutating component props or hook arguments is not allowed. Consider using a local variable instead"; } else if (abstractValue.reason.has(ValueReason.State)) { - return "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead."; + return "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead"; } else { - return "This mutates a variable that React considers immutable."; + return "This mutates a variable that React considers immutable"; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md index 141e2ce508..0440117adb 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md @@ -18,7 +18,7 @@ function Component(props) { 2 | const x = []; 3 |
{x}
; > 4 | x.push(props.value); - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (4:4) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (4:4) 5 | return x; 6 | } 7 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md index a5df290788..2318d38feb 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md @@ -19,7 +19,7 @@ function Component(props) { 3 | // freeze 4 |
{x}
; > 5 | x[0] = true; - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (5:5) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (5:5) 6 | return x; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md index 9a34f4ef13..7116e4d197 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md @@ -19,7 +19,7 @@ function Component(props) { 3 | // freeze 4 |
{x}
; > 5 | delete x[y]; - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (5:5) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (5:5) 6 | return x; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md index 65905d45e8..c6176d1afc 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md @@ -19,7 +19,7 @@ function Component(props) { 3 | // freeze 4 |
{x}
; > 5 | delete x.y; - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (5:5) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (5:5) 6 | return x; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md index 574f9acf3c..933495c5a4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md @@ -21,7 +21,7 @@ function Component(props) { 3 | const onChange = (e) => { 4 | // INVALID! should use copy-on-write and pass the new value > 5 | x.value = e.target.value; - | ^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead.. Found mutation of [object Object] (5:5) + | ^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead. Found mutation of `x` (5:5) 6 | setX(x); 7 | }; 8 | return ; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md index 48f93a8bfb..21ad87a888 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md @@ -28,7 +28,7 @@ function Component(props) { 11 | // y is MaybeFrozen at this point, since it may alias to x 12 | // (which is the above line freezes) > 13 | y.push(props.p2); - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (13:13) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (13:13) 14 | 15 | return ; 16 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md index 22885ca60e..fb8668a9c5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md @@ -22,7 +22,7 @@ function Component(props) { 5 | 6 | // x is Frozen at this point > 7 | x.push(props.p2); - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (7:7) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (7:7) 8 | 9 | return
{_}
; 10 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.expect.md index aea02439e0..8137ec1391 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.expect.md @@ -27,7 +27,7 @@ function Component(props) { 10 | // independently 11 | const onClick = () => { > 12 | FooContext.current = true; - | ^^^^^^^^^^ InvalidReact: Mutating a value returned from 'useContext()', which should not be mutated.. Found mutation of [object Object] (12:12) + | ^^^^^^^^^^ InvalidReact: Mutating a value returned from 'useContext()', which should not be mutated. Found mutation of `FooContext` (12:12) 13 | }; 14 | return
; 15 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context.expect.md index f425490778..4f8f2616e5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-context.expect.md @@ -17,7 +17,7 @@ function Component(props) { 1 | function Component(props) { 2 | const context = useContext(FooContext); > 3 | context.value = props.value; - | ^^^^^^^ InvalidReact: Mutating a value returned from 'useContext()', which should not be mutated. (3:3) + | ^^^^^^^ InvalidReact: Mutating a value returned from 'useContext()', which should not be mutated (3:3) 4 | return context.value; 5 | } 6 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-props-in-effect-fixpoint.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-props-in-effect-fixpoint.expect.md index 3e572e3724..a30dd36cd2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-props-in-effect-fixpoint.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-props-in-effect-fixpoint.expect.md @@ -28,7 +28,7 @@ function Component(props) { 8 | let y = x; 9 | let mutateProps = () => { > 10 | y.foo = true; - | ^ InvalidReact: This mutates a variable that React considers immutable.. Found mutation of [object Object] (10:10) + | ^ InvalidReact: This mutates a variable that React considers immutable. Found mutation of `y` (10:10) 11 | }; 12 | let mutatePropsIndirect = () => { 13 | mutateProps(); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-in-closure.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-in-closure.expect.md index 2d7e1828ec..342b8be9db 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-in-closure.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-in-closure.expect.md @@ -19,7 +19,7 @@ function useInvalidMutation(options) { 2 | function test() { 3 | foo(options.foo); // error should not point on this line > 4 | options.foo = "bar"; - | ^^^^^^^ InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead.. Found mutation of [object Object] (4:4) + | ^^^^^^^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead. Found mutation of `options` (4:4) 5 | } 6 | return test; 7 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-of-possible-props-phi-indirect.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-of-possible-props-phi-indirect.expect.md index 97f4ec76ca..32d392f99f 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-of-possible-props-phi-indirect.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutation-of-possible-props-phi-indirect.expect.md @@ -22,7 +22,7 @@ function Component(props) { 2 | let x = cond ? someGlobal : props.foo; 3 | const mutatePhiThatCouldBeProps = () => { > 4 | x.y = true; - | ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect.. Found mutation of [object Object] (4:4) + | ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect. Found mutation of `x` (4:4) 5 | }; 6 | const indirectMutateProps = () => { 7 | mutatePhiThatCouldBeProps(); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-prop-mutation-indirect.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-prop-mutation-indirect.expect.md index 1928b2a017..bbaa2381c2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-prop-mutation-indirect.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-prop-mutation-indirect.expect.md @@ -21,7 +21,7 @@ function Component(props) { 1 | function Component(props) { 2 | const f = () => { > 3 | props.value = true; - | ^^^^^ InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead.. Found mutation of [object Object] (3:3) + | ^^^^^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead. Found mutation of `props` (3:3) 4 | }; 5 | const g = () => { 6 | f(); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md index a894bed013..245a52183d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md @@ -19,7 +19,7 @@ function Component(props) { 3 | // freeze 4 |
{x}
; > 5 | x.y = true; - | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX. (5:5) + | ^ InvalidReact: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX (5:5) 6 | return x; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-props-mutation-in-effect-indirect.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-props-mutation-in-effect-indirect.expect.md index e656db0e31..372b1a9a85 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-props-mutation-in-effect-indirect.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-props-mutation-in-effect-indirect.expect.md @@ -21,7 +21,7 @@ function Component(props) { 1 | function Component(props) { 2 | const mutateProps = () => { > 3 | props.value = true; - | ^^^^^ InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead.. Found mutation of [object Object] (3:3) + | ^^^^^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead. Found mutation of `props` (3:3) 4 | }; 5 | const indirectMutateProps = () => { 6 | mutateProps(); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state-2.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state-2.expect.md index b6abac2381..86faecc632 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state-2.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state-2.expect.md @@ -20,7 +20,7 @@ function Foo() { 4 | const [state, setState] = useState({ foo: { bar: 3 } }); 5 | const foo = state.foo; > 6 | foo.bar = 1; - | ^^^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead. (6:6) + | ^^^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead (6:6) 7 | return state; 8 | } 9 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state.expect.md index 509299f7e8..17302a8dae 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.modify-state.expect.md @@ -19,7 +19,7 @@ function Foo() { 3 | function Foo() { 4 | let [state, setState] = useState({}); > 5 | state.foo = 1; - | ^^^^^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead. (5:5) + | ^^^^^ InvalidReact: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead (5:5) 6 | return state; 7 | } 8 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md index 43d8f79f67..787f085471 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md @@ -18,7 +18,7 @@ export function ViewModeSelector(props) { 1 | export function ViewModeSelector(props) { 2 | const renderIcon = () => ; > 3 | renderIcon.displayName = "AcceptIcon"; - | ^^^^^^^^^^ InvalidReact: This mutates a variable that React considers immutable. (3:3) + | ^^^^^^^^^^ InvalidReact: This mutates a variable that React considers immutable (3:3) 4 | 5 | return ; 6 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-hook-argument.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-hook-argument.expect.md index 0af77f8f61..665fc7053b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-hook-argument.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-hook-argument.expect.md @@ -15,7 +15,7 @@ function useHook(a, b) { ``` 1 | function useHook(a, b) { > 2 | b.test = 1; - | ^ InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead. (2:2) + | ^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead (2:2) 3 | a.test = 2; 4 | } 5 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md index 8cbac04e13..5e63453558 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md @@ -18,7 +18,7 @@ function Foo() { 2 | 3 | function Foo() { > 4 | delete wat.foo; - | ^^^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect. (4:4) + | ^^^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (4:4) 5 | return wat; 6 | } 7 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-props.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-props.expect.md index 6972f06c60..9cc7ebf898 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-props.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-props.expect.md @@ -15,7 +15,7 @@ function Foo(props) { ``` 1 | function Foo(props) { > 2 | props.test = 1; - | ^^^^^ InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead. (2:2) + | ^^^^^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead (2:2) 3 | return null; 4 | } 5 | diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.not-useEffect-external-mutate.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.not-useEffect-external-mutate.expect.md index 8dc2926b00..9313df4e58 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.not-useEffect-external-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.not-useEffect-external-mutate.expect.md @@ -20,7 +20,7 @@ function Component(props) { 3 | function Component(props) { 4 | foo(() => { > 5 | x.a = 10; - | ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect. (5:5) + | ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (5:5) 6 | x.a = 20; 7 | }); 8 | } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md index d465e889e7..158101170c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md @@ -18,7 +18,7 @@ function Foo() { 2 | 3 | function Foo() { > 4 | wat.test = 1; - | ^^^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect. (4:4) + | ^^^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (4:4) 5 | return wat; 6 | } 7 | diff --git a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts index 619e1df823..c4bbac351a 100644 --- a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts +++ b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts @@ -52,7 +52,7 @@ const tests: CompilerTestCases = { errors: [ { message: - "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead.", + "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead", line: 7, }, ],