eslint-plugin-rxjs-x 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import { TSESLint } from '@typescript-eslint/utils';
2
-
3
- interface RxjsXRuleDocs {
4
- description: string;
5
- recommended?: TSESLint.RuleRecommendation | TSESLint.RuleRecommendationAcrossConfigs<unknown[]>;
6
- requiresTypeChecking?: boolean;
7
- }
2
+ import { ESLint, Rule } from 'eslint';
8
3
 
9
4
  interface ChecksVoidReturnOptions {
10
5
  arguments?: boolean;
@@ -15,12 +10,268 @@ interface ChecksVoidReturnOptions {
15
10
  variables?: boolean;
16
11
  }
17
12
 
13
+ declare const allRules: {
14
+ 'ban-observables': TSESLint.RuleModule<"forbidden", readonly Record<string, string | boolean>[], {
15
+ description: "Disallow banned observable creators.";
16
+ }, TSESLint.RuleListener>;
17
+ 'ban-operators': TSESLint.RuleModule<"forbidden", readonly Record<string, string | boolean>[], {
18
+ description: "Disallow banned operators.";
19
+ requiresTypeChecking: true;
20
+ }, TSESLint.RuleListener>;
21
+ finnish: TSESLint.RuleModule<"shouldBeFinnish" | "shouldNotBeFinnish", readonly {
22
+ functions?: boolean;
23
+ methods?: boolean;
24
+ names?: Record<string, boolean>;
25
+ parameters?: boolean;
26
+ properties?: boolean;
27
+ strict?: boolean;
28
+ types?: Record<string, boolean>;
29
+ variables?: boolean;
30
+ }[], {
31
+ description: "Enforce Finnish notation.";
32
+ requiresTypeChecking: true;
33
+ }, TSESLint.RuleListener>;
34
+ just: TSESLint.RuleModule<"forbidden", [], {
35
+ description: "Require the use of `just` instead of `of`.";
36
+ }, TSESLint.RuleListener>;
37
+ macro: TSESLint.RuleModule<"macro", [], {
38
+ description: "Require the use of the RxJS Tools Babel macro.";
39
+ }, TSESLint.RuleListener>;
40
+ 'no-async-subscribe': TSESLint.RuleModule<"forbidden", [], {
41
+ description: "Disallow passing `async` functions to `subscribe`.";
42
+ recommended: "recommended";
43
+ requiresTypeChecking: true;
44
+ }, TSESLint.RuleListener>;
45
+ 'no-compat': TSESLint.RuleModule<"forbidden", [], {
46
+ description: "Disallow the `rxjs-compat` package.";
47
+ }, TSESLint.RuleListener>;
48
+ 'no-connectable': TSESLint.RuleModule<"forbidden", [], {
49
+ description: "Disallow operators that return connectable observables.";
50
+ requiresTypeChecking: true;
51
+ }, TSESLint.RuleListener>;
52
+ 'no-create': TSESLint.RuleModule<"forbidden", [], {
53
+ description: "Disallow the static `Observable.create` function.";
54
+ recommended: "recommended";
55
+ requiresTypeChecking: true;
56
+ }, TSESLint.RuleListener>;
57
+ 'no-cyclic-action': TSESLint.RuleModule<"forbidden", readonly {
58
+ observable?: string;
59
+ }[], {
60
+ description: "Disallow cyclic actions in effects and epics.";
61
+ requiresTypeChecking: true;
62
+ }, TSESLint.RuleListener>;
63
+ 'no-explicit-generics': TSESLint.RuleModule<"forbidden", [], {
64
+ description: "Disallow unnecessary explicit generic type arguments.";
65
+ }, TSESLint.RuleListener>;
66
+ 'no-exposed-subjects': TSESLint.RuleModule<"forbidden" | "forbiddenAllowProtected", readonly {
67
+ allowProtected?: boolean;
68
+ }[], {
69
+ description: "Disallow public and protected subjects.";
70
+ recommended: "strict";
71
+ requiresTypeChecking: true;
72
+ }, TSESLint.RuleListener>;
73
+ 'no-finnish': TSESLint.RuleModule<"forbidden", [], {
74
+ description: "Disallow Finnish notation.";
75
+ requiresTypeChecking: true;
76
+ }, TSESLint.RuleListener>;
77
+ 'no-floating-observables': TSESLint.RuleModule<"forbidden" | "forbiddenNoVoid", readonly {
78
+ ignoreVoid?: boolean;
79
+ }[], {
80
+ description: "Require Observables to be handled appropriately.";
81
+ recommended: "strict";
82
+ requiresTypeChecking: true;
83
+ }, TSESLint.RuleListener>;
84
+ 'no-ignored-default-value': TSESLint.RuleModule<"forbidden", [], {
85
+ description: "Disallow using `firstValueFrom`, `lastValueFrom`, `first`, and `last` without specifying a default value.";
86
+ recommended: "strict";
87
+ requiresTypeChecking: true;
88
+ }, TSESLint.RuleListener>;
89
+ 'no-ignored-error': TSESLint.RuleModule<"forbidden", [], {
90
+ description: "Disallow calling `subscribe` without specifying an error handler.";
91
+ recommended: "strict";
92
+ requiresTypeChecking: true;
93
+ }, TSESLint.RuleListener>;
94
+ 'no-ignored-notifier': TSESLint.RuleModule<"forbidden", [], {
95
+ description: "Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.";
96
+ recommended: "recommended";
97
+ requiresTypeChecking: true;
98
+ }, TSESLint.RuleListener>;
99
+ 'no-ignored-replay-buffer': TSESLint.RuleModule<"forbidden", [], {
100
+ description: "Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.";
101
+ recommended: "recommended";
102
+ }, TSESLint.RuleListener>;
103
+ 'no-ignored-subscribe': TSESLint.RuleModule<"forbidden", [], {
104
+ description: "Disallow calling `subscribe` without specifying arguments.";
105
+ requiresTypeChecking: true;
106
+ }, TSESLint.RuleListener>;
107
+ 'no-ignored-subscription': TSESLint.RuleModule<"forbidden", readonly {
108
+ completers?: string[];
109
+ postCompleters?: string[];
110
+ }[], {
111
+ description: "Disallow ignoring the subscription returned by `subscribe`.";
112
+ requiresTypeChecking: true;
113
+ }, TSESLint.RuleListener>;
114
+ 'no-ignored-takewhile-value': TSESLint.RuleModule<"forbidden", [], {
115
+ description: "Disallow ignoring the value within `takeWhile`.";
116
+ recommended: "recommended";
117
+ }, TSESLint.RuleListener>;
118
+ 'no-implicit-any-catch': TSESLint.RuleModule<"explicitAny" | "implicitAny" | "narrowed" | "suggestExplicitUnknown", readonly {
119
+ allowExplicitAny?: boolean;
120
+ }[], {
121
+ description: "Disallow implicit `any` error parameters in `catchError` operators.";
122
+ recommended: {
123
+ recommended: true;
124
+ strict: [{
125
+ allowExplicitAny: boolean;
126
+ }];
127
+ };
128
+ requiresTypeChecking: true;
129
+ }, TSESLint.RuleListener>;
130
+ 'no-index': TSESLint.RuleModule<"forbidden", [], {
131
+ description: "Disallow importing index modules.";
132
+ recommended: "recommended";
133
+ }, TSESLint.RuleListener>;
134
+ 'no-internal': TSESLint.RuleModule<"forbidden" | "suggest", [], {
135
+ description: "Disallow importing internal modules.";
136
+ recommended: "recommended";
137
+ }, TSESLint.RuleListener>;
138
+ 'no-misused-observables': TSESLint.RuleModule<"forbiddenVoidReturnArgument" | "forbiddenVoidReturnAttribute" | "forbiddenVoidReturnInheritedMethod" | "forbiddenVoidReturnProperty" | "forbiddenVoidReturnReturnValue" | "forbiddenVoidReturnVariable" | "forbiddenSpread", readonly {
139
+ checksVoidReturn?: boolean | ChecksVoidReturnOptions;
140
+ checksSpreads?: boolean;
141
+ }[], {
142
+ description: "Disallow Observables in places not designed to handle them.";
143
+ recommended: "strict";
144
+ requiresTypeChecking: true;
145
+ }, TSESLint.RuleListener>;
146
+ 'no-nested-subscribe': TSESLint.RuleModule<"forbidden", [], {
147
+ description: "Disallow calling `subscribe` within a `subscribe` callback.";
148
+ recommended: "recommended";
149
+ requiresTypeChecking: true;
150
+ }, TSESLint.RuleListener>;
151
+ 'no-redundant-notify': TSESLint.RuleModule<"forbidden", [], {
152
+ description: "Disallow sending redundant notifications from completed or errored observables.";
153
+ recommended: "recommended";
154
+ requiresTypeChecking: true;
155
+ }, TSESLint.RuleListener>;
156
+ 'no-sharereplay': TSESLint.RuleModule<"forbidden" | "forbiddenWithoutConfig", readonly {
157
+ allowConfig?: boolean;
158
+ }[], {
159
+ description: "Disallow unsafe `shareReplay` usage.";
160
+ recommended: "recommended";
161
+ }, TSESLint.RuleListener>;
162
+ 'no-subclass': TSESLint.RuleModule<"forbidden", [], {
163
+ description: "Disallow subclassing RxJS classes.";
164
+ recommended: "strict";
165
+ requiresTypeChecking: true;
166
+ }, TSESLint.RuleListener>;
167
+ 'no-subject-unsubscribe': TSESLint.RuleModule<"forbidden", [], {
168
+ description: "Disallow calling the `unsubscribe` method of subjects.";
169
+ recommended: "recommended";
170
+ requiresTypeChecking: true;
171
+ }, TSESLint.RuleListener>;
172
+ 'no-subject-value': TSESLint.RuleModule<"forbidden", [], {
173
+ description: "Disallow accessing the `value` property of a `BehaviorSubject` instance.";
174
+ requiresTypeChecking: true;
175
+ }, TSESLint.RuleListener>;
176
+ 'no-subscribe-handlers': TSESLint.RuleModule<"forbidden", [], {
177
+ description: "Disallow passing handlers to `subscribe`.";
178
+ requiresTypeChecking: true;
179
+ }, TSESLint.RuleListener>;
180
+ 'no-subscribe-in-pipe': TSESLint.RuleModule<"forbidden", [], {
181
+ description: "Disallow calling of `subscribe` within any RxJS operator inside a `pipe`.";
182
+ recommended: "recommended";
183
+ requiresTypeChecking: true;
184
+ }, TSESLint.RuleListener>;
185
+ 'no-tap': TSESLint.RuleModule<"forbidden", [], {
186
+ description: "Disallow the `tap` operator.";
187
+ }, TSESLint.RuleListener>;
188
+ 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFromWithDefault" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], {
189
+ description: "Disallow use of the `toPromise` method.";
190
+ recommended: "recommended";
191
+ requiresTypeChecking: true;
192
+ }, TSESLint.RuleListener>;
193
+ 'no-unbound-methods': TSESLint.RuleModule<"forbidden", readonly {
194
+ allowTypes?: string[];
195
+ }[], {
196
+ description: "Disallow passing unbound methods.";
197
+ recommended: "recommended";
198
+ requiresTypeChecking: true;
199
+ }, TSESLint.RuleListener>;
200
+ 'no-unsafe-catch': TSESLint.RuleModule<"forbidden", readonly {
201
+ observable?: string;
202
+ }[], {
203
+ description: "Disallow unsafe `catchError` usage in effects and epics.";
204
+ requiresTypeChecking: true;
205
+ }, TSESLint.RuleListener>;
206
+ 'no-unsafe-first': TSESLint.RuleModule<"forbidden", readonly {
207
+ observable?: string;
208
+ }[], {
209
+ description: "Disallow unsafe `first`/`take` usage in effects and epics.";
210
+ requiresTypeChecking: true;
211
+ }, TSESLint.RuleListener>;
212
+ 'no-unsafe-subject-next': TSESLint.RuleModule<"forbidden", [], {
213
+ description: "Disallow unsafe optional `next` calls.";
214
+ recommended: "recommended";
215
+ requiresTypeChecking: true;
216
+ }, TSESLint.RuleListener>;
217
+ 'no-unsafe-switchmap': TSESLint.RuleModule<"forbidden", readonly {
218
+ allow?: string | string[];
219
+ disallow?: string | string[];
220
+ observable?: string;
221
+ }[], {
222
+ description: "Disallow unsafe `switchMap` usage in effects and epics.";
223
+ requiresTypeChecking: true;
224
+ }, TSESLint.RuleListener>;
225
+ 'no-unsafe-takeuntil': TSESLint.RuleModule<"forbidden", readonly {
226
+ alias?: string[];
227
+ allow?: string[];
228
+ }[], {
229
+ description: "Disallow applying operators after `takeUntil`.";
230
+ recommended: "recommended";
231
+ requiresTypeChecking: true;
232
+ }, TSESLint.RuleListener>;
233
+ 'prefer-observer': TSESLint.RuleModule<"forbidden", readonly {
234
+ allowNext?: boolean;
235
+ }[], {
236
+ description: "Disallow passing separate handlers to `subscribe` and `tap`.";
237
+ recommended: "recommended";
238
+ requiresTypeChecking: true;
239
+ }, TSESLint.RuleListener>;
240
+ 'prefer-root-operators': TSESLint.RuleModule<"forbidden" | "suggest" | "forbiddenWithoutFix", [], {
241
+ description: "Disallow importing operators from `rxjs/operators`.";
242
+ recommended: "recommended";
243
+ }, TSESLint.RuleListener>;
244
+ 'suffix-subjects': TSESLint.RuleModule<"forbidden", readonly {
245
+ parameters?: boolean;
246
+ properties?: boolean;
247
+ suffix?: string;
248
+ types?: Record<string, boolean>;
249
+ variables?: boolean;
250
+ }[], {
251
+ description: "Enforce the use of a suffix in subject identifiers.";
252
+ requiresTypeChecking: true;
253
+ }, TSESLint.RuleListener>;
254
+ 'throw-error': TSESLint.RuleModule<"forbidden", readonly {
255
+ allowThrowingAny?: boolean;
256
+ allowThrowingUnknown?: boolean;
257
+ }[], {
258
+ description: "Enforce passing only `Error` values to `throwError` or `Subject.error`.";
259
+ recommended: {
260
+ recommended: true;
261
+ strict: [{
262
+ allowThrowingAny: boolean;
263
+ allowThrowingUnknown: boolean;
264
+ }];
265
+ };
266
+ requiresTypeChecking: true;
267
+ }, TSESLint.RuleListener>;
268
+ };
18
269
  declare const rxjsX: {
19
270
  configs: {
20
271
  recommended: {
21
272
  name: "rxjs-x/recommended";
22
273
  plugins: {
23
- 'rxjs-x': TSESLint.FlatConfig.Plugin;
274
+ 'rxjs-x': ESLint.Plugin;
24
275
  };
25
276
  rules: {
26
277
  'rxjs-x/no-async-subscribe': "error";
@@ -48,7 +299,7 @@ declare const rxjsX: {
48
299
  strict: {
49
300
  name: "rxjs-x/strict";
50
301
  plugins: {
51
- 'rxjs-x': TSESLint.FlatConfig.Plugin;
302
+ 'rxjs-x': ESLint.Plugin;
52
303
  };
53
304
  rules: {
54
305
  'rxjs-x/no-async-subscribe': "error";
@@ -89,102 +340,8 @@ declare const rxjsX: {
89
340
  name: string;
90
341
  version: string;
91
342
  };
92
- rules: {
93
- 'ban-observables': TSESLint.RuleModule<"forbidden", readonly Record<string, string | boolean>[], RxjsXRuleDocs, TSESLint.RuleListener>;
94
- 'ban-operators': TSESLint.RuleModule<"forbidden", readonly Record<string, string | boolean>[], RxjsXRuleDocs, TSESLint.RuleListener>;
95
- finnish: TSESLint.RuleModule<"shouldBeFinnish" | "shouldNotBeFinnish", readonly {
96
- functions?: boolean;
97
- methods?: boolean;
98
- names?: Record<string, boolean>;
99
- parameters?: boolean;
100
- properties?: boolean;
101
- strict?: boolean;
102
- types?: Record<string, boolean>;
103
- variables?: boolean;
104
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
105
- just: TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
106
- macro: TSESLint.RuleModule<"macro", [], RxjsXRuleDocs, TSESLint.RuleListener>;
107
- 'no-async-subscribe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
108
- 'no-compat': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
109
- 'no-connectable': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
110
- 'no-create': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
111
- 'no-cyclic-action': TSESLint.RuleModule<"forbidden", readonly {
112
- observable?: string;
113
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
114
- 'no-explicit-generics': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
115
- 'no-exposed-subjects': TSESLint.RuleModule<"forbidden" | "forbiddenAllowProtected", readonly {
116
- allowProtected?: boolean;
117
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
118
- 'no-finnish': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
119
- 'no-floating-observables': TSESLint.RuleModule<"forbidden" | "forbiddenNoVoid", readonly {
120
- ignoreVoid?: boolean;
121
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
122
- 'no-ignored-default-value': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
123
- 'no-ignored-error': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
124
- 'no-ignored-notifier': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
125
- 'no-ignored-replay-buffer': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
126
- 'no-ignored-subscribe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
127
- 'no-ignored-subscription': TSESLint.RuleModule<"forbidden", readonly {
128
- completers?: string[];
129
- postCompleters?: string[];
130
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
131
- 'no-ignored-takewhile-value': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
132
- 'no-implicit-any-catch': TSESLint.RuleModule<"explicitAny" | "implicitAny" | "narrowed" | "suggestExplicitUnknown", readonly {
133
- allowExplicitAny?: boolean;
134
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
135
- 'no-index': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
136
- 'no-internal': TSESLint.RuleModule<"forbidden" | "suggest", [], RxjsXRuleDocs, TSESLint.RuleListener>;
137
- 'no-misused-observables': TSESLint.RuleModule<"forbiddenVoidReturnArgument" | "forbiddenVoidReturnAttribute" | "forbiddenVoidReturnInheritedMethod" | "forbiddenVoidReturnProperty" | "forbiddenVoidReturnReturnValue" | "forbiddenVoidReturnVariable" | "forbiddenSpread", readonly {
138
- checksVoidReturn?: boolean | ChecksVoidReturnOptions;
139
- checksSpreads?: boolean;
140
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
141
- 'no-nested-subscribe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
142
- 'no-redundant-notify': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
143
- 'no-sharereplay': TSESLint.RuleModule<"forbidden" | "forbiddenWithoutConfig", readonly {
144
- allowConfig?: boolean;
145
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
146
- 'no-subclass': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
147
- 'no-subject-unsubscribe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
148
- 'no-subject-value': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
149
- 'no-subscribe-handlers': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
150
- 'no-subscribe-in-pipe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
151
- 'no-tap': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
152
- 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFromWithDefault" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], RxjsXRuleDocs, TSESLint.RuleListener>;
153
- 'no-unbound-methods': TSESLint.RuleModule<"forbidden", readonly {
154
- allowTypes?: string[];
155
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
156
- 'no-unsafe-catch': TSESLint.RuleModule<"forbidden", readonly {
157
- observable?: string;
158
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
159
- 'no-unsafe-first': TSESLint.RuleModule<"forbidden", readonly {
160
- observable?: string;
161
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
162
- 'no-unsafe-subject-next': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
163
- 'no-unsafe-switchmap': TSESLint.RuleModule<"forbidden", readonly {
164
- allow?: string | string[];
165
- disallow?: string | string[];
166
- observable?: string;
167
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
168
- 'no-unsafe-takeuntil': TSESLint.RuleModule<"forbidden", readonly {
169
- alias?: string[];
170
- allow?: string[];
171
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
172
- 'prefer-observer': TSESLint.RuleModule<"forbidden", readonly {
173
- allowNext?: boolean;
174
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
175
- 'prefer-root-operators': TSESLint.RuleModule<"forbidden" | "suggest" | "forbiddenWithoutFix", [], RxjsXRuleDocs, TSESLint.RuleListener>;
176
- 'suffix-subjects': TSESLint.RuleModule<"forbidden", readonly {
177
- parameters?: boolean;
178
- properties?: boolean;
179
- suffix?: string;
180
- types?: Record<string, boolean>;
181
- variables?: boolean;
182
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
183
- 'throw-error': TSESLint.RuleModule<"forbidden", readonly {
184
- allowThrowingAny?: boolean;
185
- allowThrowingUnknown?: boolean;
186
- }[], RxjsXRuleDocs, TSESLint.RuleListener>;
187
- };
343
+ /** Compatibility with `defineConfig` until https://github.com/typescript-eslint/typescript-eslint/issues/11543 is addressed. */
344
+ rules: { [K in keyof typeof allRules]: (typeof allRules)[K] & Rule.RuleModule; };
188
345
  };
189
346
 
190
347
  export = rxjsX;
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.7.6";
3
+ var version = "0.8.0";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
7
7
  name: "rxjs-x/recommended",
8
8
  plugins: {
9
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- "A type annotation is necessary."
9
10
  "rxjs-x": plugin2
10
11
  },
11
12
  rules: {
@@ -36,6 +37,7 @@ var createRecommendedConfig = (plugin2) => ({
36
37
  var createStrictConfig = (plugin2) => ({
37
38
  name: "rxjs-x/strict",
38
39
  plugins: {
40
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- "A type annotation is necessary."
39
41
  "rxjs-x": plugin2
40
42
  },
41
43
  rules: {
@@ -218,6 +220,9 @@ function getLoc(node) {
218
220
  function hasTypeAnnotation(node) {
219
221
  return "typeAnnotation" in node && !!node.typeAnnotation;
220
222
  }
223
+ function isAccessorProperty(node) {
224
+ return node.type === _utils.AST_NODE_TYPES.AccessorProperty;
225
+ }
221
226
  function isArrayExpression(node) {
222
227
  return node.type === _utils.AST_NODE_TYPES.ArrayExpression;
223
228
  }
@@ -435,6 +440,7 @@ function isSourcesObjectAcceptingStaticObservableCreator(expression) {
435
440
  var REPO_URL = "https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x";
436
441
  var ruleCreator = _utils.ESLintUtils.RuleCreator(
437
442
  (name2) => `${REPO_URL}/blob/v${version}/docs/rules/${name2}.md`
443
+ // Ensure the resulting types are narrowed to exactly what each rule declares.
438
444
  );
439
445
 
440
446
  // src/rules/ban-observables.ts
@@ -2235,6 +2241,7 @@ var noInternalRule = ruleCreator({
2235
2241
 
2236
2242
  // src/rules/no-misused-observables.ts
2237
2243
 
2244
+ var _astutils = require('@typescript-eslint/utils/ast-utils');
2238
2245
 
2239
2246
 
2240
2247
  function parseChecksVoidReturn(checksVoidReturn) {
@@ -2376,10 +2383,14 @@ var noMisusedObservablesRule = ruleCreator({
2376
2383
  }
2377
2384
  }
2378
2385
  function checkJSXAttribute(node) {
2379
- if (!node.value || !isJSXExpressionContainer(node.value)) {
2386
+ if (node.value == null || !isJSXExpressionContainer(node.value)) {
2380
2387
  return;
2381
2388
  }
2382
- if (couldReturnObservable(node.value.expression)) {
2389
+ const expressionContainer = esTreeNodeToTSNodeMap.get(
2390
+ node.value
2391
+ );
2392
+ const contextualType = checker.getContextualType(expressionContainer);
2393
+ if (contextualType != null && isVoidReturningFunctionType(contextualType) && couldReturnObservable(node.value.expression)) {
2383
2394
  context.report({
2384
2395
  messageId: "forbiddenVoidReturnAttribute",
2385
2396
  node: node.value
@@ -2396,7 +2407,7 @@ var noMisusedObservablesRule = ruleCreator({
2396
2407
  for (const element of node.body.body) {
2397
2408
  const tsElement = esTreeNodeToTSNodeMap.get(element);
2398
2409
  const memberName = (_a = tsElement == null ? void 0 : tsElement.name) == null ? void 0 : _a.getText();
2399
- if (memberName === void 0) {
2410
+ if (memberName == null) {
2400
2411
  continue;
2401
2412
  }
2402
2413
  if (!couldReturnObservable(element)) {
@@ -2407,7 +2418,7 @@ var noMisusedObservablesRule = ruleCreator({
2407
2418
  }
2408
2419
  for (const heritageType of heritageTypes) {
2409
2420
  const heritageMember = getMemberIfExists(heritageType, memberName);
2410
- if (heritageMember === void 0) {
2421
+ if (heritageMember == null) {
2411
2422
  continue;
2412
2423
  }
2413
2424
  const memberType = checker.getTypeOfSymbolAtLocation(heritageMember, tsElement);
@@ -2425,7 +2436,7 @@ var noMisusedObservablesRule = ruleCreator({
2425
2436
  function checkProperty(node) {
2426
2437
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2427
2438
  const contextualType = getPropertyContextualType(checker, tsNode);
2428
- if (contextualType === void 0) {
2439
+ if (contextualType == null) {
2429
2440
  return;
2430
2441
  }
2431
2442
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2434,14 +2445,29 @@ var noMisusedObservablesRule = ruleCreator({
2434
2445
  if (!couldReturnObservable(node.value)) {
2435
2446
  return;
2436
2447
  }
2437
- context.report({
2438
- messageId: "forbiddenVoidReturnProperty",
2439
- node: node.value
2440
- });
2448
+ if (_astutils.isFunction.call(void 0, node.value)) {
2449
+ const functionNode = node.value;
2450
+ if (functionNode.returnType) {
2451
+ context.report({
2452
+ messageId: "forbiddenVoidReturnProperty",
2453
+ node: functionNode.returnType.typeAnnotation
2454
+ });
2455
+ } else {
2456
+ context.report({
2457
+ messageId: "forbiddenVoidReturnProperty",
2458
+ loc: _astutils.getFunctionHeadLocation.call(void 0, functionNode, context.sourceCode)
2459
+ });
2460
+ }
2461
+ } else {
2462
+ context.report({
2463
+ messageId: "forbiddenVoidReturnProperty",
2464
+ node: node.value
2465
+ });
2466
+ }
2441
2467
  }
2442
2468
  function checkReturnStatement(node) {
2443
2469
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2444
- if (tsNode.expression === void 0 || !node.argument) {
2470
+ if (tsNode.expression == null || !node.argument) {
2445
2471
  return;
2446
2472
  }
2447
2473
  function getFunctionNode() {
@@ -2456,7 +2482,7 @@ var noMisusedObservablesRule = ruleCreator({
2456
2482
  return;
2457
2483
  }
2458
2484
  const contextualType = checker.getContextualType(tsNode.expression);
2459
- if (contextualType === void 0) {
2485
+ if (contextualType == null) {
2460
2486
  return;
2461
2487
  }
2462
2488
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2484,7 +2510,7 @@ var noMisusedObservablesRule = ruleCreator({
2484
2510
  }
2485
2511
  function checkVariableDeclaration(node) {
2486
2512
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2487
- if (tsNode.initializer === void 0 || !node.init || !node.id.typeAnnotation) {
2513
+ if (tsNode.initializer == null || node.init == null || node.id.typeAnnotation == null) {
2488
2514
  return;
2489
2515
  }
2490
2516
  if (!isPossiblyFunctionType(node.id.typeAnnotation)) {
@@ -2531,6 +2557,9 @@ function isVoidReturningFunctionType(type) {
2531
2557
  for (const subType of tsutils2.unionTypeParts(type)) {
2532
2558
  for (const signature of subType.getCallSignatures()) {
2533
2559
  const returnType = signature.getReturnType();
2560
+ if (couldBeType(returnType, "Observable")) {
2561
+ return false;
2562
+ }
2534
2563
  hasVoidReturn || (hasVoidReturn = tsutils2.isTypeFlagSet(returnType, _typescript2.default.TypeFlags.Void));
2535
2564
  }
2536
2565
  }
@@ -2547,7 +2576,7 @@ function getMemberIfExists(type, memberName) {
2547
2576
  return symbolMemberMatch != null ? symbolMemberMatch : tsutils2.getPropertyOfType(type, escapedMemberName);
2548
2577
  }
2549
2578
  function isStaticMember(node) {
2550
- return (isMethodDefinition(node) || isPropertyDefinition(node)) && node.static;
2579
+ return (isMethodDefinition(node) || isPropertyDefinition(node) || isAccessorProperty(node)) && node.static;
2551
2580
  }
2552
2581
  function getPropertyContextualType(checker, tsNode) {
2553
2582
  if (_typescript2.default.isPropertyAssignment(tsNode)) {
@@ -2563,11 +2592,11 @@ function getPropertyContextualType(checker, tsNode) {
2563
2592
  return;
2564
2593
  }
2565
2594
  const objType = checker.getContextualType(obj);
2566
- if (objType === void 0) {
2595
+ if (objType == null) {
2567
2596
  return;
2568
2597
  }
2569
2598
  const propertySymbol = checker.getPropertyOfType(objType, tsNode.name.text);
2570
- if (propertySymbol === void 0) {
2599
+ if (propertySymbol == null) {
2571
2600
  return;
2572
2601
  }
2573
2602
  return checker.getTypeOfSymbolAtLocation(propertySymbol, tsNode.name);
@@ -4100,55 +4129,57 @@ var throwErrorRule = ruleCreator({
4100
4129
  });
4101
4130
 
4102
4131
  // src/index.ts
4132
+ var allRules = {
4133
+ "ban-observables": banObservablesRule,
4134
+ "ban-operators": banOperatorsRule,
4135
+ "finnish": finnishRule,
4136
+ "just": justRule,
4137
+ "macro": macroRule,
4138
+ "no-async-subscribe": noAsyncSubscribeRule,
4139
+ "no-compat": noCompatRule,
4140
+ "no-connectable": noConnectableRule,
4141
+ "no-create": noCreateRule,
4142
+ "no-cyclic-action": noCyclicActionRule,
4143
+ "no-explicit-generics": noExplicitGenericsRule,
4144
+ "no-exposed-subjects": noExposedSubjectsRule,
4145
+ "no-finnish": noFinnishRule,
4146
+ "no-floating-observables": noFloatingObservablesRule,
4147
+ "no-ignored-default-value": noIgnoredDefaultValueRule,
4148
+ "no-ignored-error": noIgnoredErrorRule,
4149
+ "no-ignored-notifier": noIgnoredNotifierRule,
4150
+ "no-ignored-replay-buffer": noIgnoredReplayBufferRule,
4151
+ "no-ignored-subscribe": noIgnoredSubscribeRule,
4152
+ "no-ignored-subscription": noIgnoredSubscriptionRule,
4153
+ "no-ignored-takewhile-value": noIgnoredTakewhileValueRule,
4154
+ "no-implicit-any-catch": noImplicitAnyCatchRule,
4155
+ "no-index": noIndexRule,
4156
+ "no-internal": noInternalRule,
4157
+ "no-misused-observables": noMisusedObservablesRule,
4158
+ "no-nested-subscribe": noNestedSubscribeRule,
4159
+ "no-redundant-notify": noRedundantNotifyRule,
4160
+ "no-sharereplay": noSharereplayRule,
4161
+ "no-subclass": noSubclassRule,
4162
+ "no-subject-unsubscribe": noSubjectUnsubscribeRule,
4163
+ "no-subject-value": noSubjectValueRule,
4164
+ "no-subscribe-handlers": noSubscribeHandlersRule,
4165
+ "no-subscribe-in-pipe": noSubscribeInPipeRule,
4166
+ "no-tap": noTapRule,
4167
+ "no-topromise": noTopromiseRule,
4168
+ "no-unbound-methods": noUnboundMethodsRule,
4169
+ "no-unsafe-catch": noUnsafeCatchRule,
4170
+ "no-unsafe-first": noUnsafeFirstRule,
4171
+ "no-unsafe-subject-next": noUnsafeSubjectNext,
4172
+ "no-unsafe-switchmap": noUnsafeSwitchmapRule,
4173
+ "no-unsafe-takeuntil": noUnsafeTakeuntilRule,
4174
+ "prefer-observer": preferObserverRule,
4175
+ "prefer-root-operators": preferRootOperatorsRule,
4176
+ "suffix-subjects": suffixSubjectsRule,
4177
+ "throw-error": throwErrorRule
4178
+ };
4103
4179
  var plugin = {
4104
4180
  meta: { name, version },
4105
- rules: {
4106
- "ban-observables": banObservablesRule,
4107
- "ban-operators": banOperatorsRule,
4108
- "finnish": finnishRule,
4109
- "just": justRule,
4110
- "macro": macroRule,
4111
- "no-async-subscribe": noAsyncSubscribeRule,
4112
- "no-compat": noCompatRule,
4113
- "no-connectable": noConnectableRule,
4114
- "no-create": noCreateRule,
4115
- "no-cyclic-action": noCyclicActionRule,
4116
- "no-explicit-generics": noExplicitGenericsRule,
4117
- "no-exposed-subjects": noExposedSubjectsRule,
4118
- "no-finnish": noFinnishRule,
4119
- "no-floating-observables": noFloatingObservablesRule,
4120
- "no-ignored-default-value": noIgnoredDefaultValueRule,
4121
- "no-ignored-error": noIgnoredErrorRule,
4122
- "no-ignored-notifier": noIgnoredNotifierRule,
4123
- "no-ignored-replay-buffer": noIgnoredReplayBufferRule,
4124
- "no-ignored-subscribe": noIgnoredSubscribeRule,
4125
- "no-ignored-subscription": noIgnoredSubscriptionRule,
4126
- "no-ignored-takewhile-value": noIgnoredTakewhileValueRule,
4127
- "no-implicit-any-catch": noImplicitAnyCatchRule,
4128
- "no-index": noIndexRule,
4129
- "no-internal": noInternalRule,
4130
- "no-misused-observables": noMisusedObservablesRule,
4131
- "no-nested-subscribe": noNestedSubscribeRule,
4132
- "no-redundant-notify": noRedundantNotifyRule,
4133
- "no-sharereplay": noSharereplayRule,
4134
- "no-subclass": noSubclassRule,
4135
- "no-subject-unsubscribe": noSubjectUnsubscribeRule,
4136
- "no-subject-value": noSubjectValueRule,
4137
- "no-subscribe-handlers": noSubscribeHandlersRule,
4138
- "no-subscribe-in-pipe": noSubscribeInPipeRule,
4139
- "no-tap": noTapRule,
4140
- "no-topromise": noTopromiseRule,
4141
- "no-unbound-methods": noUnboundMethodsRule,
4142
- "no-unsafe-catch": noUnsafeCatchRule,
4143
- "no-unsafe-first": noUnsafeFirstRule,
4144
- "no-unsafe-subject-next": noUnsafeSubjectNext,
4145
- "no-unsafe-switchmap": noUnsafeSwitchmapRule,
4146
- "no-unsafe-takeuntil": noUnsafeTakeuntilRule,
4147
- "prefer-observer": preferObserverRule,
4148
- "prefer-root-operators": preferRootOperatorsRule,
4149
- "suffix-subjects": suffixSubjectsRule,
4150
- "throw-error": throwErrorRule
4151
- }
4181
+ /** Compatibility with `defineConfig` until https://github.com/typescript-eslint/typescript-eslint/issues/11543 is addressed. */
4182
+ rules: allRules
4152
4183
  };
4153
4184
  var rxjsX = {
4154
4185
  ...plugin,