Skip to content

Conversation

JasonWeinzierl
Copy link
Owner

Missed corner case from the original implementation of this rule when imitating no-misused-promises.

We didn't add unit tests for the non-void case, so this was triggering the rule:

        import { Observable, of } from "rxjs";

        interface Props {
          foo: () => Observable<number>;
        }
        declare function Component(props: Props): any;

        const _ = <Component foo={() => of(42)} />;

essentially blocking any prop from ever being an Observable-returning function. We need to check if the contextual type of the prop is void-returning and if the expression returns an Observable before reporting a violation.

Copy link

github-actions bot commented Jun 25, 2025

LCOV of commit 12b9a93 during .github/workflows/ci.yml #609

Summary coverage rate:
  lines......: 96.7% (4485 of 4639 lines)
  functions..: 96.2% (275 of 286 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  src/rules/no-misused-observables.ts                               | 4.0%    449| 0.0%    18|    -      0

@JasonWeinzierl JasonWeinzierl changed the title fix(no-misused-observables): false positive in prop fix(no-misused-observables): false positive for JSX attributes Jun 25, 2025
@JasonWeinzierl JasonWeinzierl merged commit 636c922 into main Jun 26, 2025
3 checks passed
@JasonWeinzierl JasonWeinzierl deleted the fix-misused-jsx branch June 26, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant