eslint-plugin-rxjs-x v0.7.0
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.
Migrating from eslint-plugin-rxjs
This project is a fork of eslint-plugin-rxjs
initially started to support the new ESLint flat config format.
There are some breaking changes:
- The old
.eslintrcformat is not supported.- If you need to continue using this old format, use the original
eslint-plugin-rxjsor a different fork.
- If you need to continue using this old format, use the original
- The plugin namespace specified in the
recommendedconfig was changed fromrxjstorxjs-x.- e.g. In your ESLint config,
rxjs/no-subject-valueshould be renamed torxjs-x/no-subject-value.
- e.g. In your ESLint config,
- The rule
rxjs/no-ignored-observableis renamed torxjs-x/no-floating-observables.
A complete description of all changes are documented in the CHANGELOG file.
Install
See typescript-eslint's Getting Started for a full ESLint setup guide.
Then use the recommended configuration in your eslint.config.mjs and enable typed linting:
// @ts-check
import tseslint from 'typescript-eslint';
import rxjsX from 'eslint-plugin-rxjs-x';
export default tseslint.config({
extends: [
...tseslint.configs.recommended,
rxjsX.configs.recommended,
],
languageOptions: {
parserOptions: {
projectService: true,
},
},
});The above example uses typescript-eslint's built-in config to set up the TypeScript parser for us.
Enabling projectService then turns on typed linting.
See Linting with Type Information for details.
Configs
| Name | |
|---|---|
| β | recommended |
| π | strict |
Rules
The package includes the following rules.
πΌ Configurations enabled in.\
β
Set in the recommended configuration.\
π Set in the strict configuration.\
π§ Automatically fixable by the --fix 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. | π§ | ||||
| macro | Require the use of the RxJS Tools Babel macro. | π§ | β | |||
| no-async-subscribe | Disallow passing async functions to subscribe. | β π | π | |||
| no-compat | Disallow the rxjs-compat package. | β | ||||
| no-connectable | Disallow operators that return connectable observables. | π | ||||
| no-create | Disallow the static Observable.create function. | β π | π | |||
| 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 firstValueFrom, lastValueFrom, first, and last without specifying a default value. | π | π | |||
| no-ignored-error | Disallow calling subscribe without specifying an error handler. | π | π | |||
| no-ignored-notifier | Disallow observables not composed from the repeatWhen or retryWhen notifier. | β π | π | |||
| no-ignored-replay-buffer | Disallow using ReplaySubject, publishReplay or shareReplay without specifying the buffer size. | β π | ||||
| no-ignored-subscribe | Disallow calling subscribe without specifying arguments. | π | ||||
| no-ignored-subscription | Disallow ignoring the subscription returned by subscribe. | π | ||||
| no-ignored-takewhile-value | Disallow ignoring the value within takeWhile. | β π | ||||
| no-implicit-any-catch | Disallow implicit any error parameters in catchError operators. | β π | π§ | π‘ | π | |
| 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 subscribe within a subscribe callback. | β π | π | |||
| no-redundant-notify | Disallow sending redundant notifications from completed or errored observables. | β π | π | |||
| no-sharereplay | Disallow unsafe shareReplay usage. | β π | ||||
| no-subclass | Disallow subclassing RxJS classes. | π | π | |||
| no-subject-unsubscribe | Disallow calling the unsubscribe method of subjects. | β π | π | |||
| no-subject-value | Disallow accessing the value property of a BehaviorSubject instance. | π | ||||
| no-subscribe-handlers | Disallow passing handlers to subscribe. | π | ||||
| no-subscribe-in-pipe | Disallow calling of subscribe within any RxJS operator inside a pipe. | β π | π | |||
| no-tap | Disallow the tap operator. | β | ||||
| no-topromise | Disallow use of the toPromise method. | β π | π‘ | π | ||
| no-unbound-methods | Disallow passing unbound methods. | β π | π | |||
| no-unsafe-catch | Disallow unsafe catchError usage in effects and epics. | π | ||||
| no-unsafe-first | Disallow unsafe first/take usage in effects and epics. | π | ||||
| no-unsafe-subject-next | Disallow unsafe optional next calls. | β π | π | |||
| no-unsafe-switchmap | Disallow unsafe switchMap usage in effects and epics. | π | ||||
| no-unsafe-takeuntil | Disallow applying operators after takeUntil. | β π | π | |||
| prefer-observer | Disallow passing separate handlers to subscribe and tap. | β π | π§ | π‘ | π | |
| prefer-root-operators | Disallow importing operators from rxjs/operators. | β π | π§ | π‘ | ||
| suffix-subjects | Enforce the use of a suffix in subject identifiers. | π | ||||
| throw-error | Enforce passing only Error values to throwError. | β π | π |