• Stars
    star
    280
  • Rank 144,007 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ESLint rules for RxJS

eslint-plugin-rxjs

GitHub License NPM version Downloads Build status dependency status devDependency Status peerDependency Status

This package contains a bunch of ESLint rules for RxJS. Essentially, it's a re-implementation of the rules that are in the rxjs-tslint-rules package. (The Angular-specific rules in rxjs-tslint-rules have been re-implemented in eslint-plugin-rxjs-angular.)

Some of the rules are rather opinionated and are not included in the recommended 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

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"
  }
};

Or, using the recommended 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"],
};

Rules

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 a just alias for of. 🔧
no-async-subscribe Forbids passing async functions to subscribe. ✅
no-compat Forbids importation from locations that depend upon rxjs-compat.
no-connectable Forbids operators that return connectable observables.
no-create Forbids the calling of Observable.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 of subscribe without specifying an error handler.
no-ignored-notifier Forbids observables not composed from the repeatWhen or retryWhen notifier. ✅
no-ignored-observable Forbids the ignoring of observables returned by functions.
no-ignored-replay-buffer Forbids using ReplaySubject, publishReplay or shareReplay without specifying the buffer size. ✅
no-ignored-subscribe Forbids the calling of subscribe without specifying arguments.
no-ignored-subscription Forbids ignoring the subscription returned by subscribe.
no-ignored-takewhile-value Forbids ignoring the value within takeWhile. ✅
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. ✅ 🔧
no-index Forbids the importation from index modules - for the reason, see this issue. ✅
no-internal Forbids the importation of internals. ✅ 🔧
no-nested-subscribe Forbids the calling of subscribe within a subscribe callback. ✅
no-redundant-notify Forbids redundant notifications from completed or errored observables. ✅
no-sharereplay Forbids using the shareReplay operator. ✅
no-subclass Forbids subclassing RxJS classes.
no-subject-unsubscribe Forbids calling the unsubscribe method of a subject instance. ✅
no-subject-value Forbids accessing the value property of a BehaviorSubject instance.
no-subscribe-handlers Forbids the passing of handlers to subscribe.
no-topromise Forbids the use of the toPromise method.
no-unbound-methods Forbids the passing of unbound methods. ✅
no-unsafe-catch Forbids unsafe catchError usage in effects and epics.
no-unsafe-first Forbids unsafe first/take usage in effects and epics.
no-unsafe-subject-next Forbids unsafe optional next calls. ✅
no-unsafe-switchmap Forbids unsafe switchMap usage in effects and epics.
no-unsafe-takeuntil Forbids the application of operators after takeUntil. ✅
prefer-observer Forbids the passing separate handlers to subscribe and tap. 🔧
suffix-subjects Enforces the use of a suffix in subject identifiers.
throw-error Enforces the passing of Error values to error notifications.

More Repositories

1

rxjs-spy

A debugging library for RxJS
TypeScript
698
star
2

rxjs-tslint-rules

TSLint rules for RxJS
TypeScript
370
star
3

rxjs-marbles

An RxJS marble testing library for any test framework
TypeScript
300
star
4

rxjs-etc

Observables and operators for RxJS
TypeScript
214
star
5

ts-action

TypeScript action creators for Redux
TypeScript
184
star
6

eslint-plugin-etc

More general-purpose (TypeScript-related) ESLint rules
TypeScript
140
star
7

rxjs-observe

A library for observing an object's property assignments and method calls
TypeScript
96
star
8

eslint-plugin-rxjs-angular

ESLint rules for RxJS and Angular
TypeScript
94
star
9

tslint-etc

More rules for TSLint
TypeScript
43
star
10

firebase-key

Firebase key utility and encoding/decoding functions
TypeScript
39
star
11

rxjs-spy-devtools

Chrome DevTools for rxjs-spy
TypeScript
39
star
12

firebase-nightlight

An in-memory, JavaScript mock for the Firebase Web API
TypeScript
37
star
13

ts-action-operators

TypeScript action operators for NgRx and redux-observable
TypeScript
33
star
14

ts-snippet

A TypeScript snippet compiler for any test framework
TypeScript
32
star
15

eslint-plugin-react-etc

More ESLint rules for React
TypeScript
16
star
16

devtools-example

DevTools extension examples
JavaScript
16
star
17

eslint-etc

Utils for ESLint TypeScript rules
TypeScript
15
star
18

rxjs-xyz

RxJS community packages
JavaScript
14
star
19

rxjs-pluggables

RxJS observables and operators with pluggable strategies
TypeScript
14
star
20

firebase-thermite

Firebase RxJS observables
TypeScript
13
star
21

rxjs-traits

RxJS Traits for Static Analysis
TypeScript
13
star
22

rxjs-report-usage

Report a project's RxJS API usage to the core team
JavaScript
10
star
23

rxjs-interop

Observable interop helpers for RxJS
TypeScript
8
star
24

eslint-plugin-rxjs-traits

TypeScript
8
star
25

blog

Blog post Markdown content
Shell
6
star
26

tsutils-etc

TypeScript
6
star
27

recompose-etc

React function components and higher-order components based on recompose and RxJS
TypeScript
4
star
28

cartant

3
star
29

memoize-resolver

A general-purpose key resolver for memoize
TypeScript
3
star
30

eslint-plugin-dtslint

ESLint rules for dtslint tests
TypeScript
2
star
31

eslint-issues

A repo for reproducing ESLint plugin problems
TypeScript
1
star
32

eslint-config-rxjs

JavaScript
1
star
33

eslint-config-etc

JavaScript
1
star
34

eslint-config

JavaScript
1
star
35

eslint-config-react

JavaScript
1
star