Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 47 additions & 45 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rules/no-async-subscribe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow passing `async` functions to `subscribe` (`rxjs-x/no-async-subscribe`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-create.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow the static `Observable.create` function (`rxjs-x/no-create`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-explicit-generics.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow unnecessary explicit generic type arguments (`rxjs-x/no-explicit-generics`)

💼 This rule is enabled in the 🔒 `strict` config.

<!-- end auto-generated rule header -->

This rule prevents the use of explicit type arguments when the type arguments can be inferred.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-exposed-subjects.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow public and protected subjects (`rxjs-x/no-exposed-subjects`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-ignored-default-value.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow using `firstValueFrom`, `lastValueFrom`, `first`, and `last` without specifying a default value (`rxjs-x/no-ignored-default-value`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-ignored-error.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow calling `subscribe` without specifying an error handler (`rxjs-x/no-ignored-error`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-ignored-notifier.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier (`rxjs-x/no-ignored-notifier`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-ignored-observable.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow ignoring observables returned by functions (`rxjs-x/no-ignored-observable`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-ignored-replay-buffer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size (`rxjs-x/no-ignored-replay-buffer`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-ignored-takewhile-value.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow ignoring the value within `takeWhile` (`rxjs-x/no-ignored-takewhile-value`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-implicit-any-catch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow implicit `any` error parameters in `catchError` operators (`rxjs-x/no-implicit-any-catch`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow importing index modules (`rxjs-x/no-index`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-internal.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow importing internal modules (`rxjs-x/no-internal`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-nested-subscribe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow calling `subscribe` within a `subscribe` callback (`rxjs-x/no-nested-subscribe`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-redundant-notify.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow sending redundant notifications from completed or errored observables (`rxjs-x/no-redundant-notify`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-sharereplay.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unsafe `shareReplay` usage (`rxjs-x/no-sharereplay`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

<!-- end auto-generated rule header -->

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-subclass.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow subclassing RxJS classes (`rxjs-x/no-subclass`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-subject-unsubscribe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow calling the `unsubscribe` method of subjects (`rxjs-x/no-subject-unsubscribe`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-topromise.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow use of the `toPromise` method (`rxjs-x/no-topromise`)

💼 This rule is enabled in the 🔒 `strict` config.

💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unbound-methods.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow passing unbound methods (`rxjs-x/no-unbound-methods`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsafe-subject-next.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow unsafe optional `next` calls (`rxjs-x/no-unsafe-subject-next`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unsafe-takeuntil.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Disallow applying operators after `takeUntil` (`rxjs-x/no-unsafe-takeuntil`)

💼 This rule is enabled in the ✅ `recommended` config.
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

Expand Down
6 changes: 6 additions & 0 deletions docs/rules/prefer-observer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow passing separate handlers to `subscribe` and `tap` (`rxjs-x/prefer-observer`)

💼 This rule is enabled in the 🔒 `strict` config.

🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
Expand Down Expand Up @@ -46,3 +48,7 @@ This rule accepts a single option which is an object with an `allowNext` propert
]
}
```

## Further reading

- [Subscribe Arguments](https://rxjs.dev/deprecations/subscribe-arguments)
2 changes: 2 additions & 0 deletions docs/rules/prefer-root-operators.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow importing operators from `rxjs/operators` (`rxjs-x/prefer-root-operators`)

💼 This rule is enabled in the 🔒 `strict` config.

🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).

<!-- end auto-generated rule header -->
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/throw-error.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Enforce passing only `Error` values to `throwError` (`rxjs-x/throw-error`)

💼 This rule is enabled in the 🔒 `strict` config.

💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).

<!-- end auto-generated rule header -->
Expand Down
6 changes: 4 additions & 2 deletions src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { TSESLint } from '@typescript-eslint/utils';

export const createRecommendedConfig = (plugin: TSESLint.FlatConfig.Plugin) => ({
export const createRecommendedConfig = (
plugin: TSESLint.FlatConfig.Plugin,
) => ({
plugins: {
'rxjs-x': plugin,
},
Expand All @@ -15,7 +17,7 @@ export const createRecommendedConfig = (plugin: TSESLint.FlatConfig.Plugin) => (
'rxjs-x/no-internal': 'error',
'rxjs-x/no-nested-subscribe': 'error',
'rxjs-x/no-redundant-notify': 'error',
'rxjs-x/no-sharereplay': ['error', { allowConfig: true }],
'rxjs-x/no-sharereplay': 'error',
'rxjs-x/no-subject-unsubscribe': 'error',
'rxjs-x/no-unbound-methods': 'error',
'rxjs-x/no-unsafe-subject-next': 'error',
Expand Down
41 changes: 41 additions & 0 deletions src/configs/strict.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TSESLint } from '@typescript-eslint/utils';

export const createStrictConfig = (
plugin: TSESLint.FlatConfig.Plugin,
) => ({
plugins: {
'rxjs-x': plugin,
},
rules: {
'rxjs-x/no-async-subscribe': 'error',
'rxjs-x/no-create': 'error',
'rxjs-x/no-explicit-generics': 'error',
'rxjs-x/no-exposed-subjects': 'error',
'rxjs-x/no-ignored-default-value': 'error',
'rxjs-x/no-ignored-error': 'error',
'rxjs-x/no-ignored-notifier': 'error',
'rxjs-x/no-ignored-observable': 'error',
'rxjs-x/no-ignored-replay-buffer': 'error',
'rxjs-x/no-ignored-takewhile-value': 'error',
'rxjs-x/no-implicit-any-catch': ['error', {
allowExplicitAny: false as const,
}],
'rxjs-x/no-index': 'error',
'rxjs-x/no-internal': 'error',
'rxjs-x/no-nested-subscribe': 'error',
'rxjs-x/no-redundant-notify': 'error',
'rxjs-x/no-sharereplay': 'error',
'rxjs-x/no-subclass': 'error',
'rxjs-x/no-subject-unsubscribe': 'error',
'rxjs-x/no-topromise': 'error',
'rxjs-x/no-unbound-methods': 'error',
'rxjs-x/no-unsafe-subject-next': 'error',
'rxjs-x/no-unsafe-takeuntil': 'error',
'rxjs-x/prefer-observer': 'error',
'rxjs-x/prefer-root-operators': 'error',
'rxjs-x/throw-error': ['error', {
allowThrowingAny: false as const,
allowThrowingUnknown: false as const,
}],
},
} satisfies TSESLint.FlatConfig.Config);
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TSESLint } from '@typescript-eslint/utils';
import { name, version } from '../package.json';
import { createRecommendedConfig } from './configs/recommended';
import { createStrictConfig } from './configs/strict';

import { banObservablesRule } from './rules/ban-observables';
import { banOperatorsRule } from './rules/ban-operators';
Expand Down Expand Up @@ -99,6 +100,7 @@ const rxjsX = {
...plugin,
configs: {
recommended: createRecommendedConfig(plugin),
strict: createStrictConfig(plugin),
},
} satisfies TSESLint.FlatConfig.Plugin;

Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-async-subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const noAsyncSubscribeRule = ruleCreator({
meta: {
docs: {
description: 'Disallow passing `async` functions to `subscribe`.',
recommended: true,
recommended: 'recommended',
requiresTypeChecking: true,
},
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const noCreateRule = ruleCreator({
meta: {
docs: {
description: 'Disallow the static `Observable.create` function.',
recommended: true,
recommended: 'recommended',
requiresTypeChecking: true,
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-explicit-generics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const noExplicitGenericsRule = ruleCreator({
meta: {
docs: {
description: 'Disallow unnecessary explicit generic type arguments.',
recommended: 'strict',
},
messages: {
forbidden: 'Explicit generic type arguments are forbidden.',
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-exposed-subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const noExposedSubjectsRule = ruleCreator({
meta: {
docs: {
description: 'Disallow public and protected subjects.',
recommended: 'strict',
requiresTypeChecking: true,
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-ignored-default-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const noIgnoredDefaultValueRule = ruleCreator({
meta: {
docs: {
description: 'Disallow using `firstValueFrom`, `lastValueFrom`, `first`, and `last` without specifying a default value.',
recommended: 'strict',
requiresTypeChecking: true,
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-ignored-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const noIgnoredErrorRule = ruleCreator({
docs: {
description:
'Disallow calling `subscribe` without specifying an error handler.',
recommended: 'strict',
requiresTypeChecking: true,
},
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-ignored-notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const noIgnoredNotifierRule = ruleCreator({
docs: {
description:
'Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.',
recommended: true,
recommended: 'recommended',
requiresTypeChecking: true,
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-ignored-observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const noIgnoredObservableRule = ruleCreator({
meta: {
docs: {
description: 'Disallow ignoring observables returned by functions.',
recommended: 'strict',
requiresTypeChecking: true,
},
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-ignored-replay-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const noIgnoredReplayBufferRule = ruleCreator({
docs: {
description:
'Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.',
recommended: true,
recommended: 'recommended',
},
messages: {
forbidden: 'Ignoring the buffer size is forbidden.',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-ignored-takewhile-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const noIgnoredTakewhileValueRule = ruleCreator({
meta: {
docs: {
description: 'Disallow ignoring the value within `takeWhile`.',
recommended: true,
recommended: 'recommended',
},
messages: {
forbidden: 'Ignoring the value within takeWhile is forbidden.',
Expand Down
7 changes: 6 additions & 1 deletion src/rules/no-implicit-any-catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ export const noImplicitAnyCatchRule = ruleCreator({
docs: {
description:
'Disallow implicit `any` error parameters in `catchError` operators.',
recommended: true,
recommended: {
recommended: true,
strict: [{
allowExplicitAny: false,
}],
},
requiresTypeChecking: true,
},
fixable: 'code',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const noIndexRule = ruleCreator({
meta: {
docs: {
description: 'Disallow importing index modules.',
recommended: true,
recommended: 'recommended',
},
messages: {
forbidden: 'RxJS imports from index modules are forbidden.',
Expand Down
Loading