This repo is a WIP.
Eventually, it will contain ESLint versions of the rules in the rxjs-tslint-rules
package.
Install the ESLint TypeScript parser using npm:
npm install @typescript-eslint/parser --save-dev
Install the package using npm:
npm install eslint-plugin-rxjs --save-dev
Configure the parser
and the parserOptions
for ESLint. Here, I use a .eslintrc.js
file for the configuration:
const { join } = require("path");
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2019,
project: join(__dirname, "./tsconfig.json"),
sourceType: "module"
},
plugins: ["rxjs"],
extends: [],
rules: {
"rxjs/no-async-subscribe": "error",
"rxjs/no-ignored-observable": "error",
"rxjs/no-ignored-subscription": "error",
"rxjs/no-nested-subscribe": "error",
"rxjs/no-unbound-methods": "error",
"rxjs/throw-error": "error"
}
};
The package includes the following rules:
Rule | Description | Recommended |
---|---|---|
ban-observables |
Forbids the use of banned observables. | TBD |
ban-operators |
Forbids the use of banned operators. | TBD |
finnish |
Enforces the use of Finnish notation. | TBD |
just |
Enforces the use of a just alias for of . |
TBD |
no-async-subscribe |
Forbids passing async functions to subscribe . |
TBD |
no-compat |
Forbids importation from locations that depend upon rxjs-compat . |
TBD |
no-connectable |
Forbids operators that return connectable observables. | TBD |
no-create |
Forbids the calling of Observable.create . |
TBD |
no-explicit-generics |
Forbids explicit generic type arguments. | TBD |
no-exposed-subjects |
Forbids exposed (i.e. non-private) subjects. | TBD |
no-finnish |
Forbids the use of Finnish notation. | TBD |
no-ignored-error |
Forbids the calling of subscribe without specifying an error handler. |
TBD |
no-ignored-notifier |
Forbids observables not composed from the repeatWhen or retryWhen notifier. |
TBD |
no-ignored-observable |
Forbids the ignoring of observables returned by functions. | TBD |
no-ignored-replay-buffer |
Forbids using ReplaySubject , publishReplay or shareReplay without specifying the buffer size. |
TBD |
no-ignored-subscribe |
Forbids the calling of subscribe without specifying arguments. |
TBD |
no-ignored-subscription |
Forbids ignoring the subscription returned by subscribe . |
TBD |
no-ignored-takewhile-value |
Forbids ignoring the value within takeWhile . |
TBD |
no-implicit-any-catch |
Like the no-implicit-any-catch rule in @typescript-eslint/eslint-plugin , but for the catchError operator instead of catch clauses. |
TBD |
no-index |
Forbids the importation from index modules - for the reason, see this issue. | TBD |
no-internal |
Forbids the importation of internals. | TBD |
no-nested-subscribe |
Forbids the calling of subscribe within a subscribe callback. |
TBD |
no-redundant-notify |
Disallows redundant notifications from completed or errored observables. | TBD |
no-sharereplay |
Forbids using the shareReplay operator. |
TBD |
no-subclass |
Forbids subclassing RxJS classes. | TBD |
no-subject-unsubscribe |
Forbids calling the unsubscribe method of a subject instance. |
TBD |
no-subject-value |
Forbids accessing the value property of a BehaviorSubject instance. |
TBD |
no-tap |
Forbids the use of the tap operator. |
TBD |
no-topromise |
Forbids the use of the toPromise method. |
TBD |
no-unbound-methods |
Forbids the passing of unbound methods. | TBD |
no-unsafe-catch |
Forbids unsafe catchError usage in effects and epics. |
TBD |
no-unsafe-first |
Forbids unsafe first /take usage in effects and epics. |
TBD |
no-unsafe-subject-next |
Forbids unsafe optional next calls. |
TBD |
no-unsafe-switchmap |
Forbids unsafe switchMap usage in effects and epics. |
TBD |
no-unsafe-takeuntil |
Forbids the application of operators after takeUntil . |
TBD |
prefer-observer |
Forbids the passing separate callbacks to subscribe and tap . |
TBD |
suffix-subjects |
Enforces the use of a suffix in subject identifiers. | TBD |
throw-error |
Enforces the passing of Error values to error notifications. |
TBD |