eslint-plugin-rxjs-x 0.1.0 → 0.2.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/README.md +57 -43
- package/dist/index.d.ts +1 -1
- package/dist/{index.cjs → index.js} +427 -342
- package/dist/index.mjs +422 -319
- package/docs/rules/ban-observables.md +3 -1
- package/docs/rules/ban-operators.md +3 -1
- package/docs/rules/finnish.md +21 -2
- package/docs/rules/just.md +5 -5
- package/docs/rules/macro.md +4 -4
- package/docs/rules/no-async-subscribe.md +7 -5
- package/docs/rules/no-compat.md +3 -5
- package/docs/rules/no-connectable.md +4 -4
- package/docs/rules/no-create.md +7 -5
- package/docs/rules/no-cyclic-action.md +14 -2
- package/docs/rules/no-explicit-generics.md +3 -5
- package/docs/rules/no-exposed-subjects.md +14 -2
- package/docs/rules/no-finnish.md +6 -6
- package/docs/rules/no-ignored-error.md +5 -5
- package/docs/rules/no-ignored-notifier.md +7 -5
- package/docs/rules/no-ignored-observable.md +5 -5
- package/docs/rules/no-ignored-replay-buffer.md +5 -5
- package/docs/rules/no-ignored-subscribe.md +5 -5
- package/docs/rules/no-ignored-subscription.md +5 -5
- package/docs/rules/no-ignored-takewhile-value.md +5 -5
- package/docs/rules/no-implicit-any-catch.md +18 -2
- package/docs/rules/no-index.md +5 -5
- package/docs/rules/no-internal.md +7 -5
- package/docs/rules/no-nested-subscribe.md +7 -5
- package/docs/rules/no-redundant-notify.md +7 -5
- package/docs/rules/no-sharereplay.md +14 -2
- package/docs/rules/no-subclass.md +4 -4
- package/docs/rules/no-subject-unsubscribe.md +7 -5
- package/docs/rules/no-subject-value.md +4 -4
- package/docs/rules/no-subscribe-handlers.md +5 -7
- package/docs/rules/no-tap.md +4 -4
- package/docs/rules/no-topromise.md +4 -4
- package/docs/rules/no-unbound-methods.md +7 -8
- package/docs/rules/no-unsafe-catch.md +13 -1
- package/docs/rules/no-unsafe-first.md +13 -1
- package/docs/rules/no-unsafe-subject-next.md +7 -5
- package/docs/rules/no-unsafe-switchmap.md +15 -1
- package/docs/rules/no-unsafe-takeuntil.md +16 -1
- package/docs/rules/prefer-observer.md +15 -1
- package/docs/rules/suffix-subjects.md +17 -1
- package/docs/rules/throw-error.md +5 -5
- package/package.json +16 -9
- package/dist/index.d.cts +0 -121
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as ts from 'typescript';
|
|
5
|
-
import { DefinitionType } from '@typescript-eslint/scope-manager';
|
|
6
|
-
import decamelize from 'decamelize';
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "eslint-plugin-rxjs-x";
|
|
3
|
+
var version = "0.2.0";
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const createRecommendedConfig = (plugin) => ({
|
|
5
|
+
// src/configs/recommended.ts
|
|
6
|
+
var createRecommendedConfig = (plugin2) => ({
|
|
12
7
|
plugins: {
|
|
13
|
-
"rxjs-x":
|
|
8
|
+
"rxjs-x": plugin2
|
|
14
9
|
},
|
|
15
10
|
rules: {
|
|
16
11
|
"rxjs-x/no-async-subscribe": "error",
|
|
@@ -31,8 +26,14 @@ const createRecommendedConfig = (plugin) => ({
|
|
|
31
26
|
}
|
|
32
27
|
});
|
|
33
28
|
|
|
29
|
+
// src/rules/ban-observables.ts
|
|
30
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
31
|
+
import { stripIndent } from "common-tags";
|
|
32
|
+
|
|
33
|
+
// src/utils.ts
|
|
34
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
34
35
|
function createRegExpForWords(config) {
|
|
35
|
-
if (!config
|
|
36
|
+
if (!(config == null ? void 0 : config.length)) {
|
|
36
37
|
return void 0;
|
|
37
38
|
}
|
|
38
39
|
const flags = "i";
|
|
@@ -46,16 +47,17 @@ function createRegExpForWords(config) {
|
|
|
46
47
|
function escapeRegExp(text) {
|
|
47
48
|
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
(
|
|
50
|
+
var ruleCreator = ESLintUtils.RuleCreator(
|
|
51
|
+
(name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
|
|
51
52
|
);
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// src/rules/ban-observables.ts
|
|
55
|
+
var defaultOptions = [];
|
|
56
|
+
var banObservablesRule = ruleCreator({
|
|
57
|
+
defaultOptions,
|
|
56
58
|
meta: {
|
|
57
59
|
docs: {
|
|
58
|
-
description: "
|
|
60
|
+
description: "Disallow banned observable creators."
|
|
59
61
|
},
|
|
60
62
|
messages: {
|
|
61
63
|
forbidden: "RxJS observable is banned: {{name}}{{explanation}}."
|
|
@@ -85,14 +87,14 @@ const banObservablesRule = ruleCreator({
|
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
});
|
|
88
|
-
function getFailure(
|
|
90
|
+
function getFailure(name2) {
|
|
89
91
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
90
92
|
const ban = bans[b];
|
|
91
|
-
if (ban.regExp.test(
|
|
93
|
+
if (ban.regExp.test(name2)) {
|
|
92
94
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
93
95
|
return {
|
|
94
96
|
messageId: "forbidden",
|
|
95
|
-
data: { name, explanation }
|
|
97
|
+
data: { name: name2, explanation }
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -101,8 +103,8 @@ const banObservablesRule = ruleCreator({
|
|
|
101
103
|
return {
|
|
102
104
|
"ImportDeclaration[source.value='rxjs'] > ImportSpecifier": (node) => {
|
|
103
105
|
const identifier = node.imported;
|
|
104
|
-
const
|
|
105
|
-
const failure = getFailure(
|
|
106
|
+
const name2 = identifier.type === AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
107
|
+
const failure = getFailure(name2);
|
|
106
108
|
if (failure) {
|
|
107
109
|
context.report({
|
|
108
110
|
...failure,
|
|
@@ -114,12 +116,15 @@ const banObservablesRule = ruleCreator({
|
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
// src/rules/ban-operators.ts
|
|
120
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/utils";
|
|
121
|
+
import { stripIndent as stripIndent2 } from "common-tags";
|
|
122
|
+
var defaultOptions2 = [];
|
|
123
|
+
var banOperatorsRule = ruleCreator({
|
|
124
|
+
defaultOptions: defaultOptions2,
|
|
120
125
|
meta: {
|
|
121
126
|
docs: {
|
|
122
|
-
description: "
|
|
127
|
+
description: "Disallow banned operators."
|
|
123
128
|
},
|
|
124
129
|
messages: {
|
|
125
130
|
forbidden: "RxJS operator is banned: {{name}}{{explanation}}."
|
|
@@ -127,7 +132,7 @@ const banOperatorsRule = ruleCreator({
|
|
|
127
132
|
schema: [
|
|
128
133
|
{
|
|
129
134
|
type: "object",
|
|
130
|
-
description:
|
|
135
|
+
description: stripIndent2`
|
|
131
136
|
An object containing keys that are names of operators
|
|
132
137
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
133
138
|
}
|
|
@@ -149,14 +154,14 @@ const banOperatorsRule = ruleCreator({
|
|
|
149
154
|
});
|
|
150
155
|
}
|
|
151
156
|
});
|
|
152
|
-
function getFailure(
|
|
157
|
+
function getFailure(name2) {
|
|
153
158
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
154
159
|
const ban = bans[b];
|
|
155
|
-
if (ban.regExp.test(
|
|
160
|
+
if (ban.regExp.test(name2)) {
|
|
156
161
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
157
162
|
return {
|
|
158
163
|
messageId: "forbidden",
|
|
159
|
-
data: { name, explanation }
|
|
164
|
+
data: { name: name2, explanation }
|
|
160
165
|
};
|
|
161
166
|
}
|
|
162
167
|
}
|
|
@@ -165,8 +170,8 @@ const banOperatorsRule = ruleCreator({
|
|
|
165
170
|
return {
|
|
166
171
|
[String.raw`ImportDeclaration[source.value=/^rxjs\u002foperators$/] > ImportSpecifier`]: (node) => {
|
|
167
172
|
const identifier = node.imported;
|
|
168
|
-
const
|
|
169
|
-
const failure = getFailure(
|
|
173
|
+
const name2 = identifier.type === AST_NODE_TYPES2.Identifier ? identifier.name : identifier.value;
|
|
174
|
+
const failure = getFailure(name2);
|
|
170
175
|
if (failure) {
|
|
171
176
|
context.report({
|
|
172
177
|
...failure,
|
|
@@ -178,26 +183,35 @@ const banOperatorsRule = ruleCreator({
|
|
|
178
183
|
}
|
|
179
184
|
});
|
|
180
185
|
|
|
181
|
-
|
|
186
|
+
// src/rules/finnish.ts
|
|
187
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES5, ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
|
|
188
|
+
|
|
189
|
+
// src/etc/could-be-function.ts
|
|
190
|
+
import * as ts2 from "typescript";
|
|
191
|
+
|
|
192
|
+
// src/etc/could-be-type.ts
|
|
193
|
+
import * as tsutils from "ts-api-utils";
|
|
194
|
+
import * as ts from "typescript";
|
|
195
|
+
function couldBeType(type, name2, qualified) {
|
|
182
196
|
if (tsutils.isTypeReference(type)) {
|
|
183
197
|
type = type.target;
|
|
184
198
|
}
|
|
185
|
-
if (isType(type,
|
|
199
|
+
if (isType(type, name2, qualified)) {
|
|
186
200
|
return true;
|
|
187
201
|
}
|
|
188
202
|
if (tsutils.isUnionOrIntersectionType(type)) {
|
|
189
|
-
return type.types.some((t) => couldBeType(t,
|
|
203
|
+
return type.types.some((t) => couldBeType(t, name2, qualified));
|
|
190
204
|
}
|
|
191
205
|
const baseTypes = type.getBaseTypes();
|
|
192
|
-
if (baseTypes
|
|
206
|
+
if (baseTypes == null ? void 0 : baseTypes.some((t) => couldBeType(t, name2, qualified))) {
|
|
193
207
|
return true;
|
|
194
208
|
}
|
|
195
|
-
if (couldImplement(type,
|
|
209
|
+
if (couldImplement(type, name2, qualified)) {
|
|
196
210
|
return true;
|
|
197
211
|
}
|
|
198
212
|
return false;
|
|
199
213
|
}
|
|
200
|
-
function isType(type,
|
|
214
|
+
function isType(type, name2, qualified) {
|
|
201
215
|
if (!type.symbol) {
|
|
202
216
|
return false;
|
|
203
217
|
}
|
|
@@ -206,9 +220,9 @@ function isType(type, name, qualified) {
|
|
|
206
220
|
)) {
|
|
207
221
|
return false;
|
|
208
222
|
}
|
|
209
|
-
return typeof
|
|
223
|
+
return typeof name2 === "string" ? type.symbol.name === name2 : Boolean(type.symbol.name.match(name2));
|
|
210
224
|
}
|
|
211
|
-
function couldImplement(type,
|
|
225
|
+
function couldImplement(type, name2, qualified) {
|
|
212
226
|
const { symbol } = type;
|
|
213
227
|
if (symbol) {
|
|
214
228
|
const { valueDeclaration } = symbol;
|
|
@@ -216,7 +230,7 @@ function couldImplement(type, name, qualified) {
|
|
|
216
230
|
const { heritageClauses } = valueDeclaration;
|
|
217
231
|
if (heritageClauses) {
|
|
218
232
|
const implemented = heritageClauses.some(
|
|
219
|
-
({ token, types }) => token === ts.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node,
|
|
233
|
+
({ token, types }) => token === ts.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node, name2, qualified))
|
|
220
234
|
);
|
|
221
235
|
if (implemented) {
|
|
222
236
|
return true;
|
|
@@ -226,7 +240,7 @@ function couldImplement(type, name, qualified) {
|
|
|
226
240
|
}
|
|
227
241
|
return false;
|
|
228
242
|
}
|
|
229
|
-
function isMatchingNode(node,
|
|
243
|
+
function isMatchingNode(node, name2, qualified) {
|
|
230
244
|
const { expression } = node;
|
|
231
245
|
if (qualified) {
|
|
232
246
|
const type = qualified.typeChecker.getTypeAtLocation(expression);
|
|
@@ -240,13 +254,15 @@ function isMatchingNode(node, name, qualified) {
|
|
|
240
254
|
}
|
|
241
255
|
}
|
|
242
256
|
const text = expression.getText();
|
|
243
|
-
return typeof
|
|
257
|
+
return typeof name2 === "string" ? text === name2 : Boolean(text.match(name2));
|
|
244
258
|
}
|
|
245
259
|
|
|
260
|
+
// src/etc/could-be-function.ts
|
|
246
261
|
function couldBeFunction(type) {
|
|
247
|
-
return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type,
|
|
262
|
+
return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type, ts2.InternalSymbolName.Function);
|
|
248
263
|
}
|
|
249
264
|
|
|
265
|
+
// src/etc/find-parent.ts
|
|
250
266
|
function findParent(node, ...args) {
|
|
251
267
|
const [arg] = args;
|
|
252
268
|
const predicate = typeof arg === "function" ? arg : (type) => !args.includes(type) ? "continue" : "return";
|
|
@@ -257,16 +273,20 @@ function findParent(node, ...args) {
|
|
|
257
273
|
return void 0;
|
|
258
274
|
case "return":
|
|
259
275
|
return parent;
|
|
276
|
+
default:
|
|
277
|
+
break;
|
|
260
278
|
}
|
|
261
279
|
parent = parent.parent;
|
|
262
280
|
}
|
|
263
281
|
return void 0;
|
|
264
282
|
}
|
|
265
283
|
|
|
284
|
+
// src/etc/get-loc.ts
|
|
285
|
+
import * as ts3 from "typescript";
|
|
266
286
|
function getLoc(node) {
|
|
267
287
|
const sourceFile = node.getSourceFile();
|
|
268
|
-
const start =
|
|
269
|
-
const end =
|
|
288
|
+
const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
289
|
+
const end = ts3.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
|
|
270
290
|
return {
|
|
271
291
|
start: {
|
|
272
292
|
line: start.line + 1,
|
|
@@ -279,76 +299,85 @@ function getLoc(node) {
|
|
|
279
299
|
};
|
|
280
300
|
}
|
|
281
301
|
|
|
302
|
+
// src/etc/get-type-services.ts
|
|
303
|
+
import { ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
|
|
304
|
+
import * as tsutils2 from "ts-api-utils";
|
|
305
|
+
import * as ts4 from "typescript";
|
|
306
|
+
|
|
307
|
+
// src/etc/is.ts
|
|
308
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
282
309
|
function hasTypeAnnotation(node) {
|
|
283
310
|
return "typeAnnotation" in node && !!node.typeAnnotation;
|
|
284
311
|
}
|
|
285
312
|
function isArrayExpression(node) {
|
|
286
|
-
return node.type ===
|
|
313
|
+
return node.type === AST_NODE_TYPES3.ArrayExpression;
|
|
287
314
|
}
|
|
288
315
|
function isArrayPattern(node) {
|
|
289
|
-
return node.type ===
|
|
316
|
+
return node.type === AST_NODE_TYPES3.ArrayPattern;
|
|
290
317
|
}
|
|
291
318
|
function isArrowFunctionExpression(node) {
|
|
292
|
-
return node.type ===
|
|
319
|
+
return node.type === AST_NODE_TYPES3.ArrowFunctionExpression;
|
|
293
320
|
}
|
|
294
321
|
function isBlockStatement(node) {
|
|
295
|
-
return node.type ===
|
|
322
|
+
return node.type === AST_NODE_TYPES3.BlockStatement;
|
|
296
323
|
}
|
|
297
324
|
function isCallExpression(node) {
|
|
298
|
-
return node.type ===
|
|
325
|
+
return node.type === AST_NODE_TYPES3.CallExpression;
|
|
299
326
|
}
|
|
300
327
|
function isFunctionDeclaration(node) {
|
|
301
|
-
return node.type ===
|
|
328
|
+
return node.type === AST_NODE_TYPES3.FunctionDeclaration;
|
|
302
329
|
}
|
|
303
330
|
function isFunctionExpression(node) {
|
|
304
|
-
return node.type ===
|
|
331
|
+
return node.type === AST_NODE_TYPES3.FunctionExpression;
|
|
305
332
|
}
|
|
306
333
|
function isIdentifier(node) {
|
|
307
|
-
return node.type ===
|
|
334
|
+
return node.type === AST_NODE_TYPES3.Identifier;
|
|
308
335
|
}
|
|
309
336
|
function isLiteral(node) {
|
|
310
|
-
return node.type ===
|
|
337
|
+
return node.type === AST_NODE_TYPES3.Literal;
|
|
311
338
|
}
|
|
312
339
|
function isMemberExpression(node) {
|
|
313
|
-
return node.type ===
|
|
340
|
+
return node.type === AST_NODE_TYPES3.MemberExpression;
|
|
314
341
|
}
|
|
315
342
|
function isObjectExpression(node) {
|
|
316
|
-
return node.type ===
|
|
343
|
+
return node.type === AST_NODE_TYPES3.ObjectExpression;
|
|
317
344
|
}
|
|
318
345
|
function isObjectPattern(node) {
|
|
319
|
-
return node.type ===
|
|
346
|
+
return node.type === AST_NODE_TYPES3.ObjectPattern;
|
|
320
347
|
}
|
|
321
348
|
function isProgram(node) {
|
|
322
|
-
return node.type ===
|
|
349
|
+
return node.type === AST_NODE_TYPES3.Program;
|
|
323
350
|
}
|
|
324
351
|
function isProperty(node) {
|
|
325
|
-
return node.type ===
|
|
352
|
+
return node.type === AST_NODE_TYPES3.Property;
|
|
326
353
|
}
|
|
327
354
|
|
|
355
|
+
// src/etc/get-type-services.ts
|
|
328
356
|
function getTypeServices(context) {
|
|
329
|
-
const services =
|
|
357
|
+
const services = ESLintUtils2.getParserServices(context);
|
|
330
358
|
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = services;
|
|
331
359
|
const typeChecker = program.getTypeChecker();
|
|
332
|
-
const
|
|
360
|
+
const couldBeType2 = (node, name2, qualified) => {
|
|
333
361
|
const type = getType(node);
|
|
334
362
|
return couldBeType(
|
|
335
363
|
type,
|
|
336
|
-
|
|
364
|
+
name2,
|
|
337
365
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
338
366
|
);
|
|
339
367
|
};
|
|
340
|
-
const couldReturnType = (node,
|
|
368
|
+
const couldReturnType = (node, name2, qualified) => {
|
|
369
|
+
var _a;
|
|
341
370
|
let tsTypeNode;
|
|
342
371
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
343
|
-
if (
|
|
344
|
-
tsTypeNode = tsNode.type
|
|
345
|
-
} else if (
|
|
372
|
+
if (ts4.isArrowFunction(tsNode) || ts4.isFunctionDeclaration(tsNode) || ts4.isMethodDeclaration(tsNode) || ts4.isFunctionExpression(tsNode)) {
|
|
373
|
+
tsTypeNode = (_a = tsNode.type) != null ? _a : tsNode.body;
|
|
374
|
+
} else if (ts4.isCallSignatureDeclaration(tsNode) || ts4.isMethodSignature(tsNode)) {
|
|
346
375
|
tsTypeNode = tsNode.type;
|
|
347
376
|
}
|
|
348
377
|
return Boolean(
|
|
349
378
|
tsTypeNode && couldBeType(
|
|
350
379
|
typeChecker.getTypeAtLocation(tsTypeNode),
|
|
351
|
-
|
|
380
|
+
name2,
|
|
352
381
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
353
382
|
)
|
|
354
383
|
);
|
|
@@ -357,45 +386,49 @@ function getTypeServices(context) {
|
|
|
357
386
|
return getTypeAtLocation(node);
|
|
358
387
|
};
|
|
359
388
|
return {
|
|
360
|
-
couldBeBehaviorSubject: (node) =>
|
|
361
|
-
couldBeError: (node) =>
|
|
389
|
+
couldBeBehaviorSubject: (node) => couldBeType2(node, "BehaviorSubject"),
|
|
390
|
+
couldBeError: (node) => couldBeType2(node, "Error"),
|
|
362
391
|
couldBeFunction: (node) => {
|
|
363
392
|
if (isArrowFunctionExpression(node) || isFunctionDeclaration(node)) {
|
|
364
393
|
return true;
|
|
365
394
|
}
|
|
366
395
|
return couldBeFunction(getType(node));
|
|
367
396
|
},
|
|
368
|
-
couldBeMonoTypeOperatorFunction: (node) =>
|
|
369
|
-
couldBeObservable: (node) =>
|
|
370
|
-
couldBeSubject: (node) =>
|
|
371
|
-
couldBeSubscription: (node) =>
|
|
372
|
-
couldBeType:
|
|
397
|
+
couldBeMonoTypeOperatorFunction: (node) => couldBeType2(node, "MonoTypeOperatorFunction"),
|
|
398
|
+
couldBeObservable: (node) => couldBeType2(node, "Observable"),
|
|
399
|
+
couldBeSubject: (node) => couldBeType2(node, "Subject"),
|
|
400
|
+
couldBeSubscription: (node) => couldBeType2(node, "Subscription"),
|
|
401
|
+
couldBeType: couldBeType2,
|
|
373
402
|
couldReturnObservable: (node) => couldReturnType(node, "Observable"),
|
|
374
403
|
couldReturnType,
|
|
375
404
|
getType,
|
|
376
|
-
isAny: (node) =>
|
|
377
|
-
isReferenceType: (node) =>
|
|
378
|
-
isUnknown: (node) =>
|
|
405
|
+
isAny: (node) => tsutils2.isIntrinsicAnyType(getType(node)),
|
|
406
|
+
isReferenceType: (node) => tsutils2.isTypeReference(getType(node)),
|
|
407
|
+
isUnknown: (node) => tsutils2.isIntrinsicUnknownType(getType(node)),
|
|
379
408
|
typeChecker
|
|
380
409
|
};
|
|
381
410
|
}
|
|
382
411
|
|
|
383
|
-
|
|
384
|
-
|
|
412
|
+
// src/etc/is-import.ts
|
|
413
|
+
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
414
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
415
|
+
function isImport(scope, name2, source) {
|
|
416
|
+
const variable = scope.variables.find((variable2) => variable2.name === name2);
|
|
385
417
|
if (variable) {
|
|
386
418
|
return variable.defs.some(
|
|
387
|
-
(def) => def.type === DefinitionType.ImportBinding && def.parent.type ===
|
|
419
|
+
(def) => def.type === DefinitionType.ImportBinding && def.parent.type === AST_NODE_TYPES4.ImportDeclaration && (typeof source === "string" ? def.parent.source.value === source : source.test(def.parent.source.value))
|
|
388
420
|
);
|
|
389
421
|
}
|
|
390
|
-
return scope.upper ? isImport(scope.upper,
|
|
422
|
+
return scope.upper ? isImport(scope.upper, name2, source) : false;
|
|
391
423
|
}
|
|
392
424
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
425
|
+
// src/rules/finnish.ts
|
|
426
|
+
var defaultOptions3 = [];
|
|
427
|
+
var finnishRule = ruleCreator({
|
|
428
|
+
defaultOptions: defaultOptions3,
|
|
396
429
|
meta: {
|
|
397
430
|
docs: {
|
|
398
|
-
description: "
|
|
431
|
+
description: "Enforce Finnish notation.",
|
|
399
432
|
requiresTypeChecking: true
|
|
400
433
|
},
|
|
401
434
|
messages: {
|
|
@@ -405,14 +438,14 @@ const finnishRule = ruleCreator({
|
|
|
405
438
|
schema: [
|
|
406
439
|
{
|
|
407
440
|
properties: {
|
|
408
|
-
functions: { type: "boolean" },
|
|
409
|
-
methods: { type: "boolean" },
|
|
410
|
-
names: { type: "object" },
|
|
411
|
-
parameters: { type: "boolean" },
|
|
412
|
-
properties: { type: "boolean" },
|
|
413
|
-
strict: { type: "boolean" },
|
|
414
|
-
types: { type: "object" },
|
|
415
|
-
variables: { type: "boolean" }
|
|
441
|
+
functions: { type: "boolean", description: "Require for functions." },
|
|
442
|
+
methods: { type: "boolean", description: "Require for methods." },
|
|
443
|
+
names: { type: "object", description: "Enforce for specific names. Keys are a RegExp, values are a boolean." },
|
|
444
|
+
parameters: { type: "boolean", description: "Require for parameters." },
|
|
445
|
+
properties: { type: "boolean", description: "Require for properties." },
|
|
446
|
+
strict: { type: "boolean", description: "Disallow Finnish notation for non-Observables." },
|
|
447
|
+
types: { type: "object", description: "Enforce for specific types. Keys are a RegExp, values are a boolean." },
|
|
448
|
+
variables: { type: "boolean", description: "Require for variables." }
|
|
416
449
|
},
|
|
417
450
|
type: "object"
|
|
418
451
|
}
|
|
@@ -421,10 +454,10 @@ const finnishRule = ruleCreator({
|
|
|
421
454
|
},
|
|
422
455
|
name: "finnish",
|
|
423
456
|
create: (context) => {
|
|
424
|
-
const { esTreeNodeToTSNodeMap } =
|
|
457
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils3.getParserServices(context);
|
|
425
458
|
const {
|
|
426
459
|
couldBeObservable,
|
|
427
|
-
couldBeType,
|
|
460
|
+
couldBeType: couldBeType2,
|
|
428
461
|
couldReturnObservable,
|
|
429
462
|
couldReturnType
|
|
430
463
|
} = getTypeServices(context);
|
|
@@ -486,8 +519,8 @@ const finnishRule = ruleCreator({
|
|
|
486
519
|
} : () => {
|
|
487
520
|
};
|
|
488
521
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
489
|
-
for (const
|
|
490
|
-
const { regExp, validate: validate2 } =
|
|
522
|
+
for (const name2 of names) {
|
|
523
|
+
const { regExp, validate: validate2 } = name2;
|
|
491
524
|
if (regExp.test(text) && !validate2) {
|
|
492
525
|
shouldNotBeFinnish();
|
|
493
526
|
return;
|
|
@@ -495,7 +528,7 @@ const finnishRule = ruleCreator({
|
|
|
495
528
|
}
|
|
496
529
|
for (const type of types) {
|
|
497
530
|
const { regExp, validate: validate2 } = type;
|
|
498
|
-
if ((
|
|
531
|
+
if ((couldBeType2(typeNode || nameNode, regExp) || couldReturnType(typeNode || nameNode, regExp)) && !validate2) {
|
|
499
532
|
shouldNotBeFinnish();
|
|
500
533
|
return;
|
|
501
534
|
}
|
|
@@ -517,7 +550,7 @@ const finnishRule = ruleCreator({
|
|
|
517
550
|
if (!found) {
|
|
518
551
|
return;
|
|
519
552
|
}
|
|
520
|
-
if (!validate.variables && found.type ===
|
|
553
|
+
if (!validate.variables && found.type === AST_NODE_TYPES5.VariableDeclarator) {
|
|
521
554
|
return;
|
|
522
555
|
}
|
|
523
556
|
if (!validate.parameters) {
|
|
@@ -596,7 +629,7 @@ const finnishRule = ruleCreator({
|
|
|
596
629
|
if (!found) {
|
|
597
630
|
return;
|
|
598
631
|
}
|
|
599
|
-
if (!validate.variables && found.type ===
|
|
632
|
+
if (!validate.variables && found.type === AST_NODE_TYPES5.VariableDeclarator) {
|
|
600
633
|
return;
|
|
601
634
|
}
|
|
602
635
|
if (!validate.parameters) {
|
|
@@ -647,11 +680,12 @@ const finnishRule = ruleCreator({
|
|
|
647
680
|
}
|
|
648
681
|
});
|
|
649
682
|
|
|
650
|
-
|
|
683
|
+
// src/rules/just.ts
|
|
684
|
+
var justRule = ruleCreator({
|
|
651
685
|
defaultOptions: [],
|
|
652
686
|
meta: {
|
|
653
687
|
docs: {
|
|
654
|
-
description: "
|
|
688
|
+
description: "Require the use of `just` instead of `of`."
|
|
655
689
|
},
|
|
656
690
|
fixable: "code",
|
|
657
691
|
messages: {
|
|
@@ -685,11 +719,12 @@ const justRule = ruleCreator({
|
|
|
685
719
|
}
|
|
686
720
|
});
|
|
687
721
|
|
|
688
|
-
|
|
722
|
+
// src/rules/macro.ts
|
|
723
|
+
var macroRule = ruleCreator({
|
|
689
724
|
defaultOptions: [],
|
|
690
725
|
meta: {
|
|
691
726
|
docs: {
|
|
692
|
-
description: "
|
|
727
|
+
description: "Require the use of the RxJS Tools Babel macro."
|
|
693
728
|
},
|
|
694
729
|
fixable: "code",
|
|
695
730
|
messages: {
|
|
@@ -744,11 +779,12 @@ const macroRule = ruleCreator({
|
|
|
744
779
|
}
|
|
745
780
|
});
|
|
746
781
|
|
|
747
|
-
|
|
782
|
+
// src/rules/no-async-subscribe.ts
|
|
783
|
+
var noAsyncSubscribeRule = ruleCreator({
|
|
748
784
|
defaultOptions: [],
|
|
749
785
|
meta: {
|
|
750
786
|
docs: {
|
|
751
|
-
description: "
|
|
787
|
+
description: "Disallow passing `async` functions to `subscribe`.",
|
|
752
788
|
recommended: true,
|
|
753
789
|
requiresTypeChecking: true
|
|
754
790
|
},
|
|
@@ -786,11 +822,12 @@ const noAsyncSubscribeRule = ruleCreator({
|
|
|
786
822
|
}
|
|
787
823
|
});
|
|
788
824
|
|
|
789
|
-
|
|
825
|
+
// src/rules/no-compat.ts
|
|
826
|
+
var noCompatRule = ruleCreator({
|
|
790
827
|
defaultOptions: [],
|
|
791
828
|
meta: {
|
|
792
829
|
docs: {
|
|
793
|
-
description: "
|
|
830
|
+
description: "Disallow the `rxjs-compat` package."
|
|
794
831
|
},
|
|
795
832
|
messages: {
|
|
796
833
|
forbidden: "'rxjs-compat'-dependent import locations are forbidden."
|
|
@@ -811,11 +848,12 @@ const noCompatRule = ruleCreator({
|
|
|
811
848
|
}
|
|
812
849
|
});
|
|
813
850
|
|
|
814
|
-
|
|
851
|
+
// src/rules/no-connectable.ts
|
|
852
|
+
var noConnectableRule = ruleCreator({
|
|
815
853
|
defaultOptions: [],
|
|
816
854
|
meta: {
|
|
817
855
|
docs: {
|
|
818
|
-
description: "
|
|
856
|
+
description: "Disallow operators that return connectable observables.",
|
|
819
857
|
requiresTypeChecking: true
|
|
820
858
|
},
|
|
821
859
|
messages: {
|
|
@@ -826,7 +864,7 @@ const noConnectableRule = ruleCreator({
|
|
|
826
864
|
},
|
|
827
865
|
name: "no-connectable",
|
|
828
866
|
create: (context) => {
|
|
829
|
-
const { couldBeFunction } = getTypeServices(context);
|
|
867
|
+
const { couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
830
868
|
return {
|
|
831
869
|
"CallExpression[callee.name='multicast']": (node) => {
|
|
832
870
|
if (node.arguments.length === 1) {
|
|
@@ -837,7 +875,7 @@ const noConnectableRule = ruleCreator({
|
|
|
837
875
|
}
|
|
838
876
|
},
|
|
839
877
|
"CallExpression[callee.name=/^(publish|publishBehavior|publishLast|publishReplay)$/]": (node) => {
|
|
840
|
-
if (!node.arguments.some((arg) =>
|
|
878
|
+
if (!node.arguments.some((arg) => couldBeFunction2(arg))) {
|
|
841
879
|
context.report({
|
|
842
880
|
messageId: "forbidden",
|
|
843
881
|
node: node.callee
|
|
@@ -848,11 +886,12 @@ const noConnectableRule = ruleCreator({
|
|
|
848
886
|
}
|
|
849
887
|
});
|
|
850
888
|
|
|
851
|
-
|
|
889
|
+
// src/rules/no-create.ts
|
|
890
|
+
var noCreateRule = ruleCreator({
|
|
852
891
|
defaultOptions: [],
|
|
853
892
|
meta: {
|
|
854
893
|
docs: {
|
|
855
|
-
description: "
|
|
894
|
+
description: "Disallow the static `Observable.create` function.",
|
|
856
895
|
recommended: true,
|
|
857
896
|
requiresTypeChecking: true
|
|
858
897
|
},
|
|
@@ -879,17 +918,23 @@ const noCreateRule = ruleCreator({
|
|
|
879
918
|
}
|
|
880
919
|
});
|
|
881
920
|
|
|
882
|
-
|
|
921
|
+
// src/rules/no-cyclic-action.ts
|
|
922
|
+
import { stripIndent as stripIndent3 } from "common-tags";
|
|
923
|
+
import * as ts5 from "typescript";
|
|
924
|
+
|
|
925
|
+
// src/constants.ts
|
|
926
|
+
var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
|
|
883
927
|
|
|
884
|
-
|
|
928
|
+
// src/rules/no-cyclic-action.ts
|
|
929
|
+
function isTypeReference3(type) {
|
|
885
930
|
return Boolean(type.target);
|
|
886
931
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
defaultOptions:
|
|
932
|
+
var defaultOptions4 = [];
|
|
933
|
+
var noCyclicActionRule = ruleCreator({
|
|
934
|
+
defaultOptions: defaultOptions4,
|
|
890
935
|
meta: {
|
|
891
936
|
docs: {
|
|
892
|
-
description: "
|
|
937
|
+
description: "Disallow cyclic actions in effects and epics.",
|
|
893
938
|
requiresTypeChecking: true
|
|
894
939
|
},
|
|
895
940
|
messages: {
|
|
@@ -898,10 +943,10 @@ const noCyclicActionRule = ruleCreator({
|
|
|
898
943
|
schema: [
|
|
899
944
|
{
|
|
900
945
|
properties: {
|
|
901
|
-
observable: { type: "string" }
|
|
946
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
902
947
|
},
|
|
903
948
|
type: "object",
|
|
904
|
-
description:
|
|
949
|
+
description: stripIndent3`
|
|
905
950
|
An optional object with an optional \`observable\` property.
|
|
906
951
|
The property can be specified as a regular expression string and is used to identify the action observables from which effects and epics are composed.`
|
|
907
952
|
}
|
|
@@ -924,13 +969,13 @@ const noCyclicActionRule = ruleCreator({
|
|
|
924
969
|
const operatorType = getType(operatorCallExpression);
|
|
925
970
|
const [signature] = typeChecker.getSignaturesOfType(
|
|
926
971
|
operatorType,
|
|
927
|
-
|
|
972
|
+
ts5.SignatureKind.Call
|
|
928
973
|
);
|
|
929
974
|
if (!signature) {
|
|
930
975
|
return;
|
|
931
976
|
}
|
|
932
977
|
const operatorReturnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
933
|
-
if (!
|
|
978
|
+
if (!isTypeReference3(operatorReturnType)) {
|
|
934
979
|
return;
|
|
935
980
|
}
|
|
936
981
|
const [operatorElementType] = typeChecker.getTypeArguments(operatorReturnType);
|
|
@@ -938,7 +983,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
938
983
|
return;
|
|
939
984
|
}
|
|
940
985
|
const pipeType = getType(pipeCallExpression);
|
|
941
|
-
if (!
|
|
986
|
+
if (!isTypeReference3(pipeType)) {
|
|
942
987
|
return;
|
|
943
988
|
}
|
|
944
989
|
const [pipeElementType] = typeChecker.getTypeArguments(pipeType);
|
|
@@ -966,7 +1011,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
966
1011
|
return memberActionTypes;
|
|
967
1012
|
}
|
|
968
1013
|
const symbol = typeChecker.getPropertyOfType(type, "type");
|
|
969
|
-
if (!symbol
|
|
1014
|
+
if (!(symbol == null ? void 0 : symbol.valueDeclaration)) {
|
|
970
1015
|
return [];
|
|
971
1016
|
}
|
|
972
1017
|
const actionType = typeChecker.getTypeOfSymbolAtLocation(
|
|
@@ -982,11 +1027,12 @@ const noCyclicActionRule = ruleCreator({
|
|
|
982
1027
|
}
|
|
983
1028
|
});
|
|
984
1029
|
|
|
985
|
-
|
|
1030
|
+
// src/rules/no-explicit-generics.ts
|
|
1031
|
+
var noExplicitGenericsRule = ruleCreator({
|
|
986
1032
|
defaultOptions: [],
|
|
987
1033
|
meta: {
|
|
988
1034
|
docs: {
|
|
989
|
-
description: "
|
|
1035
|
+
description: "Disallow unnecessary explicit generic type arguments."
|
|
990
1036
|
},
|
|
991
1037
|
messages: {
|
|
992
1038
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -1031,13 +1077,14 @@ const noExplicitGenericsRule = ruleCreator({
|
|
|
1031
1077
|
}
|
|
1032
1078
|
});
|
|
1033
1079
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1080
|
+
// src/rules/no-exposed-subjects.ts
|
|
1081
|
+
var defaultAllowedTypesRegExp = /^EventEmitter$/;
|
|
1082
|
+
var defaultOptions5 = [];
|
|
1083
|
+
var noExposedSubjectsRule = ruleCreator({
|
|
1084
|
+
defaultOptions: defaultOptions5,
|
|
1038
1085
|
meta: {
|
|
1039
1086
|
docs: {
|
|
1040
|
-
description: "
|
|
1087
|
+
description: "Disallow public and protected subjects.",
|
|
1041
1088
|
requiresTypeChecking: true
|
|
1042
1089
|
},
|
|
1043
1090
|
messages: {
|
|
@@ -1047,7 +1094,7 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1047
1094
|
schema: [
|
|
1048
1095
|
{
|
|
1049
1096
|
properties: {
|
|
1050
|
-
allowProtected: { type: "boolean" }
|
|
1097
|
+
allowProtected: { type: "boolean", description: "Allow protected subjects.", default: false }
|
|
1051
1098
|
},
|
|
1052
1099
|
type: "object"
|
|
1053
1100
|
}
|
|
@@ -1058,11 +1105,11 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1058
1105
|
create: (context) => {
|
|
1059
1106
|
const [config = {}] = context.options;
|
|
1060
1107
|
const { allowProtected = false } = config;
|
|
1061
|
-
const { couldBeSubject, couldBeType } = getTypeServices(context);
|
|
1108
|
+
const { couldBeSubject, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1062
1109
|
const messageId = allowProtected ? "forbiddenAllowProtected" : "forbidden";
|
|
1063
1110
|
const accessibilityRexExp = allowProtected ? /^(private|protected)$/ : /^private$/;
|
|
1064
1111
|
function isSubject(node) {
|
|
1065
|
-
return couldBeSubject(node) && !
|
|
1112
|
+
return couldBeSubject(node) && !couldBeType2(node, defaultAllowedTypesRegExp);
|
|
1066
1113
|
}
|
|
1067
1114
|
return {
|
|
1068
1115
|
[`PropertyDefinition[accessibility!=${accessibilityRexExp}]`]: (node) => {
|
|
@@ -1134,11 +1181,13 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1134
1181
|
}
|
|
1135
1182
|
});
|
|
1136
1183
|
|
|
1137
|
-
|
|
1184
|
+
// src/rules/no-finnish.ts
|
|
1185
|
+
import { ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
1186
|
+
var noFinnishRule = ruleCreator({
|
|
1138
1187
|
defaultOptions: [],
|
|
1139
1188
|
meta: {
|
|
1140
1189
|
docs: {
|
|
1141
|
-
description: "
|
|
1190
|
+
description: "Disallow Finnish notation.",
|
|
1142
1191
|
requiresTypeChecking: true
|
|
1143
1192
|
},
|
|
1144
1193
|
messages: {
|
|
@@ -1149,7 +1198,7 @@ const noFinnishRule = ruleCreator({
|
|
|
1149
1198
|
},
|
|
1150
1199
|
name: "no-finnish",
|
|
1151
1200
|
create: (context) => {
|
|
1152
|
-
const { esTreeNodeToTSNodeMap } =
|
|
1201
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils4.getParserServices(context);
|
|
1153
1202
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
1154
1203
|
function checkNode(nameNode, typeNode) {
|
|
1155
1204
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
@@ -1221,17 +1270,19 @@ const noFinnishRule = ruleCreator({
|
|
|
1221
1270
|
}
|
|
1222
1271
|
},
|
|
1223
1272
|
"VariableDeclarator[id.name=/[$]+$/]": (node) => {
|
|
1224
|
-
|
|
1273
|
+
var _a;
|
|
1274
|
+
checkNode(node.id, (_a = node.init) != null ? _a : node);
|
|
1225
1275
|
}
|
|
1226
1276
|
};
|
|
1227
1277
|
}
|
|
1228
1278
|
});
|
|
1229
1279
|
|
|
1230
|
-
|
|
1280
|
+
// src/rules/no-ignored-error.ts
|
|
1281
|
+
var noIgnoredErrorRule = ruleCreator({
|
|
1231
1282
|
defaultOptions: [],
|
|
1232
1283
|
meta: {
|
|
1233
1284
|
docs: {
|
|
1234
|
-
description: "
|
|
1285
|
+
description: "Disallow calling `subscribe` without specifying an error handler.",
|
|
1235
1286
|
requiresTypeChecking: true
|
|
1236
1287
|
},
|
|
1237
1288
|
messages: {
|
|
@@ -1242,12 +1293,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1242
1293
|
},
|
|
1243
1294
|
name: "no-ignored-error",
|
|
1244
1295
|
create: (context) => {
|
|
1245
|
-
const { couldBeObservable, couldBeFunction } = getTypeServices(context);
|
|
1296
|
+
const { couldBeObservable, couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
1246
1297
|
return {
|
|
1247
1298
|
"CallExpression[arguments.length > 0] > MemberExpression > Identifier[name='subscribe']": (node) => {
|
|
1248
1299
|
const memberExpression = node.parent;
|
|
1249
1300
|
const callExpression = memberExpression.parent;
|
|
1250
|
-
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) &&
|
|
1301
|
+
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) && couldBeFunction2(callExpression.arguments[0])) {
|
|
1251
1302
|
context.report({
|
|
1252
1303
|
messageId: "forbidden",
|
|
1253
1304
|
node
|
|
@@ -1258,11 +1309,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1258
1309
|
}
|
|
1259
1310
|
});
|
|
1260
1311
|
|
|
1261
|
-
|
|
1312
|
+
// src/rules/no-ignored-notifier.ts
|
|
1313
|
+
var noIgnoredNotifierRule = ruleCreator({
|
|
1262
1314
|
defaultOptions: [],
|
|
1263
1315
|
meta: {
|
|
1264
1316
|
docs: {
|
|
1265
|
-
description: "
|
|
1317
|
+
description: "Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.",
|
|
1266
1318
|
recommended: true,
|
|
1267
1319
|
requiresTypeChecking: true
|
|
1268
1320
|
},
|
|
@@ -1329,11 +1381,12 @@ const noIgnoredNotifierRule = ruleCreator({
|
|
|
1329
1381
|
}
|
|
1330
1382
|
});
|
|
1331
1383
|
|
|
1332
|
-
|
|
1384
|
+
// src/rules/no-ignored-observable.ts
|
|
1385
|
+
var noIgnoredObservableRule = ruleCreator({
|
|
1333
1386
|
defaultOptions: [],
|
|
1334
1387
|
meta: {
|
|
1335
1388
|
docs: {
|
|
1336
|
-
description: "
|
|
1389
|
+
description: "Disallow ignoring observables returned by functions.",
|
|
1337
1390
|
requiresTypeChecking: true
|
|
1338
1391
|
},
|
|
1339
1392
|
messages: {
|
|
@@ -1358,11 +1411,12 @@ const noIgnoredObservableRule = ruleCreator({
|
|
|
1358
1411
|
}
|
|
1359
1412
|
});
|
|
1360
1413
|
|
|
1361
|
-
|
|
1414
|
+
// src/rules/no-ignored-replay-buffer.ts
|
|
1415
|
+
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1362
1416
|
defaultOptions: [],
|
|
1363
1417
|
meta: {
|
|
1364
1418
|
docs: {
|
|
1365
|
-
description: "
|
|
1419
|
+
description: "Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.",
|
|
1366
1420
|
recommended: true
|
|
1367
1421
|
},
|
|
1368
1422
|
messages: {
|
|
@@ -1399,11 +1453,12 @@ const noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1399
1453
|
}
|
|
1400
1454
|
});
|
|
1401
1455
|
|
|
1402
|
-
|
|
1456
|
+
// src/rules/no-ignored-subscribe.ts
|
|
1457
|
+
var noIgnoredSubscribeRule = ruleCreator({
|
|
1403
1458
|
defaultOptions: [],
|
|
1404
1459
|
meta: {
|
|
1405
1460
|
docs: {
|
|
1406
|
-
description: "
|
|
1461
|
+
description: "Disallow calling `subscribe` without specifying arguments.",
|
|
1407
1462
|
requiresTypeChecking: true
|
|
1408
1463
|
},
|
|
1409
1464
|
messages: {
|
|
@@ -1414,11 +1469,11 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1414
1469
|
},
|
|
1415
1470
|
name: "no-ignored-subscribe",
|
|
1416
1471
|
create: (context) => {
|
|
1417
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1472
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1418
1473
|
return {
|
|
1419
1474
|
"CallExpression[arguments.length = 0][callee.property.name='subscribe']": (node) => {
|
|
1420
1475
|
const callee = node.callee;
|
|
1421
|
-
if (couldBeObservable(callee.object) ||
|
|
1476
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
1422
1477
|
context.report({
|
|
1423
1478
|
messageId: "forbidden",
|
|
1424
1479
|
node: callee.property
|
|
@@ -1429,11 +1484,12 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1429
1484
|
}
|
|
1430
1485
|
});
|
|
1431
1486
|
|
|
1432
|
-
|
|
1487
|
+
// src/rules/no-ignored-subscription.ts
|
|
1488
|
+
var noIgnoredSubscriptionRule = ruleCreator({
|
|
1433
1489
|
defaultOptions: [],
|
|
1434
1490
|
meta: {
|
|
1435
1491
|
docs: {
|
|
1436
|
-
description: "
|
|
1492
|
+
description: "Disallow ignoring the subscription returned by `subscribe`.",
|
|
1437
1493
|
requiresTypeChecking: true
|
|
1438
1494
|
},
|
|
1439
1495
|
messages: {
|
|
@@ -1444,12 +1500,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1444
1500
|
},
|
|
1445
1501
|
name: "no-ignored-subscription",
|
|
1446
1502
|
create: (context) => {
|
|
1447
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1503
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1448
1504
|
return {
|
|
1449
1505
|
"ExpressionStatement > CallExpression > MemberExpression[property.name='subscribe']": (node) => {
|
|
1450
1506
|
if (couldBeObservable(node.object)) {
|
|
1451
1507
|
const callExpression = node.parent;
|
|
1452
|
-
if (callExpression.arguments.length === 1 &&
|
|
1508
|
+
if (callExpression.arguments.length === 1 && couldBeType2(callExpression.arguments[0], "Subscriber")) {
|
|
1453
1509
|
return;
|
|
1454
1510
|
}
|
|
1455
1511
|
context.report({
|
|
@@ -1462,11 +1518,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1462
1518
|
}
|
|
1463
1519
|
});
|
|
1464
1520
|
|
|
1465
|
-
|
|
1521
|
+
// src/rules/no-ignored-takewhile-value.ts
|
|
1522
|
+
var noIgnoredTakewhileValueRule = ruleCreator({
|
|
1466
1523
|
defaultOptions: [],
|
|
1467
1524
|
meta: {
|
|
1468
1525
|
docs: {
|
|
1469
|
-
description: "
|
|
1526
|
+
description: "Disallow ignoring the value within `takeWhile`.",
|
|
1470
1527
|
recommended: true
|
|
1471
1528
|
},
|
|
1472
1529
|
messages: {
|
|
@@ -1487,7 +1544,7 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1487
1544
|
if (param) {
|
|
1488
1545
|
if (isIdentifier(param)) {
|
|
1489
1546
|
const variable = scope.variables.find(
|
|
1490
|
-
({ name }) =>
|
|
1547
|
+
({ name: name2 }) => name2 === param.name
|
|
1491
1548
|
);
|
|
1492
1549
|
if (variable && variable.references.length > 0) {
|
|
1493
1550
|
ignored = false;
|
|
@@ -1516,17 +1573,21 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1516
1573
|
}
|
|
1517
1574
|
});
|
|
1518
1575
|
|
|
1576
|
+
// src/rules/no-implicit-any-catch.ts
|
|
1577
|
+
import {
|
|
1578
|
+
AST_NODE_TYPES as AST_NODE_TYPES6
|
|
1579
|
+
} from "@typescript-eslint/utils";
|
|
1519
1580
|
function isParenthesised(sourceCode, node) {
|
|
1520
1581
|
const before = sourceCode.getTokenBefore(node);
|
|
1521
1582
|
const after = sourceCode.getTokenAfter(node);
|
|
1522
1583
|
return before && after && before.value === "(" && before.range[1] <= node.range[0] && after.value === ")" && after.range[0] >= node.range[1];
|
|
1523
1584
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
defaultOptions:
|
|
1585
|
+
var defaultOptions6 = [];
|
|
1586
|
+
var noImplicitAnyCatchRule = ruleCreator({
|
|
1587
|
+
defaultOptions: defaultOptions6,
|
|
1527
1588
|
meta: {
|
|
1528
1589
|
docs: {
|
|
1529
|
-
description: "
|
|
1590
|
+
description: "Disallow implicit `any` error parameters in `catchError` operators.",
|
|
1530
1591
|
recommended: true,
|
|
1531
1592
|
requiresTypeChecking: true
|
|
1532
1593
|
},
|
|
@@ -1543,7 +1604,9 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1543
1604
|
additionalProperties: false,
|
|
1544
1605
|
properties: {
|
|
1545
1606
|
allowExplicitAny: {
|
|
1546
|
-
type: "boolean"
|
|
1607
|
+
type: "boolean",
|
|
1608
|
+
description: "Allow error variable to be explicitly typed as `any`.",
|
|
1609
|
+
default: false
|
|
1547
1610
|
}
|
|
1548
1611
|
},
|
|
1549
1612
|
type: "object"
|
|
@@ -1568,41 +1631,43 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1568
1631
|
const {
|
|
1569
1632
|
typeAnnotation: { type }
|
|
1570
1633
|
} = typeAnnotation;
|
|
1571
|
-
if (type ===
|
|
1572
|
-
let
|
|
1634
|
+
if (type === AST_NODE_TYPES6.TSAnyKeyword) {
|
|
1635
|
+
let fix2 = function(fixer) {
|
|
1573
1636
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1574
1637
|
};
|
|
1638
|
+
var fix = fix2;
|
|
1575
1639
|
if (allowExplicitAny) {
|
|
1576
1640
|
return;
|
|
1577
1641
|
}
|
|
1578
1642
|
context.report({
|
|
1579
|
-
fix,
|
|
1643
|
+
fix: fix2,
|
|
1580
1644
|
messageId: "explicitAny",
|
|
1581
1645
|
node: param,
|
|
1582
1646
|
suggest: [
|
|
1583
1647
|
{
|
|
1584
1648
|
messageId: "suggestExplicitUnknown",
|
|
1585
|
-
fix
|
|
1649
|
+
fix: fix2
|
|
1586
1650
|
}
|
|
1587
1651
|
]
|
|
1588
1652
|
});
|
|
1589
|
-
} else if (type !==
|
|
1590
|
-
let
|
|
1653
|
+
} else if (type !== AST_NODE_TYPES6.TSUnknownKeyword) {
|
|
1654
|
+
let fix2 = function(fixer) {
|
|
1591
1655
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1592
1656
|
};
|
|
1657
|
+
var fix = fix2;
|
|
1593
1658
|
context.report({
|
|
1594
1659
|
messageId: "narrowed",
|
|
1595
1660
|
node: param,
|
|
1596
1661
|
suggest: [
|
|
1597
1662
|
{
|
|
1598
1663
|
messageId: "suggestExplicitUnknown",
|
|
1599
|
-
fix
|
|
1664
|
+
fix: fix2
|
|
1600
1665
|
}
|
|
1601
1666
|
]
|
|
1602
1667
|
});
|
|
1603
1668
|
}
|
|
1604
1669
|
} else {
|
|
1605
|
-
let
|
|
1670
|
+
let fix2 = function(fixer) {
|
|
1606
1671
|
if (isParenthesised(sourceCode, param)) {
|
|
1607
1672
|
return fixer.insertTextAfter(param, ": unknown");
|
|
1608
1673
|
}
|
|
@@ -1611,14 +1676,15 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1611
1676
|
fixer.insertTextAfter(param, ": unknown)")
|
|
1612
1677
|
];
|
|
1613
1678
|
};
|
|
1679
|
+
var fix = fix2;
|
|
1614
1680
|
context.report({
|
|
1615
|
-
fix,
|
|
1681
|
+
fix: fix2,
|
|
1616
1682
|
messageId: "implicitAny",
|
|
1617
1683
|
node: param,
|
|
1618
1684
|
suggest: [
|
|
1619
1685
|
{
|
|
1620
1686
|
messageId: "suggestExplicitUnknown",
|
|
1621
|
-
fix
|
|
1687
|
+
fix: fix2
|
|
1622
1688
|
}
|
|
1623
1689
|
]
|
|
1624
1690
|
});
|
|
@@ -1654,11 +1720,12 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1654
1720
|
}
|
|
1655
1721
|
});
|
|
1656
1722
|
|
|
1657
|
-
|
|
1723
|
+
// src/rules/no-index.ts
|
|
1724
|
+
var noIndexRule = ruleCreator({
|
|
1658
1725
|
defaultOptions: [],
|
|
1659
1726
|
meta: {
|
|
1660
1727
|
docs: {
|
|
1661
|
-
description: "
|
|
1728
|
+
description: "Disallow importing index modules.",
|
|
1662
1729
|
recommended: true
|
|
1663
1730
|
},
|
|
1664
1731
|
messages: {
|
|
@@ -1680,11 +1747,12 @@ const noIndexRule = ruleCreator({
|
|
|
1680
1747
|
}
|
|
1681
1748
|
});
|
|
1682
1749
|
|
|
1683
|
-
|
|
1750
|
+
// src/rules/no-internal.ts
|
|
1751
|
+
var noInternalRule = ruleCreator({
|
|
1684
1752
|
defaultOptions: [],
|
|
1685
1753
|
meta: {
|
|
1686
1754
|
docs: {
|
|
1687
|
-
description: "
|
|
1755
|
+
description: "Disallow importing internal modules.",
|
|
1688
1756
|
recommended: true
|
|
1689
1757
|
},
|
|
1690
1758
|
fixable: "code",
|
|
@@ -1734,14 +1802,15 @@ const noInternalRule = ruleCreator({
|
|
|
1734
1802
|
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002finternal/]`]: (node) => {
|
|
1735
1803
|
const replacement = getReplacement(node.raw);
|
|
1736
1804
|
if (replacement) {
|
|
1737
|
-
let
|
|
1805
|
+
let fix2 = function(fixer) {
|
|
1738
1806
|
return fixer.replaceText(node, replacement);
|
|
1739
1807
|
};
|
|
1808
|
+
var fix = fix2;
|
|
1740
1809
|
context.report({
|
|
1741
|
-
fix,
|
|
1810
|
+
fix: fix2,
|
|
1742
1811
|
messageId: "forbidden",
|
|
1743
1812
|
node,
|
|
1744
|
-
suggest: [{ fix, messageId: "suggest" }]
|
|
1813
|
+
suggest: [{ fix: fix2, messageId: "suggest" }]
|
|
1745
1814
|
});
|
|
1746
1815
|
} else {
|
|
1747
1816
|
context.report({
|
|
@@ -1754,11 +1823,12 @@ const noInternalRule = ruleCreator({
|
|
|
1754
1823
|
}
|
|
1755
1824
|
});
|
|
1756
1825
|
|
|
1757
|
-
|
|
1826
|
+
// src/rules/no-nested-subscribe.ts
|
|
1827
|
+
var noNestedSubscribeRule = ruleCreator({
|
|
1758
1828
|
defaultOptions: [],
|
|
1759
1829
|
meta: {
|
|
1760
1830
|
docs: {
|
|
1761
|
-
description: "
|
|
1831
|
+
description: "Disallow calling `subscribe` within a `subscribe` callback.",
|
|
1762
1832
|
recommended: true,
|
|
1763
1833
|
requiresTypeChecking: true
|
|
1764
1834
|
},
|
|
@@ -1770,11 +1840,11 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1770
1840
|
},
|
|
1771
1841
|
name: "no-nested-subscribe",
|
|
1772
1842
|
create: (context) => {
|
|
1773
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1843
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1774
1844
|
const argumentsMap = /* @__PURE__ */ new WeakMap();
|
|
1775
1845
|
return {
|
|
1776
1846
|
[`CallExpression > MemberExpression[property.name='subscribe']`]: (node) => {
|
|
1777
|
-
if (!couldBeObservable(node.object) && !
|
|
1847
|
+
if (!couldBeObservable(node.object) && !couldBeType2(node.object, "Subscribable")) {
|
|
1778
1848
|
return;
|
|
1779
1849
|
}
|
|
1780
1850
|
const callExpression = node.parent;
|
|
@@ -1797,11 +1867,12 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1797
1867
|
}
|
|
1798
1868
|
});
|
|
1799
1869
|
|
|
1800
|
-
|
|
1870
|
+
// src/rules/no-redundant-notify.ts
|
|
1871
|
+
var noRedundantNotifyRule = ruleCreator({
|
|
1801
1872
|
defaultOptions: [],
|
|
1802
1873
|
meta: {
|
|
1803
1874
|
docs: {
|
|
1804
|
-
description: "
|
|
1875
|
+
description: "Disallow sending redundant notifications from completed or errored observables.",
|
|
1805
1876
|
recommended: true,
|
|
1806
1877
|
requiresTypeChecking: true
|
|
1807
1878
|
},
|
|
@@ -1814,7 +1885,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1814
1885
|
name: "no-redundant-notify",
|
|
1815
1886
|
create: (context) => {
|
|
1816
1887
|
const sourceCode = context.sourceCode;
|
|
1817
|
-
const { couldBeType } = getTypeServices(context);
|
|
1888
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1818
1889
|
return {
|
|
1819
1890
|
"ExpressionStatement[expression.callee.property.name=/^(complete|error)$/] + ExpressionStatement[expression.callee.property.name=/^(next|complete|error)$/]": (node) => {
|
|
1820
1891
|
const parent = node.parent;
|
|
@@ -1830,7 +1901,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1830
1901
|
if (getExpressionText(sibling, sourceCode) !== getExpressionText(node, sourceCode)) {
|
|
1831
1902
|
return;
|
|
1832
1903
|
}
|
|
1833
|
-
if (!isExpressionObserver(sibling,
|
|
1904
|
+
if (!isExpressionObserver(sibling, couldBeType2) || !isExpressionObserver(node, couldBeType2)) {
|
|
1834
1905
|
return;
|
|
1835
1906
|
}
|
|
1836
1907
|
const { expression } = node;
|
|
@@ -1861,7 +1932,7 @@ function getExpressionText(expressionStatement, sourceCode) {
|
|
|
1861
1932
|
const { object } = callExpression.callee;
|
|
1862
1933
|
return sourceCode.getText(object);
|
|
1863
1934
|
}
|
|
1864
|
-
function isExpressionObserver(expressionStatement,
|
|
1935
|
+
function isExpressionObserver(expressionStatement, couldBeType2) {
|
|
1865
1936
|
if (!isCallExpression(expressionStatement.expression)) {
|
|
1866
1937
|
return false;
|
|
1867
1938
|
}
|
|
@@ -1870,15 +1941,17 @@ function isExpressionObserver(expressionStatement, couldBeType) {
|
|
|
1870
1941
|
return false;
|
|
1871
1942
|
}
|
|
1872
1943
|
const { object } = callExpression.callee;
|
|
1873
|
-
return
|
|
1944
|
+
return couldBeType2(object, /^(Subject|Subscriber)$/);
|
|
1874
1945
|
}
|
|
1875
1946
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1947
|
+
// src/rules/no-sharereplay.ts
|
|
1948
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES7 } from "@typescript-eslint/utils";
|
|
1949
|
+
var defaultOptions7 = [];
|
|
1950
|
+
var noSharereplayRule = ruleCreator({
|
|
1951
|
+
defaultOptions: defaultOptions7,
|
|
1879
1952
|
meta: {
|
|
1880
1953
|
docs: {
|
|
1881
|
-
description: "
|
|
1954
|
+
description: "Disallow unsafe `shareReplay` usage.",
|
|
1882
1955
|
recommended: true
|
|
1883
1956
|
},
|
|
1884
1957
|
messages: {
|
|
@@ -1888,7 +1961,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1888
1961
|
schema: [
|
|
1889
1962
|
{
|
|
1890
1963
|
properties: {
|
|
1891
|
-
allowConfig: { type: "boolean" }
|
|
1964
|
+
allowConfig: { type: "boolean", description: "Allow shareReplay if a config argument is specified.", default: true }
|
|
1892
1965
|
},
|
|
1893
1966
|
type: "object"
|
|
1894
1967
|
}
|
|
@@ -1903,7 +1976,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1903
1976
|
"CallExpression[callee.name='shareReplay']": (node) => {
|
|
1904
1977
|
let report = true;
|
|
1905
1978
|
if (allowConfig) {
|
|
1906
|
-
report = node.arguments.length !== 1 || node.arguments[0].type !==
|
|
1979
|
+
report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES7.ObjectExpression;
|
|
1907
1980
|
}
|
|
1908
1981
|
if (report) {
|
|
1909
1982
|
context.report({
|
|
@@ -1916,11 +1989,12 @@ const noSharereplayRule = ruleCreator({
|
|
|
1916
1989
|
}
|
|
1917
1990
|
});
|
|
1918
1991
|
|
|
1919
|
-
|
|
1992
|
+
// src/rules/no-subclass.ts
|
|
1993
|
+
var noSubclassRule = ruleCreator({
|
|
1920
1994
|
defaultOptions: [],
|
|
1921
1995
|
meta: {
|
|
1922
1996
|
docs: {
|
|
1923
|
-
description: "
|
|
1997
|
+
description: "Disallow subclassing RxJS classes.",
|
|
1924
1998
|
requiresTypeChecking: true
|
|
1925
1999
|
},
|
|
1926
2000
|
messages: {
|
|
@@ -1931,7 +2005,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1931
2005
|
},
|
|
1932
2006
|
name: "no-subclass",
|
|
1933
2007
|
create: (context) => {
|
|
1934
|
-
const { couldBeType } = getTypeServices(context);
|
|
2008
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1935
2009
|
const queryNames = [
|
|
1936
2010
|
"AsyncSubject",
|
|
1937
2011
|
"BehaviorSubject",
|
|
@@ -1946,7 +2020,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1946
2020
|
"|"
|
|
1947
2021
|
)})$/] > Identifier.superClass`]: (node) => {
|
|
1948
2022
|
if (queryNames.some(
|
|
1949
|
-
(
|
|
2023
|
+
(name2) => couldBeType2(node, name2, { name: /[/\\]rxjs[/\\]/ })
|
|
1950
2024
|
)) {
|
|
1951
2025
|
context.report({
|
|
1952
2026
|
messageId: "forbidden",
|
|
@@ -1958,11 +2032,12 @@ const noSubclassRule = ruleCreator({
|
|
|
1958
2032
|
}
|
|
1959
2033
|
});
|
|
1960
2034
|
|
|
1961
|
-
|
|
2035
|
+
// src/rules/no-subject-unsubscribe.ts
|
|
2036
|
+
var noSubjectUnsubscribeRule = ruleCreator({
|
|
1962
2037
|
defaultOptions: [],
|
|
1963
2038
|
meta: {
|
|
1964
2039
|
docs: {
|
|
1965
|
-
description: "
|
|
2040
|
+
description: "Disallow calling the `unsubscribe` method of subjects.",
|
|
1966
2041
|
recommended: true,
|
|
1967
2042
|
requiresTypeChecking: true
|
|
1968
2043
|
},
|
|
@@ -2000,11 +2075,12 @@ const noSubjectUnsubscribeRule = ruleCreator({
|
|
|
2000
2075
|
}
|
|
2001
2076
|
});
|
|
2002
2077
|
|
|
2003
|
-
|
|
2078
|
+
// src/rules/no-subject-value.ts
|
|
2079
|
+
var noSubjectValueRule = ruleCreator({
|
|
2004
2080
|
defaultOptions: [],
|
|
2005
2081
|
meta: {
|
|
2006
2082
|
docs: {
|
|
2007
|
-
description: "
|
|
2083
|
+
description: "Disallow accessing the `value` property of a `BehaviorSubject` instance.",
|
|
2008
2084
|
requiresTypeChecking: true
|
|
2009
2085
|
},
|
|
2010
2086
|
messages: {
|
|
@@ -2033,11 +2109,12 @@ const noSubjectValueRule = ruleCreator({
|
|
|
2033
2109
|
}
|
|
2034
2110
|
});
|
|
2035
2111
|
|
|
2036
|
-
|
|
2112
|
+
// src/rules/no-subscribe-handlers.ts
|
|
2113
|
+
var noSubscribeHandlersRule = ruleCreator({
|
|
2037
2114
|
defaultOptions: [],
|
|
2038
2115
|
meta: {
|
|
2039
2116
|
docs: {
|
|
2040
|
-
description: "
|
|
2117
|
+
description: "Disallow passing handlers to `subscribe`.",
|
|
2041
2118
|
requiresTypeChecking: true
|
|
2042
2119
|
},
|
|
2043
2120
|
messages: {
|
|
@@ -2048,11 +2125,11 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2048
2125
|
},
|
|
2049
2126
|
name: "no-subscribe-handlers",
|
|
2050
2127
|
create: (context) => {
|
|
2051
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
2128
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2052
2129
|
return {
|
|
2053
2130
|
"CallExpression[arguments.length > 0][callee.property.name='subscribe']": (node) => {
|
|
2054
2131
|
const callee = node.callee;
|
|
2055
|
-
if (couldBeObservable(callee.object) ||
|
|
2132
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
2056
2133
|
context.report({
|
|
2057
2134
|
messageId: "forbidden",
|
|
2058
2135
|
node: callee.property
|
|
@@ -2063,12 +2140,13 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2063
2140
|
}
|
|
2064
2141
|
});
|
|
2065
2142
|
|
|
2066
|
-
|
|
2143
|
+
// src/rules/no-tap.ts
|
|
2144
|
+
var noTapRule = ruleCreator({
|
|
2067
2145
|
defaultOptions: [],
|
|
2068
2146
|
meta: {
|
|
2069
2147
|
deprecated: true,
|
|
2070
2148
|
docs: {
|
|
2071
|
-
description: "
|
|
2149
|
+
description: "Disallow the `tap` operator."
|
|
2072
2150
|
},
|
|
2073
2151
|
messages: {
|
|
2074
2152
|
forbidden: "The tap operator is forbidden."
|
|
@@ -2097,11 +2175,12 @@ const noTapRule = ruleCreator({
|
|
|
2097
2175
|
}
|
|
2098
2176
|
});
|
|
2099
2177
|
|
|
2100
|
-
|
|
2178
|
+
// src/rules/no-topromise.ts
|
|
2179
|
+
var noTopromiseRule = ruleCreator({
|
|
2101
2180
|
defaultOptions: [],
|
|
2102
2181
|
meta: {
|
|
2103
2182
|
docs: {
|
|
2104
|
-
description: "
|
|
2183
|
+
description: "Disallow use of the `toPromise` method.",
|
|
2105
2184
|
requiresTypeChecking: true
|
|
2106
2185
|
},
|
|
2107
2186
|
messages: {
|
|
@@ -2126,11 +2205,12 @@ const noTopromiseRule = ruleCreator({
|
|
|
2126
2205
|
}
|
|
2127
2206
|
});
|
|
2128
2207
|
|
|
2129
|
-
|
|
2208
|
+
// src/rules/no-unbound-methods.ts
|
|
2209
|
+
var noUnboundMethodsRule = ruleCreator({
|
|
2130
2210
|
defaultOptions: [],
|
|
2131
2211
|
meta: {
|
|
2132
2212
|
docs: {
|
|
2133
|
-
description: "
|
|
2213
|
+
description: "Disallow passing unbound methods.",
|
|
2134
2214
|
recommended: true,
|
|
2135
2215
|
requiresTypeChecking: true
|
|
2136
2216
|
},
|
|
@@ -2187,12 +2267,14 @@ const noUnboundMethodsRule = ruleCreator({
|
|
|
2187
2267
|
}
|
|
2188
2268
|
});
|
|
2189
2269
|
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2270
|
+
// src/rules/no-unsafe-catch.ts
|
|
2271
|
+
import { stripIndent as stripIndent4 } from "common-tags";
|
|
2272
|
+
var defaultOptions8 = [];
|
|
2273
|
+
var noUnsafeCatchRule = ruleCreator({
|
|
2274
|
+
defaultOptions: defaultOptions8,
|
|
2193
2275
|
meta: {
|
|
2194
2276
|
docs: {
|
|
2195
|
-
description: "
|
|
2277
|
+
description: "Disallow unsafe `catchError` usage in effects and epics.",
|
|
2196
2278
|
requiresTypeChecking: true
|
|
2197
2279
|
},
|
|
2198
2280
|
messages: {
|
|
@@ -2201,10 +2283,10 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2201
2283
|
schema: [
|
|
2202
2284
|
{
|
|
2203
2285
|
properties: {
|
|
2204
|
-
observable: { type: "string" }
|
|
2286
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2205
2287
|
},
|
|
2206
2288
|
type: "object",
|
|
2207
|
-
description:
|
|
2289
|
+
description: stripIndent4`
|
|
2208
2290
|
An optional object with an optional \`observable\` property.
|
|
2209
2291
|
The property can be specified as a regular expression string and is used to identify the action observables from which effects and epics are composed.`
|
|
2210
2292
|
}
|
|
@@ -2246,12 +2328,14 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2246
2328
|
}
|
|
2247
2329
|
});
|
|
2248
2330
|
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2331
|
+
// src/rules/no-unsafe-first.ts
|
|
2332
|
+
import { stripIndent as stripIndent5 } from "common-tags";
|
|
2333
|
+
var defaultOptions9 = [];
|
|
2334
|
+
var noUnsafeFirstRule = ruleCreator({
|
|
2335
|
+
defaultOptions: defaultOptions9,
|
|
2252
2336
|
meta: {
|
|
2253
2337
|
docs: {
|
|
2254
|
-
description: "
|
|
2338
|
+
description: "Disallow unsafe `first`/`take` usage in effects and epics.",
|
|
2255
2339
|
requiresTypeChecking: true
|
|
2256
2340
|
},
|
|
2257
2341
|
messages: {
|
|
@@ -2260,10 +2344,10 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2260
2344
|
schema: [
|
|
2261
2345
|
{
|
|
2262
2346
|
properties: {
|
|
2263
|
-
observable: { type: "string" }
|
|
2347
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2264
2348
|
},
|
|
2265
2349
|
type: "object",
|
|
2266
|
-
description:
|
|
2350
|
+
description: stripIndent5`
|
|
2267
2351
|
An optional object with an optional \`observable\` property.
|
|
2268
2352
|
The property can be specified as a regular expression string and is used to identify the action observables from which effects and epics are composed.`
|
|
2269
2353
|
}
|
|
@@ -2314,11 +2398,14 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2314
2398
|
}
|
|
2315
2399
|
});
|
|
2316
2400
|
|
|
2317
|
-
|
|
2401
|
+
// src/rules/no-unsafe-subject-next.ts
|
|
2402
|
+
import * as tsutils3 from "ts-api-utils";
|
|
2403
|
+
import * as ts6 from "typescript";
|
|
2404
|
+
var noUnsafeSubjectNext = ruleCreator({
|
|
2318
2405
|
defaultOptions: [],
|
|
2319
2406
|
meta: {
|
|
2320
2407
|
docs: {
|
|
2321
|
-
description: "
|
|
2408
|
+
description: "Disallow unsafe optional `next` calls.",
|
|
2322
2409
|
recommended: true,
|
|
2323
2410
|
requiresTypeChecking: true
|
|
2324
2411
|
},
|
|
@@ -2335,19 +2422,19 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2335
2422
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
2336
2423
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
2337
2424
|
const type = getType(node.callee.object);
|
|
2338
|
-
if (
|
|
2425
|
+
if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
2339
2426
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
2340
|
-
if (
|
|
2427
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
|
|
2341
2428
|
return;
|
|
2342
2429
|
}
|
|
2343
|
-
if (
|
|
2430
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
|
|
2344
2431
|
return;
|
|
2345
2432
|
}
|
|
2346
|
-
if (
|
|
2433
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
|
|
2347
2434
|
return;
|
|
2348
2435
|
}
|
|
2349
|
-
if (
|
|
2350
|
-
(t) =>
|
|
2436
|
+
if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
|
|
2437
|
+
(t) => tsutils3.isTypeFlagSet(t, ts6.TypeFlags.Void)
|
|
2351
2438
|
)) {
|
|
2352
2439
|
return;
|
|
2353
2440
|
}
|
|
@@ -2362,12 +2449,15 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2362
2449
|
}
|
|
2363
2450
|
});
|
|
2364
2451
|
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2452
|
+
// src/rules/no-unsafe-switchmap.ts
|
|
2453
|
+
import { stripIndent as stripIndent6 } from "common-tags";
|
|
2454
|
+
import decamelize from "decamelize";
|
|
2455
|
+
var defaultOptions10 = [];
|
|
2456
|
+
var noUnsafeSwitchmapRule = ruleCreator({
|
|
2457
|
+
defaultOptions: defaultOptions10,
|
|
2368
2458
|
meta: {
|
|
2369
2459
|
docs: {
|
|
2370
|
-
description: "
|
|
2460
|
+
description: "Disallow unsafe `switchMap` usage in effects and epics.",
|
|
2371
2461
|
requiresTypeChecking: true
|
|
2372
2462
|
},
|
|
2373
2463
|
messages: {
|
|
@@ -2377,26 +2467,27 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2377
2467
|
{
|
|
2378
2468
|
properties: {
|
|
2379
2469
|
allow: {
|
|
2470
|
+
description: "Action types that are allowed to be used with switchMap. Mutually exclusive with `disallow`.",
|
|
2380
2471
|
oneOf: [
|
|
2381
|
-
{ type: "string" },
|
|
2382
|
-
{ type: "array", items: { type: "string" } }
|
|
2472
|
+
{ type: "string", description: "A regular expression string." },
|
|
2473
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2383
2474
|
]
|
|
2384
2475
|
},
|
|
2385
2476
|
disallow: {
|
|
2477
|
+
description: "Action types that are disallowed to be used with switchMap. Mutually exclusive with `allow`.",
|
|
2386
2478
|
oneOf: [
|
|
2387
|
-
{ type: "string" },
|
|
2388
|
-
{ type: "array", items: { type: "string" } }
|
|
2479
|
+
{ type: "string", description: "A regular expression string." },
|
|
2480
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2389
2481
|
]
|
|
2390
2482
|
},
|
|
2391
2483
|
observable: {
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
]
|
|
2484
|
+
type: "string",
|
|
2485
|
+
description: "A RegExp that matches an effect or epic's actions observable.",
|
|
2486
|
+
default: defaultObservable
|
|
2396
2487
|
}
|
|
2397
2488
|
},
|
|
2398
2489
|
type: "object",
|
|
2399
|
-
description:
|
|
2490
|
+
description: stripIndent6`
|
|
2400
2491
|
An optional object with optional \`allow\`, \`disallow\` and \`observable\` properties.
|
|
2401
2492
|
The properties can be specified as regular expression strings or as arrays of words.
|
|
2402
2493
|
The \`allow\` or \`disallow\` properties are mutually exclusive. Whether or not
|
|
@@ -2409,6 +2500,7 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2409
2500
|
},
|
|
2410
2501
|
name: "no-unsafe-switchmap",
|
|
2411
2502
|
create: (context) => {
|
|
2503
|
+
var _a, _b, _c;
|
|
2412
2504
|
const defaultDisallow = [
|
|
2413
2505
|
"add",
|
|
2414
2506
|
"create",
|
|
@@ -2424,9 +2516,9 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2424
2516
|
let observableRegExp;
|
|
2425
2517
|
const [config = {}] = context.options;
|
|
2426
2518
|
if (config.allow || config.disallow) {
|
|
2427
|
-
allowRegExp = createRegExpForWords(config.allow
|
|
2428
|
-
disallowRegExp = createRegExpForWords(config.disallow
|
|
2429
|
-
observableRegExp = new RegExp(config.observable
|
|
2519
|
+
allowRegExp = createRegExpForWords((_a = config.allow) != null ? _a : []);
|
|
2520
|
+
disallowRegExp = createRegExpForWords((_b = config.disallow) != null ? _b : []);
|
|
2521
|
+
observableRegExp = new RegExp((_c = config.observable) != null ? _c : defaultObservable);
|
|
2430
2522
|
} else {
|
|
2431
2523
|
allowRegExp = void 0;
|
|
2432
2524
|
disallowRegExp = createRegExpForWords(defaultDisallow);
|
|
@@ -2445,12 +2537,12 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2445
2537
|
return arg.property.name;
|
|
2446
2538
|
}
|
|
2447
2539
|
return "";
|
|
2448
|
-
}).map((
|
|
2540
|
+
}).map((name2) => decamelize(name2));
|
|
2449
2541
|
if (allowRegExp) {
|
|
2450
|
-
return !names.every((
|
|
2542
|
+
return !names.every((name2) => allowRegExp == null ? void 0 : allowRegExp.test(name2));
|
|
2451
2543
|
}
|
|
2452
2544
|
if (disallowRegExp) {
|
|
2453
|
-
return names.some((
|
|
2545
|
+
return names.some((name2) => disallowRegExp == null ? void 0 : disallowRegExp.test(name2));
|
|
2454
2546
|
}
|
|
2455
2547
|
return false;
|
|
2456
2548
|
}
|
|
@@ -2483,12 +2575,37 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2483
2575
|
}
|
|
2484
2576
|
});
|
|
2485
2577
|
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2578
|
+
// src/rules/no-unsafe-takeuntil.ts
|
|
2579
|
+
import { stripIndent as stripIndent7 } from "common-tags";
|
|
2580
|
+
var defaultOptions11 = [];
|
|
2581
|
+
var allowedOperators = [
|
|
2582
|
+
"count",
|
|
2583
|
+
"defaultIfEmpty",
|
|
2584
|
+
"endWith",
|
|
2585
|
+
"every",
|
|
2586
|
+
"finalize",
|
|
2587
|
+
"finally",
|
|
2588
|
+
"isEmpty",
|
|
2589
|
+
"last",
|
|
2590
|
+
"max",
|
|
2591
|
+
"min",
|
|
2592
|
+
"publish",
|
|
2593
|
+
"publishBehavior",
|
|
2594
|
+
"publishLast",
|
|
2595
|
+
"publishReplay",
|
|
2596
|
+
"reduce",
|
|
2597
|
+
"share",
|
|
2598
|
+
"shareReplay",
|
|
2599
|
+
"skipLast",
|
|
2600
|
+
"takeLast",
|
|
2601
|
+
"throwIfEmpty",
|
|
2602
|
+
"toArray"
|
|
2603
|
+
];
|
|
2604
|
+
var noUnsafeTakeuntilRule = ruleCreator({
|
|
2605
|
+
defaultOptions: defaultOptions11,
|
|
2489
2606
|
meta: {
|
|
2490
2607
|
docs: {
|
|
2491
|
-
description: "
|
|
2608
|
+
description: "Disallow applying operators after `takeUntil`.",
|
|
2492
2609
|
recommended: true,
|
|
2493
2610
|
requiresTypeChecking: true
|
|
2494
2611
|
},
|
|
@@ -2498,11 +2615,11 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2498
2615
|
schema: [
|
|
2499
2616
|
{
|
|
2500
2617
|
properties: {
|
|
2501
|
-
alias: { type: "array", items: { type: "string" } },
|
|
2502
|
-
allow: { type: "array", items: { type: "string" } }
|
|
2618
|
+
alias: { type: "array", items: { type: "string" }, description: "An array of operator names that should be treated similarly to `takeUntil`." },
|
|
2619
|
+
allow: { type: "array", items: { type: "string" }, description: "An array of operator names that are allowed to follow `takeUntil`.", default: allowedOperators }
|
|
2503
2620
|
},
|
|
2504
2621
|
type: "object",
|
|
2505
|
-
description:
|
|
2622
|
+
description: stripIndent7`
|
|
2506
2623
|
An optional object with optional \`alias\` and \`allow\` properties.
|
|
2507
2624
|
The \`alias\` property is an array containing the names of operators that aliases for \`takeUntil\`.
|
|
2508
2625
|
The \`allow\` property is an array containing the names of the operators that are allowed to follow \`takeUntil\`.`
|
|
@@ -2513,29 +2630,6 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2513
2630
|
name: "no-unsafe-takeuntil",
|
|
2514
2631
|
create: (context) => {
|
|
2515
2632
|
let checkedOperatorsRegExp = /^takeUntil$/;
|
|
2516
|
-
const allowedOperators = [
|
|
2517
|
-
"count",
|
|
2518
|
-
"defaultIfEmpty",
|
|
2519
|
-
"endWith",
|
|
2520
|
-
"every",
|
|
2521
|
-
"finalize",
|
|
2522
|
-
"finally",
|
|
2523
|
-
"isEmpty",
|
|
2524
|
-
"last",
|
|
2525
|
-
"max",
|
|
2526
|
-
"min",
|
|
2527
|
-
"publish",
|
|
2528
|
-
"publishBehavior",
|
|
2529
|
-
"publishLast",
|
|
2530
|
-
"publishReplay",
|
|
2531
|
-
"reduce",
|
|
2532
|
-
"share",
|
|
2533
|
-
"shareReplay",
|
|
2534
|
-
"skipLast",
|
|
2535
|
-
"takeLast",
|
|
2536
|
-
"throwIfEmpty",
|
|
2537
|
-
"toArray"
|
|
2538
|
-
];
|
|
2539
2633
|
const [config = {}] = context.options;
|
|
2540
2634
|
const { alias, allow = allowedOperators } = config;
|
|
2541
2635
|
if (alias) {
|
|
@@ -2586,12 +2680,13 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2586
2680
|
}
|
|
2587
2681
|
});
|
|
2588
2682
|
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2683
|
+
// src/rules/prefer-observer.ts
|
|
2684
|
+
var defaultOptions12 = [];
|
|
2685
|
+
var preferObserverRule = ruleCreator({
|
|
2686
|
+
defaultOptions: defaultOptions12,
|
|
2592
2687
|
meta: {
|
|
2593
2688
|
docs: {
|
|
2594
|
-
description: "
|
|
2689
|
+
description: "Disallow passing separate handlers to `subscribe` and `tap`.",
|
|
2595
2690
|
requiresTypeChecking: true
|
|
2596
2691
|
},
|
|
2597
2692
|
fixable: "code",
|
|
@@ -2602,7 +2697,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2602
2697
|
schema: [
|
|
2603
2698
|
{
|
|
2604
2699
|
properties: {
|
|
2605
|
-
allowNext: { type: "boolean" }
|
|
2700
|
+
allowNext: { type: "boolean", description: "Allows a single `next` callback.", default: true }
|
|
2606
2701
|
},
|
|
2607
2702
|
type: "object"
|
|
2608
2703
|
}
|
|
@@ -2611,7 +2706,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2611
2706
|
},
|
|
2612
2707
|
name: "prefer-observer",
|
|
2613
2708
|
create: (context) => {
|
|
2614
|
-
const { couldBeFunction, couldBeObservable } = getTypeServices(context);
|
|
2709
|
+
const { couldBeFunction: couldBeFunction2, couldBeObservable } = getTypeServices(context);
|
|
2615
2710
|
const [config = {}] = context.options;
|
|
2616
2711
|
const { allowNext = true } = config;
|
|
2617
2712
|
function checkArgs(callExpression, reportNode) {
|
|
@@ -2655,7 +2750,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2655
2750
|
});
|
|
2656
2751
|
} else if (args.length === 1 && !allowNext) {
|
|
2657
2752
|
const [arg] = args;
|
|
2658
|
-
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) ||
|
|
2753
|
+
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) || couldBeFunction2(arg)) {
|
|
2659
2754
|
context.report({
|
|
2660
2755
|
messageId: "forbidden",
|
|
2661
2756
|
node: reportNode,
|
|
@@ -2684,12 +2779,14 @@ function isValidArgText(argText) {
|
|
|
2684
2779
|
return argText && argText !== "undefined" && argText !== "null";
|
|
2685
2780
|
}
|
|
2686
2781
|
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2782
|
+
// src/rules/suffix-subjects.ts
|
|
2783
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES8, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
2784
|
+
var defaultOptions13 = [];
|
|
2785
|
+
var suffixSubjectsRule = ruleCreator({
|
|
2786
|
+
defaultOptions: defaultOptions13,
|
|
2690
2787
|
meta: {
|
|
2691
2788
|
docs: {
|
|
2692
|
-
description: "
|
|
2789
|
+
description: "Enforce the use of a suffix in subject identifiers.",
|
|
2693
2790
|
requiresTypeChecking: true
|
|
2694
2791
|
},
|
|
2695
2792
|
messages: {
|
|
@@ -2698,11 +2795,11 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2698
2795
|
schema: [
|
|
2699
2796
|
{
|
|
2700
2797
|
properties: {
|
|
2701
|
-
parameters: { type: "boolean" },
|
|
2702
|
-
properties: { type: "boolean" },
|
|
2703
|
-
suffix: { type: "string" },
|
|
2704
|
-
types: { type: "object" },
|
|
2705
|
-
variables: { type: "boolean" }
|
|
2798
|
+
parameters: { type: "boolean", description: "Require for parameters." },
|
|
2799
|
+
properties: { type: "boolean", description: "Require for properties." },
|
|
2800
|
+
suffix: { type: "string", description: "The suffix to enforce." },
|
|
2801
|
+
types: { type: "object", description: "Enforce for specific types. Keys are a RegExp, values are a boolean." },
|
|
2802
|
+
variables: { type: "boolean", description: "Require for variables." }
|
|
2706
2803
|
},
|
|
2707
2804
|
type: "object"
|
|
2708
2805
|
}
|
|
@@ -2711,8 +2808,8 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2711
2808
|
},
|
|
2712
2809
|
name: "suffix-subjects",
|
|
2713
2810
|
create: (context) => {
|
|
2714
|
-
const { esTreeNodeToTSNodeMap } =
|
|
2715
|
-
const { couldBeType } = getTypeServices(context);
|
|
2811
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils5.getParserServices(context);
|
|
2812
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2716
2813
|
const [config = {}] = context.options;
|
|
2717
2814
|
const validate = {
|
|
2718
2815
|
parameters: true,
|
|
@@ -2741,10 +2838,10 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2741
2838
|
function checkNode(nameNode, typeNode) {
|
|
2742
2839
|
const tsNode = esTreeNodeToTSNodeMap.get(nameNode);
|
|
2743
2840
|
const text = tsNode.getText();
|
|
2744
|
-
if (!suffixRegex.test(text) &&
|
|
2841
|
+
if (!suffixRegex.test(text) && couldBeType2(typeNode || nameNode, "Subject")) {
|
|
2745
2842
|
for (const type of types) {
|
|
2746
2843
|
const { regExp, validate: validate2 } = type;
|
|
2747
|
-
if (
|
|
2844
|
+
if (couldBeType2(typeNode || nameNode, regExp) && !validate2) {
|
|
2748
2845
|
return;
|
|
2749
2846
|
}
|
|
2750
2847
|
}
|
|
@@ -2767,7 +2864,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2767
2864
|
if (!found) {
|
|
2768
2865
|
return;
|
|
2769
2866
|
}
|
|
2770
|
-
if (!validate.variables && found.type ===
|
|
2867
|
+
if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
|
|
2771
2868
|
return;
|
|
2772
2869
|
}
|
|
2773
2870
|
if (!validate.parameters) {
|
|
@@ -2834,7 +2931,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2834
2931
|
if (!found) {
|
|
2835
2932
|
return;
|
|
2836
2933
|
}
|
|
2837
|
-
if (!validate.variables && found.type ===
|
|
2934
|
+
if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
|
|
2838
2935
|
return;
|
|
2839
2936
|
}
|
|
2840
2937
|
if (!validate.parameters) {
|
|
@@ -2880,11 +2977,14 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2880
2977
|
}
|
|
2881
2978
|
});
|
|
2882
2979
|
|
|
2883
|
-
|
|
2980
|
+
// src/rules/throw-error.ts
|
|
2981
|
+
import { ESLintUtils as ESLintUtils6 } from "@typescript-eslint/utils";
|
|
2982
|
+
import * as tsutils4 from "ts-api-utils";
|
|
2983
|
+
var throwErrorRule = ruleCreator({
|
|
2884
2984
|
defaultOptions: [],
|
|
2885
2985
|
meta: {
|
|
2886
2986
|
docs: {
|
|
2887
|
-
description: "
|
|
2987
|
+
description: "Enforce passing only `Error` values to error notifications.",
|
|
2888
2988
|
requiresTypeChecking: true
|
|
2889
2989
|
},
|
|
2890
2990
|
messages: {
|
|
@@ -2895,7 +2995,7 @@ const throwErrorRule = ruleCreator({
|
|
|
2895
2995
|
},
|
|
2896
2996
|
name: "throw-error",
|
|
2897
2997
|
create: (context) => {
|
|
2898
|
-
const { esTreeNodeToTSNodeMap, program } =
|
|
2998
|
+
const { esTreeNodeToTSNodeMap, program } = ESLintUtils6.getParserServices(context);
|
|
2899
2999
|
const { couldBeObservable, getType } = getTypeServices(context);
|
|
2900
3000
|
function checkNode(node) {
|
|
2901
3001
|
let type = getType(node);
|
|
@@ -2903,9 +3003,9 @@ const throwErrorRule = ruleCreator({
|
|
|
2903
3003
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
2904
3004
|
const annotation = tsNode.type;
|
|
2905
3005
|
const body = tsNode.body;
|
|
2906
|
-
type = program.getTypeChecker().getTypeAtLocation(annotation
|
|
3006
|
+
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
2907
3007
|
}
|
|
2908
|
-
if (!
|
|
3008
|
+
if (!tsutils4.isIntrinsicAnyType(type) && !tsutils4.isIntrinsicUnknownType(type) && !couldBeType(type, /^(Error|DOMException)$/)) {
|
|
2909
3009
|
context.report({
|
|
2910
3010
|
messageId: "forbidden",
|
|
2911
3011
|
node
|
|
@@ -2926,7 +3026,8 @@ const throwErrorRule = ruleCreator({
|
|
|
2926
3026
|
}
|
|
2927
3027
|
});
|
|
2928
3028
|
|
|
2929
|
-
|
|
3029
|
+
// src/index.ts
|
|
3030
|
+
var plugin = {
|
|
2930
3031
|
meta: { name, version },
|
|
2931
3032
|
rules: {
|
|
2932
3033
|
"ban-observables": banObservablesRule,
|
|
@@ -2972,11 +3073,13 @@ const plugin = {
|
|
|
2972
3073
|
"throw-error": throwErrorRule
|
|
2973
3074
|
}
|
|
2974
3075
|
};
|
|
2975
|
-
|
|
3076
|
+
var rxjsX = {
|
|
2976
3077
|
...plugin,
|
|
2977
3078
|
configs: {
|
|
2978
3079
|
recommended: createRecommendedConfig(plugin)
|
|
2979
3080
|
}
|
|
2980
3081
|
};
|
|
2981
|
-
|
|
2982
|
-
export {
|
|
3082
|
+
var src_default = rxjsX;
|
|
3083
|
+
export {
|
|
3084
|
+
src_default as default
|
|
3085
|
+
};
|