Disallow calling subscribe without specifying an error handler (rxjs-x/no-ignored-error)

April 18, 2025 ยท View on GitHub

๐Ÿ’ผ This rule is enabled in the ๐Ÿ”’ strict config.

๐Ÿ’ญ This rule requires type information.

This rule enforces the passing of an error handler to subscribe calls.

Rule details

Examples of incorrect code for this rule:

source.subscribe((value) => console.log(value));
source.subscribe({
  next: (value) => console.log(value)
});

Examples of correct code for this rule:

source.subscribe(
  (value) => console.log(value),
  (error) => console.error(error)
);
source.subscribe({
  next: (value) => console.log(value),
  error: (error) => console.error(error)
});

When Not To Use It

If you're not worried about ignored errors, then in some cases it may be safe to not use this rule. Or if you use operators like catchError to handle all errors, then in some cases it may be safe to not use this rule. You might consider using ESLint disable comments for those specific situations instead of completely disabling this rule.

Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.

Resources