Skip to content

Conversation

@JasonWeinzierl
Copy link
Owner

@JasonWeinzierl JasonWeinzierl commented Oct 30, 2025

New rule to detect unnecessary usage of combineLatest, forkJoin, etc. where a collection (object or array) containing only a single observable is passed in. In these cases, combineLatest, etc. can be replaced with the single observable itself (after accounting for slight changes in output).

  • This rule is added to the strict config.
  • This rule does not include a fixer. A fixer could be implemented in future for merge, race, concat, and the overload of combineLatest that accepts an array.
  • This rule does not support variable-length arrays and non-literal objects because their lengths are not guaranteed.
  • Like most rules in this plugin, this rule does not support import aliases.

Resolves #39 and cartant#107 .

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

LCOV of commit 8d11335 during .github/workflows/ci.yml #710

Summary coverage rate:
  lines......: 96.8% (4675 of 4829 lines)
  functions..: 96.3% (284 of 295 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  src/configs/strict.ts                                             | 2.3%     43| 0.0%     1|    -      0
  src/constants.ts                                                  | 0.0%     39|    -     0|    -      0
  src/index.ts                                                      | 0.0%    111|    -     0|    -      0
  src/rules/no-unnecessary-collection.ts                            | 4.5%     89| 0.0%     4|    -      0

@JasonWeinzierl JasonWeinzierl marked this pull request as ready for review October 30, 2025 19:37
@JasonWeinzierl JasonWeinzierl force-pushed the issue-39 branch 2 times, most recently from cb97fc7 to 3f03c64 Compare November 2, 2025 17:25
@JasonWeinzierl JasonWeinzierl changed the title feat(no-unnecessary-combine): new rule feat(no-unnecessary-collection): new rule Nov 2, 2025
@JasonWeinzierl JasonWeinzierl merged commit 61abe24 into main Nov 3, 2025
4 checks passed
@JasonWeinzierl JasonWeinzierl deleted the issue-39 branch November 3, 2025 16:19
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.

Add rule for disallowing combineLatest (and similar) with only a single-item array

2 participants