Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork41
cartant/eslint-plugin-rxjs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This package contains a bunch of ESLint rules for RxJS. Essentially, it's a re-implementation of the rules that are in therxjs-tslint-rules
package. (The Angular-specific rules inrxjs-tslint-rules
have been re-implemented ineslint-plugin-rxjs-angular
.)
Some of the rules are rather opinionated and are not included in therecommended
configuration. Developers can decide for themselves whether they want to enable opinionated rules.
Almost all of these rules require the TypeScript parser for ESLint.
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 theparser
and theparserOptions
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"}};
Or, using therecommended
configuration:
const{ join}=require("path");module.exports={parser:"@typescript-eslint/parser",parserOptions:{ecmaVersion:2019,project:join(__dirname,"./tsconfig.json"),sourceType:"module"},extends:["plugin:rxjs/recommended"],};
The package includes the following rules.
Rules marked with ✅ are recommended and rules marked with 🔧 have fixers.
Rule | Description | ||
---|---|---|---|
ban-observables | Forbids the use of banned observables. | ||
ban-operators | Forbids the use of banned operators. | ||
finnish | Enforces the use of Finnish notation. | ||
just | Enforces the use of ajust alias forof . | 🔧 | |
no-async-subscribe | Forbids passingasync functions tosubscribe . | ✅ | |
no-compat | Forbids importation from locations that depend uponrxjs-compat . | ||
no-connectable | Forbids operators that return connectable observables. | ||
no-create | Forbids the calling ofObservable.create . | ✅ | |
no-cyclic-action | Forbids effects and epics that re-emit filtered actions. | ||
no-explicit-generics | Forbids explicit generic type arguments. | ||
no-exposed-subjects | Forbids exposed (i.e. non-private) subjects. | ||
no-finnish | Forbids the use of Finnish notation. | ||
no-ignored-error | Forbids the calling ofsubscribe without specifying an error handler. | ||
no-ignored-notifier | Forbids observables not composed from therepeatWhen orretryWhen notifier. | ✅ | |
no-ignored-observable | Forbids the ignoring of observables returned by functions. | ||
no-ignored-replay-buffer | Forbids usingReplaySubject ,publishReplay orshareReplay without specifying the buffer size. | ✅ | |
no-ignored-subscribe | Forbids the calling ofsubscribe without specifying arguments. | ||
no-ignored-subscription | Forbids ignoring the subscription returned bysubscribe . | ||
no-ignored-takewhile-value | Forbids ignoring the value withintakeWhile . | ✅ | |
no-implicit-any-catch | Like theno-implicit-any-catch rule in@typescript-eslint/eslint-plugin , but for thecatchError operator instead ofcatch clauses. | ✅ | 🔧 |
no-index | Forbids the importation from index modules - for the reason, seethis issue. | ✅ | |
no-internal | Forbids the importation of internals. | ✅ | 🔧 |
no-nested-subscribe | Forbids the calling ofsubscribe within asubscribe callback. | ✅ | |
no-redundant-notify | Forbids redundant notifications from completed or errored observables. | ✅ | |
no-sharereplay | Forbids using theshareReplay operator. | ✅ | |
no-subclass | Forbids subclassing RxJS classes. | ||
no-subject-unsubscribe | Forbids calling theunsubscribe method of a subject instance. | ✅ | |
no-subject-value | Forbids accessing thevalue property of aBehaviorSubject instance. | ||
no-subscribe-handlers | Forbids the passing of handlers tosubscribe . | ||
no-topromise | Forbids the use of thetoPromise method. | ||
no-unbound-methods | Forbids the passing of unbound methods. | ✅ | |
no-unsafe-catch | Forbids unsafecatchError usage in effects and epics. | ||
no-unsafe-first | Forbids unsafefirst /take usage in effects and epics. | ||
no-unsafe-subject-next | Forbids unsafe optionalnext calls. | ✅ | |
no-unsafe-switchmap | Forbids unsafeswitchMap usage in effects and epics. | ||
no-unsafe-takeuntil | Forbids the application of operators aftertakeUntil . | ✅ | |
prefer-observer | Forbids the passing separate handlers tosubscribe andtap . | 🔧 | |
suffix-subjects | Enforces the use of a suffix in subject identifiers. | ||
throw-error | Enforces the passing ofError values to error notifications. |
About
ESLint rules for RxJS
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.