Skip to content

Commit ada5d55

Browse files
feat(recommended)!: add four rules to recommended (#56)
BREAKING CHANGE: RxJS ^7.2.0 is required. BREAKING CHANGE: `recommended` configuration had 4 rules added to it. See full changelog for details. Resolves #35 . - `no-topromise`: `toPromise()` was deprecated by RxJS, so this will be very useful for helping developers migrate to one of the two manual editor suggestions (`lastValueFrom` or `firstValueFrom`). - `prefer-observer`: RxJS deprecated non-observer object subscribes, so this will help migrate. - `prefer-root-operators`: RxJS moved operators to root in 7.2.0 and deprecated the old site, so this will help migrate. - This change requires bumping the RxJS peer dependency to 7.2.0 because 7.0.0 doesn't export the operators from root. - `throw-error`: This rule will rarely be triggered because it was recently changed to only apply to the static creation function `throwError()`. But in those rare cases, it should always be enforced, similar to `no-implicit-any-catch`.
1 parent 1268dc8 commit ada5d55

13 files changed

+42
-44
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ The package includes the following rules.
108108
| [no-subject-value](docs/rules/no-subject-value.md) | Disallow accessing the `value` property of a `BehaviorSubject` instance. | | | | 💭 | |
109109
| [no-subscribe-handlers](docs/rules/no-subscribe-handlers.md) | Disallow passing handlers to `subscribe`. | | | | 💭 | |
110110
| [no-tap](docs/rules/no-tap.md) | Disallow the `tap` operator. | | | | ||
111-
| [no-topromise](docs/rules/no-topromise.md) | Disallow use of the `toPromise` method. | 🔒 | | 💡 | 💭 | |
111+
| [no-topromise](docs/rules/no-topromise.md) | Disallow use of the `toPromise` method. | ✅ 🔒 | | 💡 | 💭 | |
112112
| [no-unbound-methods](docs/rules/no-unbound-methods.md) | Disallow passing unbound methods. | ✅ 🔒 | | | 💭 | |
113113
| [no-unsafe-catch](docs/rules/no-unsafe-catch.md) | Disallow unsafe `catchError` usage in effects and epics. | | | | 💭 | |
114114
| [no-unsafe-first](docs/rules/no-unsafe-first.md) | Disallow unsafe `first`/`take` usage in effects and epics. | | | | 💭 | |
115115
| [no-unsafe-subject-next](docs/rules/no-unsafe-subject-next.md) | Disallow unsafe optional `next` calls. | ✅ 🔒 | | | 💭 | |
116116
| [no-unsafe-switchmap](docs/rules/no-unsafe-switchmap.md) | Disallow unsafe `switchMap` usage in effects and epics. | | | | 💭 | |
117117
| [no-unsafe-takeuntil](docs/rules/no-unsafe-takeuntil.md) | Disallow applying operators after `takeUntil`. | ✅ 🔒 | | | 💭 | |
118-
| [prefer-observer](docs/rules/prefer-observer.md) | Disallow passing separate handlers to `subscribe` and `tap`. | 🔒 | 🔧 | 💡 | 💭 | |
119-
| [prefer-root-operators](docs/rules/prefer-root-operators.md) | Disallow importing operators from `rxjs/operators`. | 🔒 | 🔧 | 💡 | | |
118+
| [prefer-observer](docs/rules/prefer-observer.md) | Disallow passing separate handlers to `subscribe` and `tap`. | ✅ 🔒 | 🔧 | 💡 | 💭 | |
119+
| [prefer-root-operators](docs/rules/prefer-root-operators.md) | Disallow importing operators from `rxjs/operators`. | ✅ 🔒 | 🔧 | 💡 | | |
120120
| [suffix-subjects](docs/rules/suffix-subjects.md) | Enforce the use of a suffix in subject identifiers. | | | | 💭 | |
121-
| [throw-error](docs/rules/throw-error.md) | Enforce passing only `Error` values to `throwError`. | 🔒 | | | 💭 | |
121+
| [throw-error](docs/rules/throw-error.md) | Enforce passing only `Error` values to `throwError`. | ✅ 🔒 | | | 💭 | |
122122

123123
<!-- end auto-generated rules list -->

docs/rules/no-topromise.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow use of the `toPromise` method (`rxjs-x/no-topromise`)
22

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

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

docs/rules/prefer-observer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow passing separate handlers to `subscribe` and `tap` (`rxjs-x/prefer-observer`)
22

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

55
🔧💡 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).
66

docs/rules/prefer-root-operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Disallow importing operators from `rxjs/operators` (`rxjs-x/prefer-root-operators`)
22

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

55
🔧💡 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).
66

docs/rules/throw-error.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforce passing only `Error` values to `throwError` (`rxjs-x/throw-error`)
22

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

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"peerDependencies": {
6464
"eslint": "^8.57.0 || ^9.0.0",
65-
"rxjs": ">=7.0.0",
65+
"rxjs": ">=7.2.0",
6666
"typescript": ">=4.7.4"
6767
},
6868
"peerDependenciesMeta": {

src/configs/recommended.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ export const createRecommendedConfig = (
1919
'rxjs-x/no-redundant-notify': 'error',
2020
'rxjs-x/no-sharereplay': 'error',
2121
'rxjs-x/no-subject-unsubscribe': 'error',
22+
'rxjs-x/no-topromise': 'error',
2223
'rxjs-x/no-unbound-methods': 'error',
2324
'rxjs-x/no-unsafe-subject-next': 'error',
2425
'rxjs-x/no-unsafe-takeuntil': 'error',
26+
'rxjs-x/prefer-observer': 'error',
27+
'rxjs-x/prefer-root-operators': 'error',
28+
'rxjs-x/throw-error': 'error',
2529
},
2630
} satisfies TSESLint.FlatConfig.Config);

src/rules/no-topromise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const noTopromiseRule = ruleCreator({
77
meta: {
88
docs: {
99
description: 'Disallow use of the `toPromise` method.',
10-
recommended: 'strict',
10+
recommended: 'recommended',
1111
requiresTypeChecking: true,
1212
},
1313
hasSuggestions: true,

src/rules/prefer-observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const preferObserverRule = ruleCreator({
2020
docs: {
2121
description:
2222
'Disallow passing separate handlers to `subscribe` and `tap`.',
23-
recommended: 'strict',
23+
recommended: 'recommended',
2424
requiresTypeChecking: true,
2525
},
2626
fixable: 'code',

src/rules/prefer-root-operators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const preferRootOperatorsRule = ruleCreator({
2222
meta: {
2323
docs: {
2424
description: 'Disallow importing operators from `rxjs/operators`.',
25-
recommended: 'strict',
25+
recommended: 'recommended',
2626
},
2727
fixable: 'code',
2828
hasSuggestions: true,

0 commit comments

Comments
 (0)