5.0.3 • Published 1 year ago

eslint-plugin-rxjs v5.0.3

Weekly downloads
34,129
License
MIT
Repository
github
Last release
1 year ago

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.

RuleDescription
ban-observablesForbids the use of banned observables.
ban-operatorsForbids the use of banned operators.
finnishEnforces the use of Finnish notation.
justEnforces the use of a just alias for of.🔧
no-async-subscribeForbids passing async functions to subscribe.
no-compatForbids importation from locations that depend upon rxjs-compat.
no-connectableForbids operators that return connectable observables.
no-createForbids the calling of Observable.create.
no-cyclic-actionForbids effects and epics that re-emit filtered actions.
no-explicit-genericsForbids explicit generic type arguments.
no-exposed-subjectsForbids exposed (i.e. non-private) subjects.
no-finnishForbids the use of Finnish notation.
no-ignored-errorForbids the calling of subscribe without specifying an error handler.
no-ignored-notifierForbids observables not composed from the repeatWhen or retryWhen notifier.
no-ignored-observableForbids the ignoring of observables returned by functions.
no-ignored-replay-bufferForbids using ReplaySubject, publishReplay or shareReplay without specifying the buffer size.
no-ignored-subscribeForbids the calling of subscribe without specifying arguments.
no-ignored-subscriptionForbids ignoring the subscription returned by subscribe.
no-ignored-takewhile-valueForbids ignoring the value within takeWhile.
no-implicit-any-catchLike the no-implicit-any-catch rule in @typescript-eslint/eslint-plugin, but for the catchError operator instead of catch clauses.🔧
no-indexForbids the importation from index modules - for the reason, see this issue.
no-internalForbids the importation of internals.🔧
no-nested-subscribeForbids the calling of subscribe within a subscribe callback.
no-redundant-notifyForbids redundant notifications from completed or errored observables.
no-sharereplayForbids using the shareReplay operator.
no-subclassForbids subclassing RxJS classes.
no-subject-unsubscribeForbids calling the unsubscribe method of a subject instance.
no-subject-valueForbids accessing the value property of a BehaviorSubject instance.
no-subscribe-handlersForbids the passing of handlers to subscribe.
no-topromiseForbids the use of the toPromise method.
no-unbound-methodsForbids the passing of unbound methods.
no-unsafe-catchForbids unsafe catchError usage in effects and epics.
no-unsafe-firstForbids unsafe first/take usage in effects and epics.
no-unsafe-subject-nextForbids unsafe optional next calls.
no-unsafe-switchmapForbids unsafe switchMap usage in effects and epics.
no-unsafe-takeuntilForbids the application of operators after takeUntil.
prefer-observerForbids the passing separate handlers to subscribe and tap.🔧
suffix-subjectsEnforces the use of a suffix in subject identifiers.
throw-errorEnforces the passing of Error values to error notifications.
@jiralite/eslint-config-neon@tapsellorg/eslint-angular-config@kushki/eslinteslint-config-redaxmedia@infinitebrahmanuniverse/nolb-eslint-plugin-r@kushki/eslint-config@everything-registry/sub-chunk-1614elmer-eslint-config-baseseslint-config-beslogiceslint-config-brandingbrand@dlwlrma/eslint-plugin-angular@dlwlrma/eslint-plugin-angular-testingeslint-config-navideslint-config-suiyobieslint-config-strict-modeeslint-config-rel1cxeslint-config-snaileslint-config-facileeslint-config-rocketeslint-config-nlueg-angulareslint-config-neoneslint-config-holy-graileslint-config-qics@isnotdefined/eslint-config@megabytelabs/eslint-config@mblabs/eslint-config@lightech-llc/eslint-config-angular@hug/eslint-config@hubtype/angular-dx@hubtype/eslint-config-angular@eventsource/eslint-config@pepeeja/eslint-config-angular@ngbasics/eslint-plugin@neo9/n9-coding-style@progress/kendo-typescript-tasks@progress/kendo-angular-tasks@ptsecurity/eslint-config@floydspace/eslint-config-angular@firestitch/lint@flyacts/eslint-config@felvct/eslint-config@nx-pkg/eslint-config@bitovi/eslint-config@team-supercharge/frontend-quality-config@w11k/eslint-config@bou-company/eslint-config@angular-ru/eslint-config-enterprise@skblab/angular-defaults@trailheadtechnology/eslint-config@taiga-ui/eslint-plugin@tapsellorg/eslint-config@voltiso/config.eslint@voltiso/eslint-config@voltiso/eslint-config-fast@washingtondc/eslint@sourcegraph/eslint-config@breadstone-infrastructure/eslint-config@tinkoff/eslint-config-angular@trong-orm/common-scripts@cartant/eslint-config-rxjs@cloudflight/eslint-plugin-typescript@code-palette/eslint-config@craftworks/eslint-config-angular
5.0.3

1 year ago

4.0.4

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

4.0.1

2 years ago

4.0.0

3 years ago

3.3.7

3 years ago

3.3.6

3 years ago

3.3.5

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.2.0

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.3-beta.30

4 years ago

0.0.2-beta.29

4 years ago

0.0.2-beta.28

4 years ago

0.0.2-beta.27

4 years ago

0.0.2-beta.26

4 years ago

0.0.2-beta.25

4 years ago

0.0.2-beta.24

4 years ago

0.0.2-beta.23

4 years ago

0.0.2-beta.22

4 years ago

0.0.2-beta.21

4 years ago

0.0.2-beta.20

4 years ago

0.0.2-beta.19

4 years ago

0.0.2-beta.18

4 years ago

0.0.2-beta.17

4 years ago

0.0.2-beta.16

4 years ago

0.0.2-beta.15

4 years ago

0.0.2-beta.14

4 years ago

0.0.2-beta.13

4 years ago

0.0.2-beta.12

4 years ago

0.0.2-beta.11

4 years ago

0.0.1-beta.10

4 years ago

0.0.1-beta.8

4 years ago

0.0.1-beta.7

4 years ago

0.0.1-beta.6

4 years ago

0.0.1-beta.5

4 years ago

0.0.1-beta.4

5 years ago

0.0.1-beta.2

5 years ago

0.0.1-beta.1

5 years ago

0.0.1-beta.0

5 years ago