Skip to content

Conversation

@JasonWeinzierl
Copy link
Owner

@JasonWeinzierl JasonWeinzierl commented Nov 15, 2024

BREAKING CHANGE: this rule now requires typed linting.

  • Resolves Support banning operators from "rxjs" too #7 . Reworked ban-operators to support banning operators imported from root "rxjs" too.
    • This uses typed linting to actually check the operator's type instead of just reading the import statement. This was done based on the original maintainer's comments in the unit tests indicating this was necessary.
  • Also resolves upstream [enhancement] ban-operators report the use instead of the import cartant/eslint-plugin-rxjs#96 . Banned operators are now reported at the area they're used in the code instead of the import statement.
    • This allows developers to eslint-disable-next-line to allow banned operators more precisely.
  • This also resolves the only blocker before Remove deprecated no-tap rule #8 can be worked.
  • NOTE: this only runs inside of pipe() due to performance reasons.
  • If users still want to completely ban an operator via its import, they can use the built-in ESLint rule no-restricted-imports (or the typescript-eslint equivalent @typescript-eslint/no-restircted-imports) with the importNames names option.
    • Technically users could also use ban-observables, since that rule doesn't distinguish between operators and static creation function exported from "rxjs"...

@github-actions
Copy link

github-actions bot commented Nov 15, 2024

LCOV of commit cac57ec during .github/workflows/ci.yml #79

Summary coverage rate:
  lines......: 96.3% (3267 of 3394 lines)
  functions..: 94.8% (199 of 210 functions)
  branches...: 91.3% (620 of 679 branches)

Files changed coverage rate:
                                         |Lines       |Functions  |Branches    
  Filename                               |Rate     Num|Rate    Num|Rate     Num
  =============================================================================
  src/rules/ban-operators.ts             | 100%     60| 100%     4| 100%     15

Tested on a very large codebase with TIMING=1.  When checking every single CallExpression, it takes ~2.5 seconds.  When limiting to only inside of pipe, it drops off the top-10 slowest rules (less than 130ms).
@JasonWeinzierl JasonWeinzierl merged commit 994ff25 into main Nov 16, 2024
2 checks passed
@JasonWeinzierl JasonWeinzierl deleted the type-check-ban-operators branch November 16, 2024 05:02
@JasonWeinzierl JasonWeinzierl added the enhancement New feature or request label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support banning operators from "rxjs" too

2 participants