Repository navigation
Commit 7fce912
fix(eslint-plugin): [unbound-method] respect
A class property initialized with a function expression was the only
literal-function case that skipped `checkMethod`, so its own `this: void`
annotation was ignored:
```ts
const Foo = { floor: function (this: void) {} };
const { floor } = Foo; // correctly not reported
class Foo { floor = function (this: void) {} }
const { floor } = new Foo(); // reported, despite `this: void`
```
Routing it through `checkMethod` fixes that, and makes the two property
cases identical enough to share a branch. `ts.isFunctionExpression`
narrows the initializer for real, so the cast the old `.kind` check
needed goes away.
Skipping `checkMethod` also meant `firstParamIsThis` went uncomputed, so
these reports never carried the message that suggests annotating with
`this: void`. They do now, which moves 19 expectations - and leaves the
plain `unbound` message covered only by a new case whose function
expression annotates a non-`void` `this`.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>this: void on class properties1 parent 7a8dc4d commit 7fce912
2 files changed
Lines changed: 48 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
410 | 404 | | |
411 | | - | |
| 405 | + | |
412 | 406 | | |
413 | 407 | | |
414 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| |||
2327 | 2333 | | |
2328 | 2334 | | |
2329 | 2335 | | |
2330 | | - | |
| 2336 | + | |
2331 | 2337 | | |
2332 | 2338 | | |
2333 | 2339 | | |
| |||
2456 | 2462 | | |
2457 | 2463 | | |
2458 | 2464 | | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
2459 | 2482 | | |
2460 | 2483 | | |
2461 | 2484 | | |
| |||
2498 | 2521 | | |
2499 | 2522 | | |
2500 | 2523 | | |
2501 | | - | |
| 2524 | + | |
2502 | 2525 | | |
2503 | 2526 | | |
2504 | 2527 | | |
| |||
2534 | 2557 | | |
2535 | 2558 | | |
2536 | 2559 | | |
2537 | | - | |
| 2560 | + | |
2538 | 2561 | | |
2539 | 2562 | | |
2540 | 2563 | | |
| |||
2551 | 2574 | | |
2552 | 2575 | | |
2553 | 2576 | | |
2554 | | - | |
| 2577 | + | |
2555 | 2578 | | |
2556 | 2579 | | |
2557 | 2580 | | |
| |||
2569 | 2592 | | |
2570 | 2593 | | |
2571 | 2594 | | |
2572 | | - | |
| 2595 | + | |
2573 | 2596 | | |
2574 | 2597 | | |
2575 | 2598 | | |
| |||
2587 | 2610 | | |
2588 | 2611 | | |
2589 | 2612 | | |
2590 | | - | |
| 2613 | + | |
2591 | 2614 | | |
2592 | 2615 | | |
2593 | 2616 | | |
| |||
2622 | 2645 | | |
2623 | 2646 | | |
2624 | 2647 | | |
2625 | | - | |
| 2648 | + | |
2626 | 2649 | | |
2627 | 2650 | | |
2628 | 2651 | | |
| |||
2640 | 2663 | | |
2641 | 2664 | | |
2642 | 2665 | | |
2643 | | - | |
| 2666 | + | |
2644 | 2667 | | |
2645 | 2668 | | |
2646 | 2669 | | |
| |||
2658 | 2681 | | |
2659 | 2682 | | |
2660 | 2683 | | |
2661 | | - | |
| 2684 | + | |
2662 | 2685 | | |
2663 | 2686 | | |
2664 | 2687 | | |
| |||
2676 | 2699 | | |
2677 | 2700 | | |
2678 | 2701 | | |
2679 | | - | |
| 2702 | + | |
2680 | 2703 | | |
2681 | 2704 | | |
2682 | 2705 | | |
| |||
2694 | 2717 | | |
2695 | 2718 | | |
2696 | 2719 | | |
2697 | | - | |
| 2720 | + | |
2698 | 2721 | | |
2699 | 2722 | | |
2700 | 2723 | | |
| |||
2714 | 2737 | | |
2715 | 2738 | | |
2716 | 2739 | | |
2717 | | - | |
| 2740 | + | |
2718 | 2741 | | |
2719 | 2742 | | |
2720 | 2743 | | |
| |||
2731 | 2754 | | |
2732 | 2755 | | |
2733 | 2756 | | |
2734 | | - | |
| 2757 | + | |
2735 | 2758 | | |
2736 | 2759 | | |
2737 | 2760 | | |
| |||
2751 | 2774 | | |
2752 | 2775 | | |
2753 | 2776 | | |
2754 | | - | |
| 2777 | + | |
2755 | 2778 | | |
2756 | 2779 | | |
2757 | 2780 | | |
| |||
2768 | 2791 | | |
2769 | 2792 | | |
2770 | 2793 | | |
2771 | | - | |
| 2794 | + | |
2772 | 2795 | | |
2773 | 2796 | | |
2774 | 2797 | | |
| |||
2788 | 2811 | | |
2789 | 2812 | | |
2790 | 2813 | | |
2791 | | - | |
| 2814 | + | |
2792 | 2815 | | |
2793 | 2816 | | |
2794 | 2817 | | |
| |||
2808 | 2831 | | |
2809 | 2832 | | |
2810 | 2833 | | |
2811 | | - | |
| 2834 | + | |
2812 | 2835 | | |
2813 | 2836 | | |
2814 | 2837 | | |
| |||
2830 | 2853 | | |
2831 | 2854 | | |
2832 | 2855 | | |
2833 | | - | |
| 2856 | + | |
2834 | 2857 | | |
2835 | 2858 | | |
2836 | 2859 | | |
| |||
0 commit comments