Modern ESLint plugin for RxJS
npm install eslint-plugin-rxjs-x


This ESLint plugin is intended to prevent issues with RxJS.
Most of these rules require TypeScript typed linting and are indicated as such below.
See typescript-eslint's Getting Started for a full ESLint setup guide.
1. Install eslint-plugin-rxjs-x using your preferred package manager.
2. Enable typed linting.
- See Linting with Type Information for more information.
3. Import this plugin into your config.
Add the rxjsX.configs.recommended shared config to your configuration like so:
``diff
// @ts-check
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
+ import rxjsX from 'eslint-plugin-rxjs-x';
export default defineConfig({
extends: [
tseslint.configs.recommended,
+ rxjsX.configs.recommended,
],
languageOptions: {
parserOptions: {
projectService: true,
},
},
});
`
Additionally, consider if the rxjsX.configs.strict shared config is right for your project.
> [!TIP]
> A complete description of all changes from eslint-plugin-rxjs are documented in the CHANGELOG file.
This project started as a fork of eslint-plugin-rxjs
but is still compatible with the eslintrc configuration format.
> [!WARNING]
> eslintrc compatibility will be removed in v1.
> Users are highly encouraged to upgrade to ESLint's flat configuration format.
> See: [https://eslint.org/docs/latest/use/configure/migration-guide]
1. Install eslint-plugin-rxjs-x using your preferred package manager.plugin:rxjs/recommended
2. If you previously used the shared config,plugin:rxjs-x/recommended-legacy
replace it with :
`diff`
"extends": [
"plugin:@typescript-eslint/recommended",
- "plugin:rxjs/recommended",
+ "plugin:rxjs-x/recommended-legacy",
],
3. If you previously did _not_ use a shared config,
then replace the rxjs plugin to your plugins block:
`diff`
"plugins": [
"@typescript-eslint",
- "rxjs",
+ "rxjs-x",
],
- Note: this is unnecessary if you are using the recommended-legacy shared config.rules
4. In your blocks, replace the namespace rxjs with rxjs-x for all rules:
`diff`
"rules": {
- "rxjs/no-subject-value": "error",
+ "rxjs-x/no-subject-value": "error",
},
- Note: if your project has inline comments (e.g. eslint-disable-next-line) referencing rxjs rules, you must update the namespace there too.rxjs/no-ignored-observable
5. If you previously used , consider replacing it with rxjs-x/no-floating-observables. no-ignored-observable will be removed in v1.
`diff`
- 'rxjs/no-ignored-observable': 'error',
+ 'rxjs-x/no-floating-observables': 'error',
| | Name |
| :- | :------------ |
| β
| recommended |strict
| π | |
The package includes the following rules.
πΌ Configurations enabled in.\
β
Set in the recommended configuration.\strict
π Set in the configuration.\--fix
π§ Automatically fixable by the CLI option.\
π‘ Manually fixable by editor suggestions.\
π Requires type information.\
β Deprecated.
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | π§ | π‘ | π | β |
| :------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------- | :--- | :- | :- | :- | :- |
| ban-observables | Disallow banned observable creators. | | | | | |
| ban-operators | Disallow banned operators. | | | | π | |
| finnish | Enforce Finnish notation. | | | | π | |
| just | Require the use of just instead of of. | | π§ | | | |async
| macro | Require the use of the RxJS Tools Babel macro. | | π§ | | | β |
| no-async-subscribe | Disallow passing functions to subscribe. | β
π | | | π | |rxjs-compat
| no-compat | Disallow the package. | | | | | β |Observable.create
| no-connectable | Disallow operators that return connectable observables. | | | | π | |
| no-create | Disallow the static function. | β
π | | | π | |firstValueFrom
| no-cyclic-action | Disallow cyclic actions in effects and epics. | | | | π | |
| no-explicit-generics | Disallow unnecessary explicit generic type arguments. | | | | π | |
| no-exposed-subjects | Disallow public and protected subjects. | π | | | π | |
| no-finnish | Disallow Finnish notation. | | | | π | |
| no-floating-observables | Require Observables to be handled appropriately. | π | | | π | |
| no-ignored-default-value | Disallow using , lastValueFrom, first, and last without specifying a default value. | π | | | π | |subscribe
| no-ignored-error | Disallow calling without specifying an error handler. | π | | | π | |repeatWhen
| no-ignored-notifier | Disallow observables not composed from the or retryWhen notifier. | β
π | | | π | |ReplaySubject
| no-ignored-observable | Disallow ignoring of observables returned by functions. | | | | | β |
| no-ignored-replay-buffer | Disallow using , publishReplay or shareReplay without specifying the buffer size. | β
π | | | | |subscribe
| no-ignored-subscribe | Disallow calling without specifying arguments. | | | | π | |subscribe
| no-ignored-subscription | Disallow ignoring the subscription returned by . | | | | π | |takeWhile
| no-ignored-takewhile-value | Disallow ignoring the value within . | β
π | | | | |any
| no-implicit-any-catch | Disallow implicit error parameters in catchError operators. | β
π | π§ | π‘ | π | |subscribe
| no-index | Disallow importing index modules. | β
π | | | | |
| no-internal | Disallow importing internal modules. | β
π | π§ | π‘ | | |
| no-misused-observables | Disallow Observables in places not designed to handle them. | π | | | π | |
| no-nested-subscribe | Disallow calling within a subscribe callback. | β
π | | | π | |shareReplay
| no-redundant-notify | Disallow sending redundant notifications from completed or errored observables. | β
π | | | π | |
| no-sharereplay | Disallow unsafe usage. | β
π | | | | |shareReplay({ refCount: false })
| no-sharereplay-before-takeuntil | Disallow using before takeUntil. | π | | | | |unsubscribe
| no-subclass | Disallow subclassing RxJS classes. | π | | | π | |
| no-subject-unsubscribe | Disallow calling the method of subjects. | β
π | | | π | |value
| no-subject-value | Disallow accessing the property of a BehaviorSubject instance. | | | | π | |subscribe
| no-subscribe-handlers | Disallow passing handlers to . | | | | π | |subscribe
| no-subscribe-in-pipe | Disallow calling of within any RxJS operator inside a pipe. | β
π | | | π | |tap
| no-tap | Disallow the operator. | | | | | β |toPromise
| no-topromise | Disallow use of the method. | β
π | | π‘ | π | |catchError
| no-unbound-methods | Disallow passing unbound methods. | β
π | | | π | |
| no-unnecessary-collection | Disallow unnecessary usage of collection arguments with single values. | π | | | | |
| no-unsafe-catch | Disallow unsafe usage in effects and epics. | | | | π | |first
| no-unsafe-first | Disallow unsafe /take usage in effects and epics. | | | | π | |next
| no-unsafe-subject-next | Disallow unsafe optional calls. | β
π | | | π | |switchMap
| no-unsafe-switchmap | Disallow unsafe usage in effects and epics. | | | | π | |takeUntil
| no-unsafe-takeuntil | Disallow applying operators after . | β
π | | | π | |subscribe
| prefer-observer | Disallow passing separate handlers to and tap. | β
π | π§ | π‘ | π | |rxjs/operators
| prefer-root-operators | Disallow importing operators from . | β
π | π§ | π‘ | | |Error
| suffix-subjects | Enforce the use of a suffix in subject identifiers. | | | | π | |
| throw-error | Enforce passing only values to throwError or Subject.error`. | β
π | | | π | |