eslint-plugin-rxjs-x
v1.0.2
Published
Modern ESLint plugin for RxJS
Maintainers
Readme
eslint-plugin-rxjs-x
[!NOTE] Forked from
eslint-plugin-rxjsas the original repository seems no longer maintained.
This ESLint plugin is intended to prevent issues with RxJS 7.
Most of these rules require TypeScript typed linting and are indicated as such below.
Installation Guide (Flat Configuration)
See typescript-eslint's Getting Started for a full ESLint setup guide.
Install
eslint-plugin-rxjs-xusing your preferred package manager.Enable typed linting.
- See Linting with Type Information for more information.
Import this plugin into your config. Add the
rxjsX.configs.recommendedshared config to your configuration like so:// @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.
Notable Changes from eslint-plugin-rxjs
- eslintrc is not supported.
- The namespace of this plugin is
rxjs-xinstead ofrxjs.- e.g. if your ESLint config had
"rxjs/no-subject-value": "error", replace it with"rxjs-x/no-subject-value": "error". - e.g. if your project had inline comments like
// eslint-disable-next-line rxjs/no-async-subscribe, replace them with// eslint-disable-next-line rxjs-x/no-async-subscribe.
- e.g. if your ESLint config had
rxjs/no-ignored-observableis replaced withrxjs-x/no-floating-observable.
[!TIP] A complete description of all changes from
eslint-plugin-rxjsare documented in the CHANGELOG file.
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.
| 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. | | 🔧 | | |
| no-async-subscribe | Disallow passing async functions to subscribe. | ✅ 🔒 | | | 💭 |
| no-connectable | Disallow operators that return connectable observables. | | | | 💭 |
| no-create | Disallow the static Observable.create and Subject.create functions. | ✅ 🔒 | | | 💭 |
| 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, subscribe, and tap. | ✅ 🔒 | 🔧 | 💡 | 💭 |
| 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-sharereplay-before-takeuntil | Disallow using shareReplay({ refCount: false }) before takeUntil. | 🔒 | | | |
| 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-topromise | Disallow use of the toPromise method. | ✅ 🔒 | | 💡 | 💭 |
| no-unbound-methods | Disallow passing unbound methods. | ✅ 🔒 | | | 💭 |
| no-unnecessary-collection | Disallow unnecessary usage of collection arguments with single values. | 🔒 | | | |
| 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 or Subject.error. | ✅ 🔒 | | 💡 | 💭 |
