GithubHelp home page GithubHelp logo

rafaelss95 / eslint-plugin-rxjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cartant/eslint-plugin-rxjs

1.0 1.0 0.0 2.57 MB

ESLint rules for RxJS

License: MIT License

TypeScript 99.98% Shell 0.02%

eslint-plugin-rxjs's Introduction

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-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 callbacks 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.

eslint-plugin-rxjs's People

Contributors

aboyton avatar cartant avatar dkosasih avatar jdanil avatar joshuakgoldberg avatar kbarendrecht avatar porkite avatar rafaelss95 avatar rgunning avatar timdeschryver avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.