0.7.0 β€’ Published 3 months ago

eslint-plugin-rxjs-x v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

eslint-plugin-rxjs-x

GitHub License NPM version

This ESLint plugin is intended to prevent issues with RxJS.

Most of these rules require TypeScript typed linting and are indicated as such below.

Migrating from eslint-plugin-rxjs

This project is a fork of eslint-plugin-rxjs initially started to support the new ESLint flat config format. There are some breaking changes:

  • The old .eslintrc format is not supported.
    • If you need to continue using this old format, use the original eslint-plugin-rxjs or a different fork.
  • The plugin namespace specified in the recommended config was changed from rxjs to rxjs-x.
    • e.g. In your ESLint config, rxjs/no-subject-value should be renamed to rxjs-x/no-subject-value.
  • The rule rxjs/no-ignored-observable is renamed to rxjs-x/no-floating-observables.

A complete description of all changes are documented in the CHANGELOG file.

Install

See typescript-eslint's Getting Started for a full ESLint setup guide.

Then use the recommended configuration in your eslint.config.mjs and enable typed linting:

// @ts-check
import tseslint from 'typescript-eslint';
import rxjsX from 'eslint-plugin-rxjs-x';

export default tseslint.config({
    extends: [
        ...tseslint.configs.recommended,
        rxjsX.configs.recommended,
    ],
    languageOptions: {
        parserOptions: {
            projectService: true,
        },
    },
});

The above example uses typescript-eslint's built-in config to set up the TypeScript parser for us. Enabling projectService then turns on typed linting. See Linting with Type Information for details.

Configs

Name
βœ…recommended
πŸ”’strict

Rules

The package includes the following rules.

πŸ’Ό Configurations enabled in.\ βœ… Set in the recommended configuration.\ πŸ”’ Set in the strict configuration.\ πŸ”§ Automatically fixable by the --fix CLI option.\ πŸ’‘ Manually fixable by editor suggestions.\ πŸ’­ Requires type information.\ ❌ Deprecated.

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’ΌπŸ”§πŸ’‘πŸ’­βŒ
ban-observablesDisallow banned observable creators.
ban-operatorsDisallow banned operators.πŸ’­
finnishEnforce Finnish notation.πŸ’­
justRequire the use of just instead of of.πŸ”§
macroRequire the use of the RxJS Tools Babel macro.πŸ”§βŒ
no-async-subscribeDisallow passing async functions to subscribe.βœ… πŸ”’πŸ’­
no-compatDisallow the rxjs-compat package.❌
no-connectableDisallow operators that return connectable observables.πŸ’­
no-createDisallow the static Observable.create function.βœ… πŸ”’πŸ’­
no-cyclic-actionDisallow cyclic actions in effects and epics.πŸ’­
no-explicit-genericsDisallow unnecessary explicit generic type arguments.
no-exposed-subjectsDisallow public and protected subjects.πŸ”’πŸ’­
no-finnishDisallow Finnish notation.πŸ’­
no-floating-observablesRequire Observables to be handled appropriately.πŸ”’πŸ’­
no-ignored-default-valueDisallow using firstValueFrom, lastValueFrom, first, and last without specifying a default value.πŸ”’πŸ’­
no-ignored-errorDisallow calling subscribe without specifying an error handler.πŸ”’πŸ’­
no-ignored-notifierDisallow observables not composed from the repeatWhen or retryWhen notifier.βœ… πŸ”’πŸ’­
no-ignored-replay-bufferDisallow using ReplaySubject, publishReplay or shareReplay without specifying the buffer size.βœ… πŸ”’
no-ignored-subscribeDisallow calling subscribe without specifying arguments.πŸ’­
no-ignored-subscriptionDisallow ignoring the subscription returned by subscribe.πŸ’­
no-ignored-takewhile-valueDisallow ignoring the value within takeWhile.βœ… πŸ”’
no-implicit-any-catchDisallow implicit any error parameters in catchError operators.βœ… πŸ”’πŸ”§πŸ’‘πŸ’­
no-indexDisallow importing index modules.βœ… πŸ”’
no-internalDisallow importing internal modules.βœ… πŸ”’πŸ”§πŸ’‘
no-misused-observablesDisallow Observables in places not designed to handle them.πŸ”’πŸ’­
no-nested-subscribeDisallow calling subscribe within a subscribe callback.βœ… πŸ”’πŸ’­
no-redundant-notifyDisallow sending redundant notifications from completed or errored observables.βœ… πŸ”’πŸ’­
no-sharereplayDisallow unsafe shareReplay usage.βœ… πŸ”’
no-subclassDisallow subclassing RxJS classes.πŸ”’πŸ’­
no-subject-unsubscribeDisallow calling the unsubscribe method of subjects.βœ… πŸ”’πŸ’­
no-subject-valueDisallow accessing the value property of a BehaviorSubject instance.πŸ’­
no-subscribe-handlersDisallow passing handlers to subscribe.πŸ’­
no-subscribe-in-pipeDisallow calling of subscribe within any RxJS operator inside a pipe.βœ… πŸ”’πŸ’­
no-tapDisallow the tap operator.❌
no-topromiseDisallow use of the toPromise method.βœ… πŸ”’πŸ’‘πŸ’­
no-unbound-methodsDisallow passing unbound methods.βœ… πŸ”’πŸ’­
no-unsafe-catchDisallow unsafe catchError usage in effects and epics.πŸ’­
no-unsafe-firstDisallow unsafe first/take usage in effects and epics.πŸ’­
no-unsafe-subject-nextDisallow unsafe optional next calls.βœ… πŸ”’πŸ’­
no-unsafe-switchmapDisallow unsafe switchMap usage in effects and epics.πŸ’­
no-unsafe-takeuntilDisallow applying operators after takeUntil.βœ… πŸ”’πŸ’­
prefer-observerDisallow passing separate handlers to subscribe and tap.βœ… πŸ”’πŸ”§πŸ’‘πŸ’­
prefer-root-operatorsDisallow importing operators from rxjs/operators.βœ… πŸ”’πŸ”§πŸ’‘
suffix-subjectsEnforce the use of a suffix in subject identifiers.πŸ’­
throw-errorEnforce passing only Error values to throwError.βœ… πŸ”’πŸ’­
0.7.0

3 months ago

0.6.2

5 months ago

0.6.1

6 months ago

0.6.0

6 months ago

0.5.1

6 months ago

0.5.0

7 months ago

0.4.1

7 months ago

0.3.2

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.3.1

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.4

7 months ago

0.1.0

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago