Skip to content

prefer-takeuntil Rule Should Not Trigger for HTTP RequestsΒ #24

@manickam1999

Description

@manickam1999

Issue: prefer-takeuntil Rule Should Not Trigger for HTTP Requests

Description:
The prefer-takeuntil rule currently triggers when subscribe is called within a component, requiring the use of the takeUntil-destroyed pattern. However, this rule should not be triggered for HTTP requests, since HTTP requests clean up themselves, such as the one shown below:

Example Code:

this.http.post(url, value).subscribe();

Reason:
For specific HTTP requests, especially those that are one-time operations and do not need to be unsubscribed from when the component is destroyed, enforcing the takeUntil pattern is unnecessary and adds unnecessary complexity to the code.

Proposed Solution:
Modify the prefer-takeuntil rule to allow exceptions for certain HTTP request patterns, such as http.patch, http.post, http.put, etc. This could be controlled through additional rule options or by recognizing common HTTP request patterns that do not require unsubscription.

Example Configuration:

{
  "rxjs-angular/prefer-takeuntil": [
    "error",
    {
      "alias": ["untilDestroyed"],
      "checkComplete": true,
      "checkDecorators": ["Component"],
      "checkDestroy": true,
      "allows": ["http.patch", "http.post", "http.put"]
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions