Commit 56da114
fix(linter/react/jsx-handler-names): do not detect the function name within the inline-function's body block (#13456)
This PR fixes a behavior of `react/jsx-handler-names` rule incompatible
with that of the eslint-version.
## Fixed difference with the eslint version
With the configuration below:
```json
{ "checkInlineFunction": true, "checkLocalVariables": true }
```
the eslint version of `react/jsx-handler-names` rule treats the
following code as invalid.
```tsx
<TestComponent onChange={() => { handleChange() }} />
```
But the current oxc version finds `handleChange` to be an event handler
name and considers this code to be correct.
Along with this change, the diagnostic messages are also modified
because the event handler name is not always available, and replaced
"invalid" with "bad" to be in accordance with the eslint-version's
message ID`badHandlerName` and `badPropKey`.
---------
Co-authored-by: Cameron Clark <cameron.clark@hey.com>1 parent 48fde64 commit 56da114
File tree
2 files changed
+41
-8
lines changed- crates/oxc_linter/src
- rules/react
- snapshots
2 files changed
+41
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
31 | | - | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
302 | 312 | | |
303 | 313 | | |
304 | 314 | | |
305 | | - | |
| 315 | + | |
306 | 316 | | |
307 | 317 | | |
308 | 318 | | |
309 | | - | |
| 319 | + | |
310 | 320 | | |
311 | 321 | | |
312 | 322 | | |
313 | | - | |
| 323 | + | |
314 | 324 | | |
315 | 325 | | |
316 | 326 | | |
317 | | - | |
| 327 | + | |
318 | 328 | | |
319 | 329 | | |
320 | 330 | | |
| |||
396 | 406 | | |
397 | 407 | | |
398 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
399 | 415 | | |
400 | 416 | | |
401 | 417 | | |
| |||
454 | 470 | | |
455 | 471 | | |
456 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
457 | 479 | | |
458 | 480 | | |
459 | 481 | | |
| |||
565 | 587 | | |
566 | 588 | | |
567 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
568 | 594 | | |
569 | 595 | | |
570 | 596 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| |||
0 commit comments