Skip to content

Conversation

JasonWeinzierl
Copy link
Owner

@JasonWeinzierl JasonWeinzierl commented Nov 19, 2024

Help developers migrate from rxjs/operators to rxjs.

  • Handles both imports and exports.
  • Will auto-rename any operators that have a different name in rxjs (concat -> concatWith as concat).
  • Will not attempt to auto-fix if there's a risk of breaking code. e.g. the partition operator was not moved at all, so we leave that import alone. Ditto for * imports/exports.
  • This will likely be added to the recommended config when v1 releases. That change will also include bumping the RxJS peer dependency version to v7.2 instead of v7.0.

Resolves #9 .

Feedback is welcome, especially on the rule's name.

@JasonWeinzierl JasonWeinzierl added the enhancement New feature or request label Nov 19, 2024
Copy link

github-actions bot commented Nov 19, 2024

LCOV of commit fca768c during .github/workflows/ci.yml #110

Summary coverage rate:
  lines......: 96.2% (3628 of 3770 lines)
  functions..: 95.6% (237 of 248 functions)
  branches...: 91.3% (732 of 802 branches)

Files changed coverage rate:
                                         |Lines       |Functions  |Branches    
  Filename                               |Rate     Num|Rate    Num|Rate     Num
  =============================================================================
  src/index.ts                           | 100%    101|    -     0|    -      0
  src/rules/prefer-root-operators.ts     |94.9%    137| 100%    16|90.7%     43

We're only adding a suggestion right now because an auto-fixer might break if the operator is old and not exported from `rxjs` too.
It's ugly and needs refactoring, but the tests pass.
- When alias name and operator name equal, we also need to check range to determine if the alias exists or not.
- Refactored rule for less duplication.
…ovided

Warn about possible renames or partition being gone.
Import isn't accurate because the rule also covers exports too.
@JasonWeinzierl JasonWeinzierl changed the title feat(prefer-import-root-operators): new rule feat(prefer-root-operators): new rule Nov 21, 2024
@JasonWeinzierl JasonWeinzierl merged commit e3b8090 into main Nov 22, 2024
2 checks passed
@JasonWeinzierl JasonWeinzierl deleted the op-import branch November 22, 2024 03:13
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.

Add rule enforcing operator imports from "rxjs" instead of "rxjs/operators"
1 participant