Skip to content

Commit 6f20094

Browse files
committed
docs: Complete rule docs.
1 parent f1f86a0 commit 6f20094

40 files changed

+989
-116
lines changed

README.md

+38-38
Original file line numberDiff line numberDiff line change
@@ -56,41 +56,41 @@ The package includes the following rules:
5656

5757
| Rule | Description | Recommended |
5858
| --- | --- | --- |
59-
| [`ban-observables`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/ban-observables.ts) | Forbids the use of banned observables. | TBD |
60-
| [`ban-operators`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/ban-operators.ts) | Forbids the use of banned operators. | TBD |
61-
| [`finnish`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/finnish.ts) | Enforces the use of Finnish notation. | TBD |
62-
| [`just`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/just.ts) | Enforces the use of a `just` alias for `of`. | TBD |
63-
| [`no-async-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-async-subscribe.ts) | Forbids passing `async` functions to `subscribe`. | TBD |
64-
| [`no-compat`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-compat.ts) | Forbids importation from locations that depend upon `rxjs-compat`. | TBD |
65-
| [`no-connectable`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-connectable.ts) | Forbids operators that return connectable observables. | TBD |
66-
| [`no-create`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-create.ts) | Forbids the calling of `Observable.create`. | TBD |
67-
| [`no-explicit-generics`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-explicit-generics.ts) | Forbids explicit generic type arguments. | TBD |
68-
| [`no-exposed-subjects`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-exposed-subjects.ts) | Forbids exposed (i.e. non-private) subjects. | TBD |
69-
| [`no-finnish`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-finnish.ts) | Forbids the use of Finnish notation. | TBD |
70-
| [`no-ignored-error`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-error.ts) | Forbids the calling of `subscribe` without specifying an error handler. | TBD |
71-
| [`no-ignored-notifier`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-notifier.ts) | Forbids observables not composed from the `repeatWhen` or `retryWhen` notifier. | TBD |
72-
| [`no-ignored-observable`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-observable.ts) | Forbids the ignoring of observables returned by functions. | TBD |
73-
| [`no-ignored-replay-buffer`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-replay-buffer.ts) | Forbids using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size. | TBD |
74-
| [`no-ignored-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-subscribe.ts) | Forbids the calling of `subscribe` without specifying arguments. | TBD |
75-
| [`no-ignored-subscription`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-subscription.ts) | Forbids ignoring the subscription returned by `subscribe`. | TBD |
76-
| [`no-ignored-takewhile-value`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-ignored-takewhile-value.ts) | Forbids ignoring the value within `takeWhile`. | TBD |
77-
| [`no-implicit-any-catch`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-implicit-any-catch.ts) | Like the [`no-implicit-any-catch` rule](https://github.com/typescript-eslint/typescript-eslint/pull/2202) in `@typescript-eslint/eslint-plugin`, but for the `catchError` operator instead of `catch` clauses. | TBD |
78-
| [`no-index`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-index.ts) | Forbids the importation from index modules - for the reason, see [this issue](https://github.com/ReactiveX/rxjs/issues/4230). | TBD |
79-
| [`no-internal`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-internal.ts) | Forbids the importation of internals. | TBD |
80-
| [`no-nested-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-nested-subscribe.ts) | Forbids the calling of `subscribe` within a `subscribe` callback. | TBD |
81-
| [`no-redundant-notify`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-redundant-notify.ts) | Disallows redundant notifications from completed or errored observables. | TBD |
82-
| [`no-sharereplay`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-sharereplay.ts) | Forbids using the `shareReplay` operator. | TBD |
83-
| [`no-subclass`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-subclass.ts) | Forbids subclassing RxJS classes. | TBD |
84-
| [`no-subject-unsubscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-subject-unsubscribe.ts) | Forbids calling the `unsubscribe` method of a subject instance. | TBD |
85-
| [`no-subject-value`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-subject-value.ts) | Forbids accessing the `value` property of a `BehaviorSubject` instance. | TBD |
86-
| [`no-tap`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-tap.ts) | Forbids the use of the `tap` operator. | TBD |
87-
| [`no-topromise`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-topromise.ts) | Forbids the use of the `toPromise` method. | TBD |
88-
| [`no-unbound-methods`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unbound-methods.ts) | Forbids the passing of unbound methods. | TBD |
89-
| [`no-unsafe-catch`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-catch.ts) | Forbids unsafe `catchError` usage in effects and epics. | TBD |
90-
| [`no-unsafe-first`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-first.ts) | Forbids unsafe `first`/`take` usage in effects and epics. | TBD |
91-
| [`no-unsafe-subject-next`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-subject-next.ts) | Forbids unsafe optional `next` calls. | TBD |
92-
| [`no-unsafe-switchmap`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-switchmap.ts) | Forbids unsafe `switchMap` usage in effects and epics. | TBD |
93-
| [`no-unsafe-takeuntil`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-takeuntil.ts) | Forbids the application of operators after `takeUntil`. | TBD |
94-
| [`prefer-observer`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/prefer-observer.ts) | Forbids the passing separate callbacks to `subscribe` and `tap`. | TBD |
95-
| [`suffix-subjects`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/suffix-subjects.ts) | Enforces the use of a suffix in subject identifiers. | TBD |
96-
| [`throw-error`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/throw-error.ts) | Enforces the passing of `Error` values to error notifications. | TBD |
59+
| [`ban-observables`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/ban-observables.md) | Forbids the use of banned observables. | TBD |
60+
| [`ban-operators`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/ban-operators.md) | Forbids the use of banned operators. | TBD |
61+
| [`finnish`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/finnish.md) | Enforces the use of Finnish notation. | TBD |
62+
| [`just`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/just.md) | Enforces the use of a `just` alias for `of`. | TBD |
63+
| [`no-async-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-async-subscribe.md) | Forbids passing `async` functions to `subscribe`. | TBD |
64+
| [`no-compat`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-compat.md) | Forbids importation from locations that depend upon `rxjs-compat`. | TBD |
65+
| [`no-connectable`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-connectable.md) | Forbids operators that return connectable observables. | TBD |
66+
| [`no-create`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-create.md) | Forbids the calling of `Observable.create`. | TBD |
67+
| [`no-explicit-generics`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-explicit-generics.md) | Forbids explicit generic type arguments. | TBD |
68+
| [`no-exposed-subjects`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-exposed-subjects.md) | Forbids exposed (i.e. non-private) subjects. | TBD |
69+
| [`no-finnish`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-finnish.md) | Forbids the use of Finnish notation. | TBD |
70+
| [`no-ignored-error`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-error.md) | Forbids the calling of `subscribe` without specifying an error handler. | TBD |
71+
| [`no-ignored-notifier`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-notifier.md) | Forbids observables not composed from the `repeatWhen` or `retryWhen` notifier. | TBD |
72+
| [`no-ignored-observable`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-observable.md) | Forbids the ignoring of observables returned by functions. | TBD |
73+
| [`no-ignored-replay-buffer`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-replay-buffer.md) | Forbids using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size. | TBD |
74+
| [`no-ignored-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-subscribe.md) | Forbids the calling of `subscribe` without specifying arguments. | TBD |
75+
| [`no-ignored-subscription`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-subscription.md) | Forbids ignoring the subscription returned by `subscribe`. | TBD |
76+
| [`no-ignored-takewhile-value`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-ignored-takewhile-value.md) | Forbids ignoring the value within `takeWhile`. | TBD |
77+
| [`no-implicit-any-catch`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-implicit-any-catch.md) | Like the [`no-implicit-any-catch` rule](https://github.com/typescript-eslint/typescript-eslint/pull/2202) in `@typescript-eslint/eslint-plugin`, but for the `catchError` operator instead of `catch` clauses. | TBD |
78+
| [`no-index`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-index.md) | Forbids the importation from index modules - for the reason, see [this issue](https://github.com/ReactiveX/rxjs/issues/4230). | TBD |
79+
| [`no-internal`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-internal.md) | Forbids the importation of internals. | TBD |
80+
| [`no-nested-subscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-nested-subscribe.md) | Forbids the calling of `subscribe` within a `subscribe` callback. | TBD |
81+
| [`no-redundant-notify`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-redundant-notify.md) | Disallows redundant notifications from completed or errored observables. | TBD |
82+
| [`no-sharereplay`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-sharereplay.md) | Forbids using the `shareReplay` operator. | TBD |
83+
| [`no-subclass`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-subclass.md) | Forbids subclassing RxJS classes. | TBD |
84+
| [`no-subject-unsubscribe`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-subject-unsubscribe.md) | Forbids calling the `unsubscribe` method of a subject instance. | TBD |
85+
| [`no-subject-value`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-subject-value.md) | Forbids accessing the `value` property of a `BehaviorSubject` instance. | TBD |
86+
| [`no-tap`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-tap.md) | Forbids the use of the `tap` operator. | TBD |
87+
| [`no-topromise`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-topromise.md) | Forbids the use of the `toPromise` method. | TBD |
88+
| [`no-unbound-methods`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unbound-methods.md) | Forbids the passing of unbound methods. | TBD |
89+
| [`no-unsafe-catch`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unsafe-catch.md) | Forbids unsafe `catchError` usage in effects and epics. | TBD |
90+
| [`no-unsafe-first`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unsafe-first.md) | Forbids unsafe `first`/`take` usage in effects and epics. | TBD |
91+
| [`no-unsafe-subject-next`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unsafe-subject-next.md) | Forbids unsafe optional `next` calls. | TBD |
92+
| [`no-unsafe-switchmap`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unsafe-switchmap.md) | Forbids unsafe `switchMap` usage in effects and epics. | TBD |
93+
| [`no-unsafe-takeuntil`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/no-unsafe-takeuntil.md) | Forbids the application of operators after `takeUntil`. | TBD |
94+
| [`prefer-observer`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/prefer-observer.md) | Forbids the passing separate callbacks to `subscribe` and `tap`. | TBD |
95+
| [`suffix-subjects`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/suffix-subjects.md) | Enforces the use of a suffix in subject identifiers. | TBD |
96+
| [`throw-error`](https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/throw-error.md) | Enforces the passing of `Error` values to error notifications. | TBD |

docs/rules/ban-observables.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
# ban-observables
1+
# Avoid banned observable creators (`ban-observables`)
22

3-
TK
3+
This rule can be configured so that developers can ban any observable creators they want to avoid in their project.
4+
5+
## Options
6+
7+
This rule accepts a single option which is an object the keys of which are the names of observable factory functions and the values are either booleans or strings containing the explanation for the ban.
8+
9+
The following configuration bans `partition` and `onErrorResumeNext`:
10+
11+
```json
12+
{
13+
"rxjs/ban-observables": [
14+
"error",
15+
{
16+
"partition": true,
17+
"of": false,
18+
"onErrorResumeNext": "What is this? Visual Basic?"
19+
}
20+
]
21+
}
22+
```

docs/rules/ban-operators.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
# ban-operators
1+
# Avoid banned operators (`ban-operators`)
22

3-
TK
3+
This rule can be configured so that developers can ban any operators they want to avoid in their project.
4+
5+
## Options
6+
7+
This rule accepts a single option which is an object the keys of which are the names of operators and the values are either booleans or strings containing the explanation for the ban.
8+
9+
The following configuration bans `ajax` and `onErrorResumeNext`:
10+
11+
```json
12+
{
13+
"rxjs/ban-operators": [
14+
"error",
15+
{
16+
"partition": true,
17+
"map": false,
18+
"onErrorResumeNext": "What is this? Visual Basic?"
19+
}
20+
]
21+
}

docs/rules/finnish.md

+49-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1-
# finnish
1+
# Use Finnish notation (`finnish`)
22

3-
TK
3+
This rule enforces the use of Finnish notation - i.e. the `$` suffix.
4+
5+
## Rule details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
const answers = of(42, 54);
11+
```
12+
13+
Examples of **correct** code for this rule:
14+
15+
```ts
16+
const answer$ = of(42, 54);
17+
```
18+
19+
## Options
20+
21+
This rule accepts a single option which is an object with properties that determine whether Finnish notation is enforced for `functions`, `methods`, `parameters`, `properties` and `variables`. It also contains `names` and `types` properties that determine whether of not Finnish notation is to be enforced for specific names or types.
22+
23+
The default (Angular-friendly) configuration looks like this:
24+
25+
```json
26+
{
27+
"rxjs/finnish": [
28+
"error",
29+
{
30+
"functions": true,
31+
"methods": true,
32+
"names": {
33+
"^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$": false
34+
},
35+
"parameters": true,
36+
"properties": true,
37+
"types": {
38+
"^EventEmitter$": false
39+
},
40+
"variables": true
41+
}
42+
]
43+
}
44+
```
45+
46+
The properties in the options object are themselves optional; they do not all have to be specified.
47+
48+
## Further reading
49+
50+
- [Observables and Finnish Notation](https://medium.com/@benlesh/observables-and-finnish-notation-df8356ed1c9b)

docs/rules/just.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
# just
1+
# Use `just` instead of `of` (`just`)
22

3-
TK
3+
This rule enforces the use of `just` instead of `of`. Some other languages with Rx implementations use the former and this rule is for developers who have that preference.
4+
5+
## Options
6+
7+
This rule has no options.
8+
9+
## Further reading
10+
11+
- [Rename `of` to `just`](https://github.com/ReactiveX/rxjs/issues/3747)

docs/rules/macro.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
# macro
1+
# Use the RxJS Tools macro (`macro`)
22

3-
TK
3+
This rule ensures that modules that import `rxjs` also import the Babel macro for [RxJS Tools](https://rxjs.tools).
4+
5+
## Options
6+
7+
This rule has no options.

docs/rules/no-async-subscribe.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
# no-async-subscribe
1+
# Avoid passing async functions to `subscribe` (`no-async-subscribe`)
22

3-
TK
3+
This rule effects failures if async functions are passed to `subscribe`.
4+
5+
## Rule details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
import { of } from "rxjs";
11+
of(42).subscribe(async () => {console.log(value));
12+
```
13+
14+
Examples of **correct** code for this rule:
15+
16+
```ts
17+
import { of } from "rxjs";
18+
of(42).subscribe(() => console.log(value));
19+
```
20+
21+
## Options
22+
23+
This rule has no options.

docs/rules/no-compat.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
# no-compat
1+
# Avoid the `rxjs-compat` package (`no-compat`)
22

3-
TK
3+
This rule prevents the use of `rxjs-compat`.
4+
5+
## Options
6+
7+
This rule has no options.
8+
9+
## Further reading
10+
11+
- [Backwards compatibility](https://github.com/ReactiveX/rxjs/blob/a6590e971969c736a15b77154dabbc22275aa0d5/docs_app/content/guide/v6/migration.md#backwards-compatibility)

docs/rules/no-connectable.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
# no-connectable
1+
# Avoid connectable observables (`no-connectable`)
22

3-
TK
3+
This rule prevents the use of connectable observables.
4+
5+
## Options
6+
7+
This rule has no options.

docs/rules/no-create.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
# no-create
1+
# Avoid the static `create` function (`no-create`)
22

3-
TK
3+
This rule prevents the use of the static `create` function in `Observable`. Developers should use `new` and the constructor instead.
4+
5+
## Options
6+
7+
This rule has no options.

docs/rules/no-explicit-generics.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
# no-explicit-generics
1+
# Avoid unnecessary explicit type arguments (`no-explicit-generics`)
22

3-
TK
3+
This rule prevents the use of explicit type arguments when the type arguments can be inferred.
4+
5+
## Rule details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
import { BehaviorSubject } from "rxjs";
11+
const subject = new BehaviorSubject<number>(42);
12+
```
13+
14+
Examples of **correct** code for this rule:
15+
16+
```ts
17+
import { BehaviorSubject } from "rxjs";
18+
const subject = new BehaviorSubject(42);
19+
```
20+
21+
## Options
22+
23+
This rule has no options.

0 commit comments

Comments
 (0)