Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including eslint-plugin-rxjs with all npm packages installed. Try it out:

require("eslint/package.json"); // eslint is a peer dependency. require("typescript/package.json"); // typescript is a peer dependency. var eslintPluginRxjs = require("eslint-plugin-rxjs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

eslint-plugin-rxjs v0.0.3-beta.30

ESLint rules for RxJS

eslint-plugin-rxjs

This repo is a WIP.

Eventually, it will contain ESLint versions of the rules in the rxjs-tslint-rules package.

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

Rules

The package includes the following rules:

RuleDescriptionRecommended
ban-observablesForbids the use of banned observables.TBD
ban-operatorsForbids the use of banned operators.TBD
finnishEnforces the use of Finnish notation.TBD
justEnforces the use of a just alias for of.TBD
no-async-subscribeForbids passing async functions to subscribe.TBD
no-compatForbids importation from locations that depend upon rxjs-compat.TBD
no-connectableForbids operators that return connectable observables.TBD
no-createForbids the calling of Observable.create.TBD
no-explicit-genericsForbids explicit generic type arguments.TBD
no-exposed-subjectsForbids exposed (i.e. non-private) subjects.TBD
no-finnishForbids the use of Finnish notation.TBD
no-ignored-errorForbids the calling of subscribe without specifying an error handler.TBD
no-ignored-notifierForbids observables not composed from the repeatWhen or retryWhen notifier.TBD
no-ignored-observableForbids the ignoring of observables returned by functions.TBD
no-ignored-replay-bufferForbids using ReplaySubject, publishReplay or shareReplay without specifying the buffer size.TBD
no-ignored-subscribeForbids the calling of subscribe without specifying arguments.TBD
no-ignored-subscriptionForbids ignoring the subscription returned by subscribe.TBD
no-ignored-takewhile-valueForbids ignoring the value within takeWhile.TBD
no-implicit-any-catchLike the no-implicit-any-catch rule in @typescript-eslint/eslint-plugin, but for the catchError operator instead of catch clauses.TBD
no-indexForbids the importation from index modules - for the reason, see this issue.TBD
no-internalForbids the importation of internals.TBD
no-nested-subscribeForbids the calling of subscribe within a subscribe callback.TBD
no-redundant-notifyDisallows redundant notifications from completed or errored observables.TBD
no-sharereplayForbids using the shareReplay operator.TBD
no-subclassForbids subclassing RxJS classes.TBD
no-subject-unsubscribeForbids calling the unsubscribe method of a subject instance.TBD
no-subject-valueForbids accessing the value property of a BehaviorSubject instance.TBD
no-tapForbids the use of the tap operator.TBD
no-topromiseForbids the use of the toPromise method.TBD
no-unbound-methodsForbids the passing of unbound methods.TBD
no-unsafe-catchForbids unsafe catchError usage in effects and epics.TBD
no-unsafe-firstForbids unsafe first/take usage in effects and epics.TBD
no-unsafe-subject-nextForbids unsafe optional next calls.TBD
no-unsafe-switchmapForbids unsafe switchMap usage in effects and epics.TBD
no-unsafe-takeuntilForbids the application of operators after takeUntil.TBD
prefer-observerForbids the passing separate callbacks to subscribe and tap.TBD
suffix-subjectsEnforces the use of a suffix in subject identifiers.TBD
throw-errorEnforces the passing of Error values to error notifications.TBD
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free