Add test fixture showing invalid location

Add test fixture showing invalid location 

The error should be on the node mutating the output, not in the read location.
This commit is contained in:
Jan Kassens
2024-02-15 19:00:21 -05:00
parent ac89712750
commit 530f2c293d
2 changed files with 35 additions and 0 deletions
@@ -0,0 +1,28 @@
## Input
```javascript
function useInvalidMutation(options) {
function test() {
foo(options.foo); // error should not point on this line
options.foo = "bar";
}
return test;
}
```
## Error
```
1 | function useInvalidMutation(options) {
2 | function test() {
> 3 | foo(options.foo); // error should not point on this line
| ^^^^^^^^^^^ [ReactForget] InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead. (3:3)
4 | options.foo = "bar";
5 | }
6 | return test;
```
@@ -0,0 +1,7 @@
function useInvalidMutation(options) {
function test() {
foo(options.foo); // error should not point on this line
options.foo = "bar";
}
return test;
}