1.0.20 • Published 1 month ago

@smarttools/eslint-plugin-rxjs v1.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

eslint-plugin-rxjs

NPM Version License: MIT CI

An upgrade of eslint-plugin-rxjs to support modern TypeScript and ESLint. ie, Flat Config as well as legacy config.

Since some rules have better implementations in other more generic ESLint packages, they have been removed and noted here as to the appropriate replacements.

The tests have been upgraded to use standard TypeScript and ESLint test helpers.

All existing unit tests pass.

This plugin now works with both Flat Config and Legacy Config. Pay attention to the example below.

Install

Install the ESLint TypeScript parser using npm:

npm install @typescript-eslint/parser --save-dev

Install the package using npm:

npm install @smarttools/eslint-plugin-rxjs --save-dev

Configure the parser and the parserOptions for ESLint. Here, I use a .eslintrc.js file for the configuration:

Flat Config

const rxjs = require('@smarttools/eslint-plugin-rxjs');

module.exports = [{
  files: ['**/*'],
  plugins: {
    rxjs,
  },
},{
  files: ['**/*.ts'],
  // languageOptions here
  rules: {
    'rxjs/no-async-subscribe': 'error',
    ...etc.
  },
}];

Legacy Config

const { join } = require("path");
module.exports = {
  parser: "@typescript-eslint/parser",
  // parserOptions here
  plugins: ["@smarttools/rxjs"],
  extends: [],
  rules: {
    "@smarttools/rxjs/no-async-subscribe": "error",
    ...etc.
  }
};

Or, using the recommended configuration:

Note: The recommended configuration uses rules that require type checking. You will need to supply the parsing options as specified in the TypeScript ESLint documentation.

Flat Config

const rxjs = require('@smarttools/eslint-plugin-rxjs');

module.exports = [
  rxjs.configs.recommended,
  {
    files: ['**/*.ts'],
    plugins: {
      rxjs,
    },
  },
  // additional rules
];

Legacy Config

const { join } = require("path");
module.exports = {
  parser: "@typescript-eslint/parser",
  // parserOptions here
  extends: ["plugin:@smarttools/rxjs/recommended-legacy"],
};

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-genericsUse @typescript-eslint/no-unnecessary-type-arguments instead.
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.
1.0.20

1 month ago

1.0.19

3 months ago

1.0.18

5 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago