eslint-plugin-rxjs-x 0.0.2 → 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} +485 -333
- package/dist/index.mjs +482 -312
- 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 +21 -13
- package/dist/index.d.cts +0 -121
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { isReferenceType, couldBeType, isUnionType, couldBeFunction, isAny, isUnknown } from 'tsutils-etc';
|
|
5
|
-
import * as ts from 'typescript';
|
|
6
|
-
import { DefinitionType } from '@typescript-eslint/scope-manager';
|
|
7
|
-
import * as tsutils$1 from 'tsutils';
|
|
8
|
-
import decamelize from 'decamelize';
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "eslint-plugin-rxjs-x";
|
|
3
|
+
var version = "0.2.0";
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const createRecommendedConfig = (plugin) => ({
|
|
5
|
+
// src/configs/recommended.ts
|
|
6
|
+
var createRecommendedConfig = (plugin2) => ({
|
|
14
7
|
plugins: {
|
|
15
|
-
"rxjs-x":
|
|
8
|
+
"rxjs-x": plugin2
|
|
16
9
|
},
|
|
17
10
|
rules: {
|
|
18
11
|
"rxjs-x/no-async-subscribe": "error",
|
|
@@ -33,8 +26,14 @@ const createRecommendedConfig = (plugin) => ({
|
|
|
33
26
|
}
|
|
34
27
|
});
|
|
35
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";
|
|
36
35
|
function createRegExpForWords(config) {
|
|
37
|
-
if (!config
|
|
36
|
+
if (!(config == null ? void 0 : config.length)) {
|
|
38
37
|
return void 0;
|
|
39
38
|
}
|
|
40
39
|
const flags = "i";
|
|
@@ -48,16 +47,17 @@ function createRegExpForWords(config) {
|
|
|
48
47
|
function escapeRegExp(text) {
|
|
49
48
|
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
(
|
|
50
|
+
var ruleCreator = ESLintUtils.RuleCreator(
|
|
51
|
+
(name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
|
|
53
52
|
);
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// src/rules/ban-observables.ts
|
|
55
|
+
var defaultOptions = [];
|
|
56
|
+
var banObservablesRule = ruleCreator({
|
|
57
|
+
defaultOptions,
|
|
58
58
|
meta: {
|
|
59
59
|
docs: {
|
|
60
|
-
description: "
|
|
60
|
+
description: "Disallow banned observable creators."
|
|
61
61
|
},
|
|
62
62
|
messages: {
|
|
63
63
|
forbidden: "RxJS observable is banned: {{name}}{{explanation}}."
|
|
@@ -87,14 +87,14 @@ const banObservablesRule = ruleCreator({
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
function getFailure(
|
|
90
|
+
function getFailure(name2) {
|
|
91
91
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
92
92
|
const ban = bans[b];
|
|
93
|
-
if (ban.regExp.test(
|
|
93
|
+
if (ban.regExp.test(name2)) {
|
|
94
94
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
95
95
|
return {
|
|
96
96
|
messageId: "forbidden",
|
|
97
|
-
data: { name, explanation }
|
|
97
|
+
data: { name: name2, explanation }
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -103,8 +103,8 @@ const banObservablesRule = ruleCreator({
|
|
|
103
103
|
return {
|
|
104
104
|
"ImportDeclaration[source.value='rxjs'] > ImportSpecifier": (node) => {
|
|
105
105
|
const identifier = node.imported;
|
|
106
|
-
const
|
|
107
|
-
const failure = getFailure(
|
|
106
|
+
const name2 = identifier.type === AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
107
|
+
const failure = getFailure(name2);
|
|
108
108
|
if (failure) {
|
|
109
109
|
context.report({
|
|
110
110
|
...failure,
|
|
@@ -116,12 +116,15 @@ const banObservablesRule = ruleCreator({
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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,
|
|
122
125
|
meta: {
|
|
123
126
|
docs: {
|
|
124
|
-
description: "
|
|
127
|
+
description: "Disallow banned operators."
|
|
125
128
|
},
|
|
126
129
|
messages: {
|
|
127
130
|
forbidden: "RxJS operator is banned: {{name}}{{explanation}}."
|
|
@@ -129,7 +132,7 @@ const banOperatorsRule = ruleCreator({
|
|
|
129
132
|
schema: [
|
|
130
133
|
{
|
|
131
134
|
type: "object",
|
|
132
|
-
description:
|
|
135
|
+
description: stripIndent2`
|
|
133
136
|
An object containing keys that are names of operators
|
|
134
137
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
135
138
|
}
|
|
@@ -151,14 +154,14 @@ const banOperatorsRule = ruleCreator({
|
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
156
|
});
|
|
154
|
-
function getFailure(
|
|
157
|
+
function getFailure(name2) {
|
|
155
158
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
156
159
|
const ban = bans[b];
|
|
157
|
-
if (ban.regExp.test(
|
|
160
|
+
if (ban.regExp.test(name2)) {
|
|
158
161
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
159
162
|
return {
|
|
160
163
|
messageId: "forbidden",
|
|
161
|
-
data: { name, explanation }
|
|
164
|
+
data: { name: name2, explanation }
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
}
|
|
@@ -167,8 +170,8 @@ const banOperatorsRule = ruleCreator({
|
|
|
167
170
|
return {
|
|
168
171
|
[String.raw`ImportDeclaration[source.value=/^rxjs\u002foperators$/] > ImportSpecifier`]: (node) => {
|
|
169
172
|
const identifier = node.imported;
|
|
170
|
-
const
|
|
171
|
-
const failure = getFailure(
|
|
173
|
+
const name2 = identifier.type === AST_NODE_TYPES2.Identifier ? identifier.name : identifier.value;
|
|
174
|
+
const failure = getFailure(name2);
|
|
172
175
|
if (failure) {
|
|
173
176
|
context.report({
|
|
174
177
|
...failure,
|
|
@@ -180,6 +183,86 @@ const banOperatorsRule = ruleCreator({
|
|
|
180
183
|
}
|
|
181
184
|
});
|
|
182
185
|
|
|
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) {
|
|
196
|
+
if (tsutils.isTypeReference(type)) {
|
|
197
|
+
type = type.target;
|
|
198
|
+
}
|
|
199
|
+
if (isType(type, name2, qualified)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (tsutils.isUnionOrIntersectionType(type)) {
|
|
203
|
+
return type.types.some((t) => couldBeType(t, name2, qualified));
|
|
204
|
+
}
|
|
205
|
+
const baseTypes = type.getBaseTypes();
|
|
206
|
+
if (baseTypes == null ? void 0 : baseTypes.some((t) => couldBeType(t, name2, qualified))) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
if (couldImplement(type, name2, qualified)) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
function isType(type, name2, qualified) {
|
|
215
|
+
if (!type.symbol) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
if (qualified && !qualified.name.test(
|
|
219
|
+
qualified.typeChecker.getFullyQualifiedName(type.symbol)
|
|
220
|
+
)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
return typeof name2 === "string" ? type.symbol.name === name2 : Boolean(type.symbol.name.match(name2));
|
|
224
|
+
}
|
|
225
|
+
function couldImplement(type, name2, qualified) {
|
|
226
|
+
const { symbol } = type;
|
|
227
|
+
if (symbol) {
|
|
228
|
+
const { valueDeclaration } = symbol;
|
|
229
|
+
if (valueDeclaration && ts.isClassDeclaration(valueDeclaration)) {
|
|
230
|
+
const { heritageClauses } = valueDeclaration;
|
|
231
|
+
if (heritageClauses) {
|
|
232
|
+
const implemented = heritageClauses.some(
|
|
233
|
+
({ token, types }) => token === ts.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node, name2, qualified))
|
|
234
|
+
);
|
|
235
|
+
if (implemented) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
function isMatchingNode(node, name2, qualified) {
|
|
244
|
+
const { expression } = node;
|
|
245
|
+
if (qualified) {
|
|
246
|
+
const type = qualified.typeChecker.getTypeAtLocation(expression);
|
|
247
|
+
if (type) {
|
|
248
|
+
const qualifiedName = qualified.typeChecker.getFullyQualifiedName(
|
|
249
|
+
type.symbol
|
|
250
|
+
);
|
|
251
|
+
if (!qualified.name.test(qualifiedName)) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const text = expression.getText();
|
|
257
|
+
return typeof name2 === "string" ? text === name2 : Boolean(text.match(name2));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/etc/could-be-function.ts
|
|
261
|
+
function couldBeFunction(type) {
|
|
262
|
+
return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type, ts2.InternalSymbolName.Function);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/etc/find-parent.ts
|
|
183
266
|
function findParent(node, ...args) {
|
|
184
267
|
const [arg] = args;
|
|
185
268
|
const predicate = typeof arg === "function" ? arg : (type) => !args.includes(type) ? "continue" : "return";
|
|
@@ -190,16 +273,20 @@ function findParent(node, ...args) {
|
|
|
190
273
|
return void 0;
|
|
191
274
|
case "return":
|
|
192
275
|
return parent;
|
|
276
|
+
default:
|
|
277
|
+
break;
|
|
193
278
|
}
|
|
194
279
|
parent = parent.parent;
|
|
195
280
|
}
|
|
196
281
|
return void 0;
|
|
197
282
|
}
|
|
198
283
|
|
|
284
|
+
// src/etc/get-loc.ts
|
|
285
|
+
import * as ts3 from "typescript";
|
|
199
286
|
function getLoc(node) {
|
|
200
287
|
const sourceFile = node.getSourceFile();
|
|
201
|
-
const start =
|
|
202
|
-
const end =
|
|
288
|
+
const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
289
|
+
const end = ts3.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
|
|
203
290
|
return {
|
|
204
291
|
start: {
|
|
205
292
|
line: start.line + 1,
|
|
@@ -212,76 +299,85 @@ function getLoc(node) {
|
|
|
212
299
|
};
|
|
213
300
|
}
|
|
214
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";
|
|
215
309
|
function hasTypeAnnotation(node) {
|
|
216
310
|
return "typeAnnotation" in node && !!node.typeAnnotation;
|
|
217
311
|
}
|
|
218
312
|
function isArrayExpression(node) {
|
|
219
|
-
return node.type ===
|
|
313
|
+
return node.type === AST_NODE_TYPES3.ArrayExpression;
|
|
220
314
|
}
|
|
221
315
|
function isArrayPattern(node) {
|
|
222
|
-
return node.type ===
|
|
316
|
+
return node.type === AST_NODE_TYPES3.ArrayPattern;
|
|
223
317
|
}
|
|
224
318
|
function isArrowFunctionExpression(node) {
|
|
225
|
-
return node.type ===
|
|
319
|
+
return node.type === AST_NODE_TYPES3.ArrowFunctionExpression;
|
|
226
320
|
}
|
|
227
321
|
function isBlockStatement(node) {
|
|
228
|
-
return node.type ===
|
|
322
|
+
return node.type === AST_NODE_TYPES3.BlockStatement;
|
|
229
323
|
}
|
|
230
324
|
function isCallExpression(node) {
|
|
231
|
-
return node.type ===
|
|
325
|
+
return node.type === AST_NODE_TYPES3.CallExpression;
|
|
232
326
|
}
|
|
233
327
|
function isFunctionDeclaration(node) {
|
|
234
|
-
return node.type ===
|
|
328
|
+
return node.type === AST_NODE_TYPES3.FunctionDeclaration;
|
|
235
329
|
}
|
|
236
330
|
function isFunctionExpression(node) {
|
|
237
|
-
return node.type ===
|
|
331
|
+
return node.type === AST_NODE_TYPES3.FunctionExpression;
|
|
238
332
|
}
|
|
239
333
|
function isIdentifier(node) {
|
|
240
|
-
return node.type ===
|
|
334
|
+
return node.type === AST_NODE_TYPES3.Identifier;
|
|
241
335
|
}
|
|
242
336
|
function isLiteral(node) {
|
|
243
|
-
return node.type ===
|
|
337
|
+
return node.type === AST_NODE_TYPES3.Literal;
|
|
244
338
|
}
|
|
245
339
|
function isMemberExpression(node) {
|
|
246
|
-
return node.type ===
|
|
340
|
+
return node.type === AST_NODE_TYPES3.MemberExpression;
|
|
247
341
|
}
|
|
248
342
|
function isObjectExpression(node) {
|
|
249
|
-
return node.type ===
|
|
343
|
+
return node.type === AST_NODE_TYPES3.ObjectExpression;
|
|
250
344
|
}
|
|
251
345
|
function isObjectPattern(node) {
|
|
252
|
-
return node.type ===
|
|
346
|
+
return node.type === AST_NODE_TYPES3.ObjectPattern;
|
|
253
347
|
}
|
|
254
348
|
function isProgram(node) {
|
|
255
|
-
return node.type ===
|
|
349
|
+
return node.type === AST_NODE_TYPES3.Program;
|
|
256
350
|
}
|
|
257
351
|
function isProperty(node) {
|
|
258
|
-
return node.type ===
|
|
352
|
+
return node.type === AST_NODE_TYPES3.Property;
|
|
259
353
|
}
|
|
260
354
|
|
|
355
|
+
// src/etc/get-type-services.ts
|
|
261
356
|
function getTypeServices(context) {
|
|
262
|
-
const services =
|
|
357
|
+
const services = ESLintUtils2.getParserServices(context);
|
|
263
358
|
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = services;
|
|
264
359
|
const typeChecker = program.getTypeChecker();
|
|
265
|
-
const
|
|
360
|
+
const couldBeType2 = (node, name2, qualified) => {
|
|
266
361
|
const type = getType(node);
|
|
267
|
-
return
|
|
362
|
+
return couldBeType(
|
|
268
363
|
type,
|
|
269
|
-
|
|
364
|
+
name2,
|
|
270
365
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
271
366
|
);
|
|
272
367
|
};
|
|
273
|
-
const couldReturnType = (node,
|
|
368
|
+
const couldReturnType = (node, name2, qualified) => {
|
|
369
|
+
var _a;
|
|
274
370
|
let tsTypeNode;
|
|
275
371
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
276
|
-
if (
|
|
277
|
-
tsTypeNode = tsNode.type
|
|
278
|
-
} 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)) {
|
|
279
375
|
tsTypeNode = tsNode.type;
|
|
280
376
|
}
|
|
281
377
|
return Boolean(
|
|
282
|
-
tsTypeNode &&
|
|
378
|
+
tsTypeNode && couldBeType(
|
|
283
379
|
typeChecker.getTypeAtLocation(tsTypeNode),
|
|
284
|
-
|
|
380
|
+
name2,
|
|
285
381
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
286
382
|
)
|
|
287
383
|
);
|
|
@@ -290,45 +386,49 @@ function getTypeServices(context) {
|
|
|
290
386
|
return getTypeAtLocation(node);
|
|
291
387
|
};
|
|
292
388
|
return {
|
|
293
|
-
couldBeBehaviorSubject: (node) =>
|
|
294
|
-
couldBeError: (node) =>
|
|
389
|
+
couldBeBehaviorSubject: (node) => couldBeType2(node, "BehaviorSubject"),
|
|
390
|
+
couldBeError: (node) => couldBeType2(node, "Error"),
|
|
295
391
|
couldBeFunction: (node) => {
|
|
296
392
|
if (isArrowFunctionExpression(node) || isFunctionDeclaration(node)) {
|
|
297
393
|
return true;
|
|
298
394
|
}
|
|
299
|
-
return
|
|
395
|
+
return couldBeFunction(getType(node));
|
|
300
396
|
},
|
|
301
|
-
couldBeMonoTypeOperatorFunction: (node) =>
|
|
302
|
-
couldBeObservable: (node) =>
|
|
303
|
-
couldBeSubject: (node) =>
|
|
304
|
-
couldBeSubscription: (node) =>
|
|
305
|
-
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,
|
|
306
402
|
couldReturnObservable: (node) => couldReturnType(node, "Observable"),
|
|
307
403
|
couldReturnType,
|
|
308
404
|
getType,
|
|
309
|
-
isAny: (node) =>
|
|
310
|
-
isReferenceType: (node) =>
|
|
311
|
-
isUnknown: (node) =>
|
|
405
|
+
isAny: (node) => tsutils2.isIntrinsicAnyType(getType(node)),
|
|
406
|
+
isReferenceType: (node) => tsutils2.isTypeReference(getType(node)),
|
|
407
|
+
isUnknown: (node) => tsutils2.isIntrinsicUnknownType(getType(node)),
|
|
312
408
|
typeChecker
|
|
313
409
|
};
|
|
314
410
|
}
|
|
315
411
|
|
|
316
|
-
|
|
317
|
-
|
|
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);
|
|
318
417
|
if (variable) {
|
|
319
418
|
return variable.defs.some(
|
|
320
|
-
(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))
|
|
321
420
|
);
|
|
322
421
|
}
|
|
323
|
-
return scope.upper ? isImport(scope.upper,
|
|
422
|
+
return scope.upper ? isImport(scope.upper, name2, source) : false;
|
|
324
423
|
}
|
|
325
424
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
425
|
+
// src/rules/finnish.ts
|
|
426
|
+
var defaultOptions3 = [];
|
|
427
|
+
var finnishRule = ruleCreator({
|
|
428
|
+
defaultOptions: defaultOptions3,
|
|
329
429
|
meta: {
|
|
330
430
|
docs: {
|
|
331
|
-
description: "
|
|
431
|
+
description: "Enforce Finnish notation.",
|
|
332
432
|
requiresTypeChecking: true
|
|
333
433
|
},
|
|
334
434
|
messages: {
|
|
@@ -338,14 +438,14 @@ const finnishRule = ruleCreator({
|
|
|
338
438
|
schema: [
|
|
339
439
|
{
|
|
340
440
|
properties: {
|
|
341
|
-
functions: { type: "boolean" },
|
|
342
|
-
methods: { type: "boolean" },
|
|
343
|
-
names: { type: "object" },
|
|
344
|
-
parameters: { type: "boolean" },
|
|
345
|
-
properties: { type: "boolean" },
|
|
346
|
-
strict: { type: "boolean" },
|
|
347
|
-
types: { type: "object" },
|
|
348
|
-
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." }
|
|
349
449
|
},
|
|
350
450
|
type: "object"
|
|
351
451
|
}
|
|
@@ -354,10 +454,10 @@ const finnishRule = ruleCreator({
|
|
|
354
454
|
},
|
|
355
455
|
name: "finnish",
|
|
356
456
|
create: (context) => {
|
|
357
|
-
const { esTreeNodeToTSNodeMap } =
|
|
457
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils3.getParserServices(context);
|
|
358
458
|
const {
|
|
359
459
|
couldBeObservable,
|
|
360
|
-
couldBeType,
|
|
460
|
+
couldBeType: couldBeType2,
|
|
361
461
|
couldReturnObservable,
|
|
362
462
|
couldReturnType
|
|
363
463
|
} = getTypeServices(context);
|
|
@@ -419,8 +519,8 @@ const finnishRule = ruleCreator({
|
|
|
419
519
|
} : () => {
|
|
420
520
|
};
|
|
421
521
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
422
|
-
for (const
|
|
423
|
-
const { regExp, validate: validate2 } =
|
|
522
|
+
for (const name2 of names) {
|
|
523
|
+
const { regExp, validate: validate2 } = name2;
|
|
424
524
|
if (regExp.test(text) && !validate2) {
|
|
425
525
|
shouldNotBeFinnish();
|
|
426
526
|
return;
|
|
@@ -428,7 +528,7 @@ const finnishRule = ruleCreator({
|
|
|
428
528
|
}
|
|
429
529
|
for (const type of types) {
|
|
430
530
|
const { regExp, validate: validate2 } = type;
|
|
431
|
-
if ((
|
|
531
|
+
if ((couldBeType2(typeNode || nameNode, regExp) || couldReturnType(typeNode || nameNode, regExp)) && !validate2) {
|
|
432
532
|
shouldNotBeFinnish();
|
|
433
533
|
return;
|
|
434
534
|
}
|
|
@@ -450,7 +550,7 @@ const finnishRule = ruleCreator({
|
|
|
450
550
|
if (!found) {
|
|
451
551
|
return;
|
|
452
552
|
}
|
|
453
|
-
if (!validate.variables && found.type ===
|
|
553
|
+
if (!validate.variables && found.type === AST_NODE_TYPES5.VariableDeclarator) {
|
|
454
554
|
return;
|
|
455
555
|
}
|
|
456
556
|
if (!validate.parameters) {
|
|
@@ -529,7 +629,7 @@ const finnishRule = ruleCreator({
|
|
|
529
629
|
if (!found) {
|
|
530
630
|
return;
|
|
531
631
|
}
|
|
532
|
-
if (!validate.variables && found.type ===
|
|
632
|
+
if (!validate.variables && found.type === AST_NODE_TYPES5.VariableDeclarator) {
|
|
533
633
|
return;
|
|
534
634
|
}
|
|
535
635
|
if (!validate.parameters) {
|
|
@@ -580,11 +680,12 @@ const finnishRule = ruleCreator({
|
|
|
580
680
|
}
|
|
581
681
|
});
|
|
582
682
|
|
|
583
|
-
|
|
683
|
+
// src/rules/just.ts
|
|
684
|
+
var justRule = ruleCreator({
|
|
584
685
|
defaultOptions: [],
|
|
585
686
|
meta: {
|
|
586
687
|
docs: {
|
|
587
|
-
description: "
|
|
688
|
+
description: "Require the use of `just` instead of `of`."
|
|
588
689
|
},
|
|
589
690
|
fixable: "code",
|
|
590
691
|
messages: {
|
|
@@ -618,11 +719,12 @@ const justRule = ruleCreator({
|
|
|
618
719
|
}
|
|
619
720
|
});
|
|
620
721
|
|
|
621
|
-
|
|
722
|
+
// src/rules/macro.ts
|
|
723
|
+
var macroRule = ruleCreator({
|
|
622
724
|
defaultOptions: [],
|
|
623
725
|
meta: {
|
|
624
726
|
docs: {
|
|
625
|
-
description: "
|
|
727
|
+
description: "Require the use of the RxJS Tools Babel macro."
|
|
626
728
|
},
|
|
627
729
|
fixable: "code",
|
|
628
730
|
messages: {
|
|
@@ -677,11 +779,12 @@ const macroRule = ruleCreator({
|
|
|
677
779
|
}
|
|
678
780
|
});
|
|
679
781
|
|
|
680
|
-
|
|
782
|
+
// src/rules/no-async-subscribe.ts
|
|
783
|
+
var noAsyncSubscribeRule = ruleCreator({
|
|
681
784
|
defaultOptions: [],
|
|
682
785
|
meta: {
|
|
683
786
|
docs: {
|
|
684
|
-
description: "
|
|
787
|
+
description: "Disallow passing `async` functions to `subscribe`.",
|
|
685
788
|
recommended: true,
|
|
686
789
|
requiresTypeChecking: true
|
|
687
790
|
},
|
|
@@ -719,11 +822,12 @@ const noAsyncSubscribeRule = ruleCreator({
|
|
|
719
822
|
}
|
|
720
823
|
});
|
|
721
824
|
|
|
722
|
-
|
|
825
|
+
// src/rules/no-compat.ts
|
|
826
|
+
var noCompatRule = ruleCreator({
|
|
723
827
|
defaultOptions: [],
|
|
724
828
|
meta: {
|
|
725
829
|
docs: {
|
|
726
|
-
description: "
|
|
830
|
+
description: "Disallow the `rxjs-compat` package."
|
|
727
831
|
},
|
|
728
832
|
messages: {
|
|
729
833
|
forbidden: "'rxjs-compat'-dependent import locations are forbidden."
|
|
@@ -744,11 +848,12 @@ const noCompatRule = ruleCreator({
|
|
|
744
848
|
}
|
|
745
849
|
});
|
|
746
850
|
|
|
747
|
-
|
|
851
|
+
// src/rules/no-connectable.ts
|
|
852
|
+
var noConnectableRule = ruleCreator({
|
|
748
853
|
defaultOptions: [],
|
|
749
854
|
meta: {
|
|
750
855
|
docs: {
|
|
751
|
-
description: "
|
|
856
|
+
description: "Disallow operators that return connectable observables.",
|
|
752
857
|
requiresTypeChecking: true
|
|
753
858
|
},
|
|
754
859
|
messages: {
|
|
@@ -759,7 +864,7 @@ const noConnectableRule = ruleCreator({
|
|
|
759
864
|
},
|
|
760
865
|
name: "no-connectable",
|
|
761
866
|
create: (context) => {
|
|
762
|
-
const { couldBeFunction } = getTypeServices(context);
|
|
867
|
+
const { couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
763
868
|
return {
|
|
764
869
|
"CallExpression[callee.name='multicast']": (node) => {
|
|
765
870
|
if (node.arguments.length === 1) {
|
|
@@ -770,7 +875,7 @@ const noConnectableRule = ruleCreator({
|
|
|
770
875
|
}
|
|
771
876
|
},
|
|
772
877
|
"CallExpression[callee.name=/^(publish|publishBehavior|publishLast|publishReplay)$/]": (node) => {
|
|
773
|
-
if (!node.arguments.some((arg) =>
|
|
878
|
+
if (!node.arguments.some((arg) => couldBeFunction2(arg))) {
|
|
774
879
|
context.report({
|
|
775
880
|
messageId: "forbidden",
|
|
776
881
|
node: node.callee
|
|
@@ -781,11 +886,12 @@ const noConnectableRule = ruleCreator({
|
|
|
781
886
|
}
|
|
782
887
|
});
|
|
783
888
|
|
|
784
|
-
|
|
889
|
+
// src/rules/no-create.ts
|
|
890
|
+
var noCreateRule = ruleCreator({
|
|
785
891
|
defaultOptions: [],
|
|
786
892
|
meta: {
|
|
787
893
|
docs: {
|
|
788
|
-
description: "
|
|
894
|
+
description: "Disallow the static `Observable.create` function.",
|
|
789
895
|
recommended: true,
|
|
790
896
|
requiresTypeChecking: true
|
|
791
897
|
},
|
|
@@ -812,17 +918,23 @@ const noCreateRule = ruleCreator({
|
|
|
812
918
|
}
|
|
813
919
|
});
|
|
814
920
|
|
|
815
|
-
|
|
921
|
+
// src/rules/no-cyclic-action.ts
|
|
922
|
+
import { stripIndent as stripIndent3 } from "common-tags";
|
|
923
|
+
import * as ts5 from "typescript";
|
|
816
924
|
|
|
817
|
-
|
|
925
|
+
// src/constants.ts
|
|
926
|
+
var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
|
|
927
|
+
|
|
928
|
+
// src/rules/no-cyclic-action.ts
|
|
929
|
+
function isTypeReference3(type) {
|
|
818
930
|
return Boolean(type.target);
|
|
819
931
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
defaultOptions:
|
|
932
|
+
var defaultOptions4 = [];
|
|
933
|
+
var noCyclicActionRule = ruleCreator({
|
|
934
|
+
defaultOptions: defaultOptions4,
|
|
823
935
|
meta: {
|
|
824
936
|
docs: {
|
|
825
|
-
description: "
|
|
937
|
+
description: "Disallow cyclic actions in effects and epics.",
|
|
826
938
|
requiresTypeChecking: true
|
|
827
939
|
},
|
|
828
940
|
messages: {
|
|
@@ -831,10 +943,10 @@ const noCyclicActionRule = ruleCreator({
|
|
|
831
943
|
schema: [
|
|
832
944
|
{
|
|
833
945
|
properties: {
|
|
834
|
-
observable: { type: "string" }
|
|
946
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
835
947
|
},
|
|
836
948
|
type: "object",
|
|
837
|
-
description:
|
|
949
|
+
description: stripIndent3`
|
|
838
950
|
An optional object with an optional \`observable\` property.
|
|
839
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.`
|
|
840
952
|
}
|
|
@@ -857,13 +969,13 @@ const noCyclicActionRule = ruleCreator({
|
|
|
857
969
|
const operatorType = getType(operatorCallExpression);
|
|
858
970
|
const [signature] = typeChecker.getSignaturesOfType(
|
|
859
971
|
operatorType,
|
|
860
|
-
|
|
972
|
+
ts5.SignatureKind.Call
|
|
861
973
|
);
|
|
862
974
|
if (!signature) {
|
|
863
975
|
return;
|
|
864
976
|
}
|
|
865
977
|
const operatorReturnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
866
|
-
if (!
|
|
978
|
+
if (!isTypeReference3(operatorReturnType)) {
|
|
867
979
|
return;
|
|
868
980
|
}
|
|
869
981
|
const [operatorElementType] = typeChecker.getTypeArguments(operatorReturnType);
|
|
@@ -871,7 +983,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
871
983
|
return;
|
|
872
984
|
}
|
|
873
985
|
const pipeType = getType(pipeCallExpression);
|
|
874
|
-
if (!
|
|
986
|
+
if (!isTypeReference3(pipeType)) {
|
|
875
987
|
return;
|
|
876
988
|
}
|
|
877
989
|
const [pipeElementType] = typeChecker.getTypeArguments(pipeType);
|
|
@@ -899,7 +1011,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
899
1011
|
return memberActionTypes;
|
|
900
1012
|
}
|
|
901
1013
|
const symbol = typeChecker.getPropertyOfType(type, "type");
|
|
902
|
-
if (!symbol
|
|
1014
|
+
if (!(symbol == null ? void 0 : symbol.valueDeclaration)) {
|
|
903
1015
|
return [];
|
|
904
1016
|
}
|
|
905
1017
|
const actionType = typeChecker.getTypeOfSymbolAtLocation(
|
|
@@ -915,11 +1027,12 @@ const noCyclicActionRule = ruleCreator({
|
|
|
915
1027
|
}
|
|
916
1028
|
});
|
|
917
1029
|
|
|
918
|
-
|
|
1030
|
+
// src/rules/no-explicit-generics.ts
|
|
1031
|
+
var noExplicitGenericsRule = ruleCreator({
|
|
919
1032
|
defaultOptions: [],
|
|
920
1033
|
meta: {
|
|
921
1034
|
docs: {
|
|
922
|
-
description: "
|
|
1035
|
+
description: "Disallow unnecessary explicit generic type arguments."
|
|
923
1036
|
},
|
|
924
1037
|
messages: {
|
|
925
1038
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -964,13 +1077,14 @@ const noExplicitGenericsRule = ruleCreator({
|
|
|
964
1077
|
}
|
|
965
1078
|
});
|
|
966
1079
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1080
|
+
// src/rules/no-exposed-subjects.ts
|
|
1081
|
+
var defaultAllowedTypesRegExp = /^EventEmitter$/;
|
|
1082
|
+
var defaultOptions5 = [];
|
|
1083
|
+
var noExposedSubjectsRule = ruleCreator({
|
|
1084
|
+
defaultOptions: defaultOptions5,
|
|
971
1085
|
meta: {
|
|
972
1086
|
docs: {
|
|
973
|
-
description: "
|
|
1087
|
+
description: "Disallow public and protected subjects.",
|
|
974
1088
|
requiresTypeChecking: true
|
|
975
1089
|
},
|
|
976
1090
|
messages: {
|
|
@@ -980,7 +1094,7 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
980
1094
|
schema: [
|
|
981
1095
|
{
|
|
982
1096
|
properties: {
|
|
983
|
-
allowProtected: { type: "boolean" }
|
|
1097
|
+
allowProtected: { type: "boolean", description: "Allow protected subjects.", default: false }
|
|
984
1098
|
},
|
|
985
1099
|
type: "object"
|
|
986
1100
|
}
|
|
@@ -991,11 +1105,11 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
991
1105
|
create: (context) => {
|
|
992
1106
|
const [config = {}] = context.options;
|
|
993
1107
|
const { allowProtected = false } = config;
|
|
994
|
-
const { couldBeSubject, couldBeType } = getTypeServices(context);
|
|
1108
|
+
const { couldBeSubject, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
995
1109
|
const messageId = allowProtected ? "forbiddenAllowProtected" : "forbidden";
|
|
996
1110
|
const accessibilityRexExp = allowProtected ? /^(private|protected)$/ : /^private$/;
|
|
997
1111
|
function isSubject(node) {
|
|
998
|
-
return couldBeSubject(node) && !
|
|
1112
|
+
return couldBeSubject(node) && !couldBeType2(node, defaultAllowedTypesRegExp);
|
|
999
1113
|
}
|
|
1000
1114
|
return {
|
|
1001
1115
|
[`PropertyDefinition[accessibility!=${accessibilityRexExp}]`]: (node) => {
|
|
@@ -1067,11 +1181,13 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1067
1181
|
}
|
|
1068
1182
|
});
|
|
1069
1183
|
|
|
1070
|
-
|
|
1184
|
+
// src/rules/no-finnish.ts
|
|
1185
|
+
import { ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
1186
|
+
var noFinnishRule = ruleCreator({
|
|
1071
1187
|
defaultOptions: [],
|
|
1072
1188
|
meta: {
|
|
1073
1189
|
docs: {
|
|
1074
|
-
description: "
|
|
1190
|
+
description: "Disallow Finnish notation.",
|
|
1075
1191
|
requiresTypeChecking: true
|
|
1076
1192
|
},
|
|
1077
1193
|
messages: {
|
|
@@ -1082,7 +1198,7 @@ const noFinnishRule = ruleCreator({
|
|
|
1082
1198
|
},
|
|
1083
1199
|
name: "no-finnish",
|
|
1084
1200
|
create: (context) => {
|
|
1085
|
-
const { esTreeNodeToTSNodeMap } =
|
|
1201
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils4.getParserServices(context);
|
|
1086
1202
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
1087
1203
|
function checkNode(nameNode, typeNode) {
|
|
1088
1204
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
@@ -1154,17 +1270,19 @@ const noFinnishRule = ruleCreator({
|
|
|
1154
1270
|
}
|
|
1155
1271
|
},
|
|
1156
1272
|
"VariableDeclarator[id.name=/[$]+$/]": (node) => {
|
|
1157
|
-
|
|
1273
|
+
var _a;
|
|
1274
|
+
checkNode(node.id, (_a = node.init) != null ? _a : node);
|
|
1158
1275
|
}
|
|
1159
1276
|
};
|
|
1160
1277
|
}
|
|
1161
1278
|
});
|
|
1162
1279
|
|
|
1163
|
-
|
|
1280
|
+
// src/rules/no-ignored-error.ts
|
|
1281
|
+
var noIgnoredErrorRule = ruleCreator({
|
|
1164
1282
|
defaultOptions: [],
|
|
1165
1283
|
meta: {
|
|
1166
1284
|
docs: {
|
|
1167
|
-
description: "
|
|
1285
|
+
description: "Disallow calling `subscribe` without specifying an error handler.",
|
|
1168
1286
|
requiresTypeChecking: true
|
|
1169
1287
|
},
|
|
1170
1288
|
messages: {
|
|
@@ -1175,12 +1293,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1175
1293
|
},
|
|
1176
1294
|
name: "no-ignored-error",
|
|
1177
1295
|
create: (context) => {
|
|
1178
|
-
const { couldBeObservable, couldBeFunction } = getTypeServices(context);
|
|
1296
|
+
const { couldBeObservable, couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
1179
1297
|
return {
|
|
1180
1298
|
"CallExpression[arguments.length > 0] > MemberExpression > Identifier[name='subscribe']": (node) => {
|
|
1181
1299
|
const memberExpression = node.parent;
|
|
1182
1300
|
const callExpression = memberExpression.parent;
|
|
1183
|
-
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) &&
|
|
1301
|
+
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) && couldBeFunction2(callExpression.arguments[0])) {
|
|
1184
1302
|
context.report({
|
|
1185
1303
|
messageId: "forbidden",
|
|
1186
1304
|
node
|
|
@@ -1191,11 +1309,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1191
1309
|
}
|
|
1192
1310
|
});
|
|
1193
1311
|
|
|
1194
|
-
|
|
1312
|
+
// src/rules/no-ignored-notifier.ts
|
|
1313
|
+
var noIgnoredNotifierRule = ruleCreator({
|
|
1195
1314
|
defaultOptions: [],
|
|
1196
1315
|
meta: {
|
|
1197
1316
|
docs: {
|
|
1198
|
-
description: "
|
|
1317
|
+
description: "Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.",
|
|
1199
1318
|
recommended: true,
|
|
1200
1319
|
requiresTypeChecking: true
|
|
1201
1320
|
},
|
|
@@ -1262,11 +1381,12 @@ const noIgnoredNotifierRule = ruleCreator({
|
|
|
1262
1381
|
}
|
|
1263
1382
|
});
|
|
1264
1383
|
|
|
1265
|
-
|
|
1384
|
+
// src/rules/no-ignored-observable.ts
|
|
1385
|
+
var noIgnoredObservableRule = ruleCreator({
|
|
1266
1386
|
defaultOptions: [],
|
|
1267
1387
|
meta: {
|
|
1268
1388
|
docs: {
|
|
1269
|
-
description: "
|
|
1389
|
+
description: "Disallow ignoring observables returned by functions.",
|
|
1270
1390
|
requiresTypeChecking: true
|
|
1271
1391
|
},
|
|
1272
1392
|
messages: {
|
|
@@ -1291,11 +1411,12 @@ const noIgnoredObservableRule = ruleCreator({
|
|
|
1291
1411
|
}
|
|
1292
1412
|
});
|
|
1293
1413
|
|
|
1294
|
-
|
|
1414
|
+
// src/rules/no-ignored-replay-buffer.ts
|
|
1415
|
+
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1295
1416
|
defaultOptions: [],
|
|
1296
1417
|
meta: {
|
|
1297
1418
|
docs: {
|
|
1298
|
-
description: "
|
|
1419
|
+
description: "Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.",
|
|
1299
1420
|
recommended: true
|
|
1300
1421
|
},
|
|
1301
1422
|
messages: {
|
|
@@ -1332,11 +1453,12 @@ const noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1332
1453
|
}
|
|
1333
1454
|
});
|
|
1334
1455
|
|
|
1335
|
-
|
|
1456
|
+
// src/rules/no-ignored-subscribe.ts
|
|
1457
|
+
var noIgnoredSubscribeRule = ruleCreator({
|
|
1336
1458
|
defaultOptions: [],
|
|
1337
1459
|
meta: {
|
|
1338
1460
|
docs: {
|
|
1339
|
-
description: "
|
|
1461
|
+
description: "Disallow calling `subscribe` without specifying arguments.",
|
|
1340
1462
|
requiresTypeChecking: true
|
|
1341
1463
|
},
|
|
1342
1464
|
messages: {
|
|
@@ -1347,11 +1469,11 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1347
1469
|
},
|
|
1348
1470
|
name: "no-ignored-subscribe",
|
|
1349
1471
|
create: (context) => {
|
|
1350
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1472
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1351
1473
|
return {
|
|
1352
1474
|
"CallExpression[arguments.length = 0][callee.property.name='subscribe']": (node) => {
|
|
1353
1475
|
const callee = node.callee;
|
|
1354
|
-
if (couldBeObservable(callee.object) ||
|
|
1476
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
1355
1477
|
context.report({
|
|
1356
1478
|
messageId: "forbidden",
|
|
1357
1479
|
node: callee.property
|
|
@@ -1362,11 +1484,12 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1362
1484
|
}
|
|
1363
1485
|
});
|
|
1364
1486
|
|
|
1365
|
-
|
|
1487
|
+
// src/rules/no-ignored-subscription.ts
|
|
1488
|
+
var noIgnoredSubscriptionRule = ruleCreator({
|
|
1366
1489
|
defaultOptions: [],
|
|
1367
1490
|
meta: {
|
|
1368
1491
|
docs: {
|
|
1369
|
-
description: "
|
|
1492
|
+
description: "Disallow ignoring the subscription returned by `subscribe`.",
|
|
1370
1493
|
requiresTypeChecking: true
|
|
1371
1494
|
},
|
|
1372
1495
|
messages: {
|
|
@@ -1377,12 +1500,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1377
1500
|
},
|
|
1378
1501
|
name: "no-ignored-subscription",
|
|
1379
1502
|
create: (context) => {
|
|
1380
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1503
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1381
1504
|
return {
|
|
1382
1505
|
"ExpressionStatement > CallExpression > MemberExpression[property.name='subscribe']": (node) => {
|
|
1383
1506
|
if (couldBeObservable(node.object)) {
|
|
1384
1507
|
const callExpression = node.parent;
|
|
1385
|
-
if (callExpression.arguments.length === 1 &&
|
|
1508
|
+
if (callExpression.arguments.length === 1 && couldBeType2(callExpression.arguments[0], "Subscriber")) {
|
|
1386
1509
|
return;
|
|
1387
1510
|
}
|
|
1388
1511
|
context.report({
|
|
@@ -1395,11 +1518,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1395
1518
|
}
|
|
1396
1519
|
});
|
|
1397
1520
|
|
|
1398
|
-
|
|
1521
|
+
// src/rules/no-ignored-takewhile-value.ts
|
|
1522
|
+
var noIgnoredTakewhileValueRule = ruleCreator({
|
|
1399
1523
|
defaultOptions: [],
|
|
1400
1524
|
meta: {
|
|
1401
1525
|
docs: {
|
|
1402
|
-
description: "
|
|
1526
|
+
description: "Disallow ignoring the value within `takeWhile`.",
|
|
1403
1527
|
recommended: true
|
|
1404
1528
|
},
|
|
1405
1529
|
messages: {
|
|
@@ -1420,7 +1544,7 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1420
1544
|
if (param) {
|
|
1421
1545
|
if (isIdentifier(param)) {
|
|
1422
1546
|
const variable = scope.variables.find(
|
|
1423
|
-
({ name }) =>
|
|
1547
|
+
({ name: name2 }) => name2 === param.name
|
|
1424
1548
|
);
|
|
1425
1549
|
if (variable && variable.references.length > 0) {
|
|
1426
1550
|
ignored = false;
|
|
@@ -1449,17 +1573,21 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1449
1573
|
}
|
|
1450
1574
|
});
|
|
1451
1575
|
|
|
1576
|
+
// src/rules/no-implicit-any-catch.ts
|
|
1577
|
+
import {
|
|
1578
|
+
AST_NODE_TYPES as AST_NODE_TYPES6
|
|
1579
|
+
} from "@typescript-eslint/utils";
|
|
1452
1580
|
function isParenthesised(sourceCode, node) {
|
|
1453
1581
|
const before = sourceCode.getTokenBefore(node);
|
|
1454
1582
|
const after = sourceCode.getTokenAfter(node);
|
|
1455
1583
|
return before && after && before.value === "(" && before.range[1] <= node.range[0] && after.value === ")" && after.range[0] >= node.range[1];
|
|
1456
1584
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
defaultOptions:
|
|
1585
|
+
var defaultOptions6 = [];
|
|
1586
|
+
var noImplicitAnyCatchRule = ruleCreator({
|
|
1587
|
+
defaultOptions: defaultOptions6,
|
|
1460
1588
|
meta: {
|
|
1461
1589
|
docs: {
|
|
1462
|
-
description: "
|
|
1590
|
+
description: "Disallow implicit `any` error parameters in `catchError` operators.",
|
|
1463
1591
|
recommended: true,
|
|
1464
1592
|
requiresTypeChecking: true
|
|
1465
1593
|
},
|
|
@@ -1476,7 +1604,9 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1476
1604
|
additionalProperties: false,
|
|
1477
1605
|
properties: {
|
|
1478
1606
|
allowExplicitAny: {
|
|
1479
|
-
type: "boolean"
|
|
1607
|
+
type: "boolean",
|
|
1608
|
+
description: "Allow error variable to be explicitly typed as `any`.",
|
|
1609
|
+
default: false
|
|
1480
1610
|
}
|
|
1481
1611
|
},
|
|
1482
1612
|
type: "object"
|
|
@@ -1501,41 +1631,43 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1501
1631
|
const {
|
|
1502
1632
|
typeAnnotation: { type }
|
|
1503
1633
|
} = typeAnnotation;
|
|
1504
|
-
if (type ===
|
|
1505
|
-
let
|
|
1634
|
+
if (type === AST_NODE_TYPES6.TSAnyKeyword) {
|
|
1635
|
+
let fix2 = function(fixer) {
|
|
1506
1636
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1507
1637
|
};
|
|
1638
|
+
var fix = fix2;
|
|
1508
1639
|
if (allowExplicitAny) {
|
|
1509
1640
|
return;
|
|
1510
1641
|
}
|
|
1511
1642
|
context.report({
|
|
1512
|
-
fix,
|
|
1643
|
+
fix: fix2,
|
|
1513
1644
|
messageId: "explicitAny",
|
|
1514
1645
|
node: param,
|
|
1515
1646
|
suggest: [
|
|
1516
1647
|
{
|
|
1517
1648
|
messageId: "suggestExplicitUnknown",
|
|
1518
|
-
fix
|
|
1649
|
+
fix: fix2
|
|
1519
1650
|
}
|
|
1520
1651
|
]
|
|
1521
1652
|
});
|
|
1522
|
-
} else if (type !==
|
|
1523
|
-
let
|
|
1653
|
+
} else if (type !== AST_NODE_TYPES6.TSUnknownKeyword) {
|
|
1654
|
+
let fix2 = function(fixer) {
|
|
1524
1655
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1525
1656
|
};
|
|
1657
|
+
var fix = fix2;
|
|
1526
1658
|
context.report({
|
|
1527
1659
|
messageId: "narrowed",
|
|
1528
1660
|
node: param,
|
|
1529
1661
|
suggest: [
|
|
1530
1662
|
{
|
|
1531
1663
|
messageId: "suggestExplicitUnknown",
|
|
1532
|
-
fix
|
|
1664
|
+
fix: fix2
|
|
1533
1665
|
}
|
|
1534
1666
|
]
|
|
1535
1667
|
});
|
|
1536
1668
|
}
|
|
1537
1669
|
} else {
|
|
1538
|
-
let
|
|
1670
|
+
let fix2 = function(fixer) {
|
|
1539
1671
|
if (isParenthesised(sourceCode, param)) {
|
|
1540
1672
|
return fixer.insertTextAfter(param, ": unknown");
|
|
1541
1673
|
}
|
|
@@ -1544,14 +1676,15 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1544
1676
|
fixer.insertTextAfter(param, ": unknown)")
|
|
1545
1677
|
];
|
|
1546
1678
|
};
|
|
1679
|
+
var fix = fix2;
|
|
1547
1680
|
context.report({
|
|
1548
|
-
fix,
|
|
1681
|
+
fix: fix2,
|
|
1549
1682
|
messageId: "implicitAny",
|
|
1550
1683
|
node: param,
|
|
1551
1684
|
suggest: [
|
|
1552
1685
|
{
|
|
1553
1686
|
messageId: "suggestExplicitUnknown",
|
|
1554
|
-
fix
|
|
1687
|
+
fix: fix2
|
|
1555
1688
|
}
|
|
1556
1689
|
]
|
|
1557
1690
|
});
|
|
@@ -1587,11 +1720,12 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1587
1720
|
}
|
|
1588
1721
|
});
|
|
1589
1722
|
|
|
1590
|
-
|
|
1723
|
+
// src/rules/no-index.ts
|
|
1724
|
+
var noIndexRule = ruleCreator({
|
|
1591
1725
|
defaultOptions: [],
|
|
1592
1726
|
meta: {
|
|
1593
1727
|
docs: {
|
|
1594
|
-
description: "
|
|
1728
|
+
description: "Disallow importing index modules.",
|
|
1595
1729
|
recommended: true
|
|
1596
1730
|
},
|
|
1597
1731
|
messages: {
|
|
@@ -1613,11 +1747,12 @@ const noIndexRule = ruleCreator({
|
|
|
1613
1747
|
}
|
|
1614
1748
|
});
|
|
1615
1749
|
|
|
1616
|
-
|
|
1750
|
+
// src/rules/no-internal.ts
|
|
1751
|
+
var noInternalRule = ruleCreator({
|
|
1617
1752
|
defaultOptions: [],
|
|
1618
1753
|
meta: {
|
|
1619
1754
|
docs: {
|
|
1620
|
-
description: "
|
|
1755
|
+
description: "Disallow importing internal modules.",
|
|
1621
1756
|
recommended: true
|
|
1622
1757
|
},
|
|
1623
1758
|
fixable: "code",
|
|
@@ -1667,14 +1802,15 @@ const noInternalRule = ruleCreator({
|
|
|
1667
1802
|
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002finternal/]`]: (node) => {
|
|
1668
1803
|
const replacement = getReplacement(node.raw);
|
|
1669
1804
|
if (replacement) {
|
|
1670
|
-
let
|
|
1805
|
+
let fix2 = function(fixer) {
|
|
1671
1806
|
return fixer.replaceText(node, replacement);
|
|
1672
1807
|
};
|
|
1808
|
+
var fix = fix2;
|
|
1673
1809
|
context.report({
|
|
1674
|
-
fix,
|
|
1810
|
+
fix: fix2,
|
|
1675
1811
|
messageId: "forbidden",
|
|
1676
1812
|
node,
|
|
1677
|
-
suggest: [{ fix, messageId: "suggest" }]
|
|
1813
|
+
suggest: [{ fix: fix2, messageId: "suggest" }]
|
|
1678
1814
|
});
|
|
1679
1815
|
} else {
|
|
1680
1816
|
context.report({
|
|
@@ -1687,11 +1823,12 @@ const noInternalRule = ruleCreator({
|
|
|
1687
1823
|
}
|
|
1688
1824
|
});
|
|
1689
1825
|
|
|
1690
|
-
|
|
1826
|
+
// src/rules/no-nested-subscribe.ts
|
|
1827
|
+
var noNestedSubscribeRule = ruleCreator({
|
|
1691
1828
|
defaultOptions: [],
|
|
1692
1829
|
meta: {
|
|
1693
1830
|
docs: {
|
|
1694
|
-
description: "
|
|
1831
|
+
description: "Disallow calling `subscribe` within a `subscribe` callback.",
|
|
1695
1832
|
recommended: true,
|
|
1696
1833
|
requiresTypeChecking: true
|
|
1697
1834
|
},
|
|
@@ -1703,11 +1840,11 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1703
1840
|
},
|
|
1704
1841
|
name: "no-nested-subscribe",
|
|
1705
1842
|
create: (context) => {
|
|
1706
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1843
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1707
1844
|
const argumentsMap = /* @__PURE__ */ new WeakMap();
|
|
1708
1845
|
return {
|
|
1709
1846
|
[`CallExpression > MemberExpression[property.name='subscribe']`]: (node) => {
|
|
1710
|
-
if (!couldBeObservable(node.object) && !
|
|
1847
|
+
if (!couldBeObservable(node.object) && !couldBeType2(node.object, "Subscribable")) {
|
|
1711
1848
|
return;
|
|
1712
1849
|
}
|
|
1713
1850
|
const callExpression = node.parent;
|
|
@@ -1730,11 +1867,12 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1730
1867
|
}
|
|
1731
1868
|
});
|
|
1732
1869
|
|
|
1733
|
-
|
|
1870
|
+
// src/rules/no-redundant-notify.ts
|
|
1871
|
+
var noRedundantNotifyRule = ruleCreator({
|
|
1734
1872
|
defaultOptions: [],
|
|
1735
1873
|
meta: {
|
|
1736
1874
|
docs: {
|
|
1737
|
-
description: "
|
|
1875
|
+
description: "Disallow sending redundant notifications from completed or errored observables.",
|
|
1738
1876
|
recommended: true,
|
|
1739
1877
|
requiresTypeChecking: true
|
|
1740
1878
|
},
|
|
@@ -1747,7 +1885,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1747
1885
|
name: "no-redundant-notify",
|
|
1748
1886
|
create: (context) => {
|
|
1749
1887
|
const sourceCode = context.sourceCode;
|
|
1750
|
-
const { couldBeType } = getTypeServices(context);
|
|
1888
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1751
1889
|
return {
|
|
1752
1890
|
"ExpressionStatement[expression.callee.property.name=/^(complete|error)$/] + ExpressionStatement[expression.callee.property.name=/^(next|complete|error)$/]": (node) => {
|
|
1753
1891
|
const parent = node.parent;
|
|
@@ -1763,7 +1901,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1763
1901
|
if (getExpressionText(sibling, sourceCode) !== getExpressionText(node, sourceCode)) {
|
|
1764
1902
|
return;
|
|
1765
1903
|
}
|
|
1766
|
-
if (!isExpressionObserver(sibling,
|
|
1904
|
+
if (!isExpressionObserver(sibling, couldBeType2) || !isExpressionObserver(node, couldBeType2)) {
|
|
1767
1905
|
return;
|
|
1768
1906
|
}
|
|
1769
1907
|
const { expression } = node;
|
|
@@ -1794,7 +1932,7 @@ function getExpressionText(expressionStatement, sourceCode) {
|
|
|
1794
1932
|
const { object } = callExpression.callee;
|
|
1795
1933
|
return sourceCode.getText(object);
|
|
1796
1934
|
}
|
|
1797
|
-
function isExpressionObserver(expressionStatement,
|
|
1935
|
+
function isExpressionObserver(expressionStatement, couldBeType2) {
|
|
1798
1936
|
if (!isCallExpression(expressionStatement.expression)) {
|
|
1799
1937
|
return false;
|
|
1800
1938
|
}
|
|
@@ -1803,15 +1941,17 @@ function isExpressionObserver(expressionStatement, couldBeType) {
|
|
|
1803
1941
|
return false;
|
|
1804
1942
|
}
|
|
1805
1943
|
const { object } = callExpression.callee;
|
|
1806
|
-
return
|
|
1944
|
+
return couldBeType2(object, /^(Subject|Subscriber)$/);
|
|
1807
1945
|
}
|
|
1808
1946
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
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,
|
|
1812
1952
|
meta: {
|
|
1813
1953
|
docs: {
|
|
1814
|
-
description: "
|
|
1954
|
+
description: "Disallow unsafe `shareReplay` usage.",
|
|
1815
1955
|
recommended: true
|
|
1816
1956
|
},
|
|
1817
1957
|
messages: {
|
|
@@ -1821,7 +1961,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1821
1961
|
schema: [
|
|
1822
1962
|
{
|
|
1823
1963
|
properties: {
|
|
1824
|
-
allowConfig: { type: "boolean" }
|
|
1964
|
+
allowConfig: { type: "boolean", description: "Allow shareReplay if a config argument is specified.", default: true }
|
|
1825
1965
|
},
|
|
1826
1966
|
type: "object"
|
|
1827
1967
|
}
|
|
@@ -1836,7 +1976,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1836
1976
|
"CallExpression[callee.name='shareReplay']": (node) => {
|
|
1837
1977
|
let report = true;
|
|
1838
1978
|
if (allowConfig) {
|
|
1839
|
-
report = node.arguments.length !== 1 || node.arguments[0].type !==
|
|
1979
|
+
report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES7.ObjectExpression;
|
|
1840
1980
|
}
|
|
1841
1981
|
if (report) {
|
|
1842
1982
|
context.report({
|
|
@@ -1849,11 +1989,12 @@ const noSharereplayRule = ruleCreator({
|
|
|
1849
1989
|
}
|
|
1850
1990
|
});
|
|
1851
1991
|
|
|
1852
|
-
|
|
1992
|
+
// src/rules/no-subclass.ts
|
|
1993
|
+
var noSubclassRule = ruleCreator({
|
|
1853
1994
|
defaultOptions: [],
|
|
1854
1995
|
meta: {
|
|
1855
1996
|
docs: {
|
|
1856
|
-
description: "
|
|
1997
|
+
description: "Disallow subclassing RxJS classes.",
|
|
1857
1998
|
requiresTypeChecking: true
|
|
1858
1999
|
},
|
|
1859
2000
|
messages: {
|
|
@@ -1864,7 +2005,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1864
2005
|
},
|
|
1865
2006
|
name: "no-subclass",
|
|
1866
2007
|
create: (context) => {
|
|
1867
|
-
const { couldBeType } = getTypeServices(context);
|
|
2008
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1868
2009
|
const queryNames = [
|
|
1869
2010
|
"AsyncSubject",
|
|
1870
2011
|
"BehaviorSubject",
|
|
@@ -1879,7 +2020,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1879
2020
|
"|"
|
|
1880
2021
|
)})$/] > Identifier.superClass`]: (node) => {
|
|
1881
2022
|
if (queryNames.some(
|
|
1882
|
-
(
|
|
2023
|
+
(name2) => couldBeType2(node, name2, { name: /[/\\]rxjs[/\\]/ })
|
|
1883
2024
|
)) {
|
|
1884
2025
|
context.report({
|
|
1885
2026
|
messageId: "forbidden",
|
|
@@ -1891,11 +2032,12 @@ const noSubclassRule = ruleCreator({
|
|
|
1891
2032
|
}
|
|
1892
2033
|
});
|
|
1893
2034
|
|
|
1894
|
-
|
|
2035
|
+
// src/rules/no-subject-unsubscribe.ts
|
|
2036
|
+
var noSubjectUnsubscribeRule = ruleCreator({
|
|
1895
2037
|
defaultOptions: [],
|
|
1896
2038
|
meta: {
|
|
1897
2039
|
docs: {
|
|
1898
|
-
description: "
|
|
2040
|
+
description: "Disallow calling the `unsubscribe` method of subjects.",
|
|
1899
2041
|
recommended: true,
|
|
1900
2042
|
requiresTypeChecking: true
|
|
1901
2043
|
},
|
|
@@ -1933,11 +2075,12 @@ const noSubjectUnsubscribeRule = ruleCreator({
|
|
|
1933
2075
|
}
|
|
1934
2076
|
});
|
|
1935
2077
|
|
|
1936
|
-
|
|
2078
|
+
// src/rules/no-subject-value.ts
|
|
2079
|
+
var noSubjectValueRule = ruleCreator({
|
|
1937
2080
|
defaultOptions: [],
|
|
1938
2081
|
meta: {
|
|
1939
2082
|
docs: {
|
|
1940
|
-
description: "
|
|
2083
|
+
description: "Disallow accessing the `value` property of a `BehaviorSubject` instance.",
|
|
1941
2084
|
requiresTypeChecking: true
|
|
1942
2085
|
},
|
|
1943
2086
|
messages: {
|
|
@@ -1966,11 +2109,12 @@ const noSubjectValueRule = ruleCreator({
|
|
|
1966
2109
|
}
|
|
1967
2110
|
});
|
|
1968
2111
|
|
|
1969
|
-
|
|
2112
|
+
// src/rules/no-subscribe-handlers.ts
|
|
2113
|
+
var noSubscribeHandlersRule = ruleCreator({
|
|
1970
2114
|
defaultOptions: [],
|
|
1971
2115
|
meta: {
|
|
1972
2116
|
docs: {
|
|
1973
|
-
description: "
|
|
2117
|
+
description: "Disallow passing handlers to `subscribe`.",
|
|
1974
2118
|
requiresTypeChecking: true
|
|
1975
2119
|
},
|
|
1976
2120
|
messages: {
|
|
@@ -1981,11 +2125,11 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
1981
2125
|
},
|
|
1982
2126
|
name: "no-subscribe-handlers",
|
|
1983
2127
|
create: (context) => {
|
|
1984
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
2128
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1985
2129
|
return {
|
|
1986
2130
|
"CallExpression[arguments.length > 0][callee.property.name='subscribe']": (node) => {
|
|
1987
2131
|
const callee = node.callee;
|
|
1988
|
-
if (couldBeObservable(callee.object) ||
|
|
2132
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
1989
2133
|
context.report({
|
|
1990
2134
|
messageId: "forbidden",
|
|
1991
2135
|
node: callee.property
|
|
@@ -1996,12 +2140,13 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
1996
2140
|
}
|
|
1997
2141
|
});
|
|
1998
2142
|
|
|
1999
|
-
|
|
2143
|
+
// src/rules/no-tap.ts
|
|
2144
|
+
var noTapRule = ruleCreator({
|
|
2000
2145
|
defaultOptions: [],
|
|
2001
2146
|
meta: {
|
|
2002
2147
|
deprecated: true,
|
|
2003
2148
|
docs: {
|
|
2004
|
-
description: "
|
|
2149
|
+
description: "Disallow the `tap` operator."
|
|
2005
2150
|
},
|
|
2006
2151
|
messages: {
|
|
2007
2152
|
forbidden: "The tap operator is forbidden."
|
|
@@ -2030,11 +2175,12 @@ const noTapRule = ruleCreator({
|
|
|
2030
2175
|
}
|
|
2031
2176
|
});
|
|
2032
2177
|
|
|
2033
|
-
|
|
2178
|
+
// src/rules/no-topromise.ts
|
|
2179
|
+
var noTopromiseRule = ruleCreator({
|
|
2034
2180
|
defaultOptions: [],
|
|
2035
2181
|
meta: {
|
|
2036
2182
|
docs: {
|
|
2037
|
-
description: "
|
|
2183
|
+
description: "Disallow use of the `toPromise` method.",
|
|
2038
2184
|
requiresTypeChecking: true
|
|
2039
2185
|
},
|
|
2040
2186
|
messages: {
|
|
@@ -2059,11 +2205,12 @@ const noTopromiseRule = ruleCreator({
|
|
|
2059
2205
|
}
|
|
2060
2206
|
});
|
|
2061
2207
|
|
|
2062
|
-
|
|
2208
|
+
// src/rules/no-unbound-methods.ts
|
|
2209
|
+
var noUnboundMethodsRule = ruleCreator({
|
|
2063
2210
|
defaultOptions: [],
|
|
2064
2211
|
meta: {
|
|
2065
2212
|
docs: {
|
|
2066
|
-
description: "
|
|
2213
|
+
description: "Disallow passing unbound methods.",
|
|
2067
2214
|
recommended: true,
|
|
2068
2215
|
requiresTypeChecking: true
|
|
2069
2216
|
},
|
|
@@ -2120,12 +2267,14 @@ const noUnboundMethodsRule = ruleCreator({
|
|
|
2120
2267
|
}
|
|
2121
2268
|
});
|
|
2122
2269
|
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
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,
|
|
2126
2275
|
meta: {
|
|
2127
2276
|
docs: {
|
|
2128
|
-
description: "
|
|
2277
|
+
description: "Disallow unsafe `catchError` usage in effects and epics.",
|
|
2129
2278
|
requiresTypeChecking: true
|
|
2130
2279
|
},
|
|
2131
2280
|
messages: {
|
|
@@ -2134,10 +2283,10 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2134
2283
|
schema: [
|
|
2135
2284
|
{
|
|
2136
2285
|
properties: {
|
|
2137
|
-
observable: { type: "string" }
|
|
2286
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2138
2287
|
},
|
|
2139
2288
|
type: "object",
|
|
2140
|
-
description:
|
|
2289
|
+
description: stripIndent4`
|
|
2141
2290
|
An optional object with an optional \`observable\` property.
|
|
2142
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.`
|
|
2143
2292
|
}
|
|
@@ -2179,12 +2328,14 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2179
2328
|
}
|
|
2180
2329
|
});
|
|
2181
2330
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
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,
|
|
2185
2336
|
meta: {
|
|
2186
2337
|
docs: {
|
|
2187
|
-
description: "
|
|
2338
|
+
description: "Disallow unsafe `first`/`take` usage in effects and epics.",
|
|
2188
2339
|
requiresTypeChecking: true
|
|
2189
2340
|
},
|
|
2190
2341
|
messages: {
|
|
@@ -2193,10 +2344,10 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2193
2344
|
schema: [
|
|
2194
2345
|
{
|
|
2195
2346
|
properties: {
|
|
2196
|
-
observable: { type: "string" }
|
|
2347
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2197
2348
|
},
|
|
2198
2349
|
type: "object",
|
|
2199
|
-
description:
|
|
2350
|
+
description: stripIndent5`
|
|
2200
2351
|
An optional object with an optional \`observable\` property.
|
|
2201
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.`
|
|
2202
2353
|
}
|
|
@@ -2247,11 +2398,14 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2247
2398
|
}
|
|
2248
2399
|
});
|
|
2249
2400
|
|
|
2250
|
-
|
|
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({
|
|
2251
2405
|
defaultOptions: [],
|
|
2252
2406
|
meta: {
|
|
2253
2407
|
docs: {
|
|
2254
|
-
description: "
|
|
2408
|
+
description: "Disallow unsafe optional `next` calls.",
|
|
2255
2409
|
recommended: true,
|
|
2256
2410
|
requiresTypeChecking: true
|
|
2257
2411
|
},
|
|
@@ -2268,19 +2422,19 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2268
2422
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
2269
2423
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
2270
2424
|
const type = getType(node.callee.object);
|
|
2271
|
-
if (
|
|
2425
|
+
if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
2272
2426
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
2273
|
-
if (
|
|
2427
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
|
|
2274
2428
|
return;
|
|
2275
2429
|
}
|
|
2276
|
-
if (
|
|
2430
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
|
|
2277
2431
|
return;
|
|
2278
2432
|
}
|
|
2279
|
-
if (
|
|
2433
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
|
|
2280
2434
|
return;
|
|
2281
2435
|
}
|
|
2282
|
-
if (isUnionType(typeArg) && typeArg.types.some(
|
|
2283
|
-
(t) =>
|
|
2436
|
+
if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
|
|
2437
|
+
(t) => tsutils3.isTypeFlagSet(t, ts6.TypeFlags.Void)
|
|
2284
2438
|
)) {
|
|
2285
2439
|
return;
|
|
2286
2440
|
}
|
|
@@ -2295,12 +2449,15 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2295
2449
|
}
|
|
2296
2450
|
});
|
|
2297
2451
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
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,
|
|
2301
2458
|
meta: {
|
|
2302
2459
|
docs: {
|
|
2303
|
-
description: "
|
|
2460
|
+
description: "Disallow unsafe `switchMap` usage in effects and epics.",
|
|
2304
2461
|
requiresTypeChecking: true
|
|
2305
2462
|
},
|
|
2306
2463
|
messages: {
|
|
@@ -2310,26 +2467,27 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2310
2467
|
{
|
|
2311
2468
|
properties: {
|
|
2312
2469
|
allow: {
|
|
2470
|
+
description: "Action types that are allowed to be used with switchMap. Mutually exclusive with `disallow`.",
|
|
2313
2471
|
oneOf: [
|
|
2314
|
-
{ type: "string" },
|
|
2315
|
-
{ type: "array", items: { type: "string" } }
|
|
2472
|
+
{ type: "string", description: "A regular expression string." },
|
|
2473
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2316
2474
|
]
|
|
2317
2475
|
},
|
|
2318
2476
|
disallow: {
|
|
2477
|
+
description: "Action types that are disallowed to be used with switchMap. Mutually exclusive with `allow`.",
|
|
2319
2478
|
oneOf: [
|
|
2320
|
-
{ type: "string" },
|
|
2321
|
-
{ type: "array", items: { type: "string" } }
|
|
2479
|
+
{ type: "string", description: "A regular expression string." },
|
|
2480
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2322
2481
|
]
|
|
2323
2482
|
},
|
|
2324
2483
|
observable: {
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
]
|
|
2484
|
+
type: "string",
|
|
2485
|
+
description: "A RegExp that matches an effect or epic's actions observable.",
|
|
2486
|
+
default: defaultObservable
|
|
2329
2487
|
}
|
|
2330
2488
|
},
|
|
2331
2489
|
type: "object",
|
|
2332
|
-
description:
|
|
2490
|
+
description: stripIndent6`
|
|
2333
2491
|
An optional object with optional \`allow\`, \`disallow\` and \`observable\` properties.
|
|
2334
2492
|
The properties can be specified as regular expression strings or as arrays of words.
|
|
2335
2493
|
The \`allow\` or \`disallow\` properties are mutually exclusive. Whether or not
|
|
@@ -2342,6 +2500,7 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2342
2500
|
},
|
|
2343
2501
|
name: "no-unsafe-switchmap",
|
|
2344
2502
|
create: (context) => {
|
|
2503
|
+
var _a, _b, _c;
|
|
2345
2504
|
const defaultDisallow = [
|
|
2346
2505
|
"add",
|
|
2347
2506
|
"create",
|
|
@@ -2357,9 +2516,9 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2357
2516
|
let observableRegExp;
|
|
2358
2517
|
const [config = {}] = context.options;
|
|
2359
2518
|
if (config.allow || config.disallow) {
|
|
2360
|
-
allowRegExp = createRegExpForWords(config.allow
|
|
2361
|
-
disallowRegExp = createRegExpForWords(config.disallow
|
|
2362
|
-
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);
|
|
2363
2522
|
} else {
|
|
2364
2523
|
allowRegExp = void 0;
|
|
2365
2524
|
disallowRegExp = createRegExpForWords(defaultDisallow);
|
|
@@ -2378,12 +2537,12 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2378
2537
|
return arg.property.name;
|
|
2379
2538
|
}
|
|
2380
2539
|
return "";
|
|
2381
|
-
}).map((
|
|
2540
|
+
}).map((name2) => decamelize(name2));
|
|
2382
2541
|
if (allowRegExp) {
|
|
2383
|
-
return !names.every((
|
|
2542
|
+
return !names.every((name2) => allowRegExp == null ? void 0 : allowRegExp.test(name2));
|
|
2384
2543
|
}
|
|
2385
2544
|
if (disallowRegExp) {
|
|
2386
|
-
return names.some((
|
|
2545
|
+
return names.some((name2) => disallowRegExp == null ? void 0 : disallowRegExp.test(name2));
|
|
2387
2546
|
}
|
|
2388
2547
|
return false;
|
|
2389
2548
|
}
|
|
@@ -2416,12 +2575,37 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2416
2575
|
}
|
|
2417
2576
|
});
|
|
2418
2577
|
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
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,
|
|
2422
2606
|
meta: {
|
|
2423
2607
|
docs: {
|
|
2424
|
-
description: "
|
|
2608
|
+
description: "Disallow applying operators after `takeUntil`.",
|
|
2425
2609
|
recommended: true,
|
|
2426
2610
|
requiresTypeChecking: true
|
|
2427
2611
|
},
|
|
@@ -2431,11 +2615,11 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2431
2615
|
schema: [
|
|
2432
2616
|
{
|
|
2433
2617
|
properties: {
|
|
2434
|
-
alias: { type: "array", items: { type: "string" } },
|
|
2435
|
-
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 }
|
|
2436
2620
|
},
|
|
2437
2621
|
type: "object",
|
|
2438
|
-
description:
|
|
2622
|
+
description: stripIndent7`
|
|
2439
2623
|
An optional object with optional \`alias\` and \`allow\` properties.
|
|
2440
2624
|
The \`alias\` property is an array containing the names of operators that aliases for \`takeUntil\`.
|
|
2441
2625
|
The \`allow\` property is an array containing the names of the operators that are allowed to follow \`takeUntil\`.`
|
|
@@ -2446,29 +2630,6 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2446
2630
|
name: "no-unsafe-takeuntil",
|
|
2447
2631
|
create: (context) => {
|
|
2448
2632
|
let checkedOperatorsRegExp = /^takeUntil$/;
|
|
2449
|
-
const allowedOperators = [
|
|
2450
|
-
"count",
|
|
2451
|
-
"defaultIfEmpty",
|
|
2452
|
-
"endWith",
|
|
2453
|
-
"every",
|
|
2454
|
-
"finalize",
|
|
2455
|
-
"finally",
|
|
2456
|
-
"isEmpty",
|
|
2457
|
-
"last",
|
|
2458
|
-
"max",
|
|
2459
|
-
"min",
|
|
2460
|
-
"publish",
|
|
2461
|
-
"publishBehavior",
|
|
2462
|
-
"publishLast",
|
|
2463
|
-
"publishReplay",
|
|
2464
|
-
"reduce",
|
|
2465
|
-
"share",
|
|
2466
|
-
"shareReplay",
|
|
2467
|
-
"skipLast",
|
|
2468
|
-
"takeLast",
|
|
2469
|
-
"throwIfEmpty",
|
|
2470
|
-
"toArray"
|
|
2471
|
-
];
|
|
2472
2633
|
const [config = {}] = context.options;
|
|
2473
2634
|
const { alias, allow = allowedOperators } = config;
|
|
2474
2635
|
if (alias) {
|
|
@@ -2519,12 +2680,13 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2519
2680
|
}
|
|
2520
2681
|
});
|
|
2521
2682
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2683
|
+
// src/rules/prefer-observer.ts
|
|
2684
|
+
var defaultOptions12 = [];
|
|
2685
|
+
var preferObserverRule = ruleCreator({
|
|
2686
|
+
defaultOptions: defaultOptions12,
|
|
2525
2687
|
meta: {
|
|
2526
2688
|
docs: {
|
|
2527
|
-
description: "
|
|
2689
|
+
description: "Disallow passing separate handlers to `subscribe` and `tap`.",
|
|
2528
2690
|
requiresTypeChecking: true
|
|
2529
2691
|
},
|
|
2530
2692
|
fixable: "code",
|
|
@@ -2535,7 +2697,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2535
2697
|
schema: [
|
|
2536
2698
|
{
|
|
2537
2699
|
properties: {
|
|
2538
|
-
allowNext: { type: "boolean" }
|
|
2700
|
+
allowNext: { type: "boolean", description: "Allows a single `next` callback.", default: true }
|
|
2539
2701
|
},
|
|
2540
2702
|
type: "object"
|
|
2541
2703
|
}
|
|
@@ -2544,7 +2706,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2544
2706
|
},
|
|
2545
2707
|
name: "prefer-observer",
|
|
2546
2708
|
create: (context) => {
|
|
2547
|
-
const { couldBeFunction, couldBeObservable } = getTypeServices(context);
|
|
2709
|
+
const { couldBeFunction: couldBeFunction2, couldBeObservable } = getTypeServices(context);
|
|
2548
2710
|
const [config = {}] = context.options;
|
|
2549
2711
|
const { allowNext = true } = config;
|
|
2550
2712
|
function checkArgs(callExpression, reportNode) {
|
|
@@ -2588,7 +2750,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2588
2750
|
});
|
|
2589
2751
|
} else if (args.length === 1 && !allowNext) {
|
|
2590
2752
|
const [arg] = args;
|
|
2591
|
-
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) ||
|
|
2753
|
+
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) || couldBeFunction2(arg)) {
|
|
2592
2754
|
context.report({
|
|
2593
2755
|
messageId: "forbidden",
|
|
2594
2756
|
node: reportNode,
|
|
@@ -2617,12 +2779,14 @@ function isValidArgText(argText) {
|
|
|
2617
2779
|
return argText && argText !== "undefined" && argText !== "null";
|
|
2618
2780
|
}
|
|
2619
2781
|
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
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,
|
|
2623
2787
|
meta: {
|
|
2624
2788
|
docs: {
|
|
2625
|
-
description: "
|
|
2789
|
+
description: "Enforce the use of a suffix in subject identifiers.",
|
|
2626
2790
|
requiresTypeChecking: true
|
|
2627
2791
|
},
|
|
2628
2792
|
messages: {
|
|
@@ -2631,11 +2795,11 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2631
2795
|
schema: [
|
|
2632
2796
|
{
|
|
2633
2797
|
properties: {
|
|
2634
|
-
parameters: { type: "boolean" },
|
|
2635
|
-
properties: { type: "boolean" },
|
|
2636
|
-
suffix: { type: "string" },
|
|
2637
|
-
types: { type: "object" },
|
|
2638
|
-
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." }
|
|
2639
2803
|
},
|
|
2640
2804
|
type: "object"
|
|
2641
2805
|
}
|
|
@@ -2644,8 +2808,8 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2644
2808
|
},
|
|
2645
2809
|
name: "suffix-subjects",
|
|
2646
2810
|
create: (context) => {
|
|
2647
|
-
const { esTreeNodeToTSNodeMap } =
|
|
2648
|
-
const { couldBeType } = getTypeServices(context);
|
|
2811
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils5.getParserServices(context);
|
|
2812
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2649
2813
|
const [config = {}] = context.options;
|
|
2650
2814
|
const validate = {
|
|
2651
2815
|
parameters: true,
|
|
@@ -2674,10 +2838,10 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2674
2838
|
function checkNode(nameNode, typeNode) {
|
|
2675
2839
|
const tsNode = esTreeNodeToTSNodeMap.get(nameNode);
|
|
2676
2840
|
const text = tsNode.getText();
|
|
2677
|
-
if (!suffixRegex.test(text) &&
|
|
2841
|
+
if (!suffixRegex.test(text) && couldBeType2(typeNode || nameNode, "Subject")) {
|
|
2678
2842
|
for (const type of types) {
|
|
2679
2843
|
const { regExp, validate: validate2 } = type;
|
|
2680
|
-
if (
|
|
2844
|
+
if (couldBeType2(typeNode || nameNode, regExp) && !validate2) {
|
|
2681
2845
|
return;
|
|
2682
2846
|
}
|
|
2683
2847
|
}
|
|
@@ -2700,7 +2864,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2700
2864
|
if (!found) {
|
|
2701
2865
|
return;
|
|
2702
2866
|
}
|
|
2703
|
-
if (!validate.variables && found.type ===
|
|
2867
|
+
if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
|
|
2704
2868
|
return;
|
|
2705
2869
|
}
|
|
2706
2870
|
if (!validate.parameters) {
|
|
@@ -2767,7 +2931,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2767
2931
|
if (!found) {
|
|
2768
2932
|
return;
|
|
2769
2933
|
}
|
|
2770
|
-
if (!validate.variables && found.type ===
|
|
2934
|
+
if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
|
|
2771
2935
|
return;
|
|
2772
2936
|
}
|
|
2773
2937
|
if (!validate.parameters) {
|
|
@@ -2813,11 +2977,14 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2813
2977
|
}
|
|
2814
2978
|
});
|
|
2815
2979
|
|
|
2816
|
-
|
|
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({
|
|
2817
2984
|
defaultOptions: [],
|
|
2818
2985
|
meta: {
|
|
2819
2986
|
docs: {
|
|
2820
|
-
description: "
|
|
2987
|
+
description: "Enforce passing only `Error` values to error notifications.",
|
|
2821
2988
|
requiresTypeChecking: true
|
|
2822
2989
|
},
|
|
2823
2990
|
messages: {
|
|
@@ -2828,7 +2995,7 @@ const throwErrorRule = ruleCreator({
|
|
|
2828
2995
|
},
|
|
2829
2996
|
name: "throw-error",
|
|
2830
2997
|
create: (context) => {
|
|
2831
|
-
const { esTreeNodeToTSNodeMap, program } =
|
|
2998
|
+
const { esTreeNodeToTSNodeMap, program } = ESLintUtils6.getParserServices(context);
|
|
2832
2999
|
const { couldBeObservable, getType } = getTypeServices(context);
|
|
2833
3000
|
function checkNode(node) {
|
|
2834
3001
|
let type = getType(node);
|
|
@@ -2836,9 +3003,9 @@ const throwErrorRule = ruleCreator({
|
|
|
2836
3003
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
2837
3004
|
const annotation = tsNode.type;
|
|
2838
3005
|
const body = tsNode.body;
|
|
2839
|
-
type = program.getTypeChecker().getTypeAtLocation(annotation
|
|
3006
|
+
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
2840
3007
|
}
|
|
2841
|
-
if (!
|
|
3008
|
+
if (!tsutils4.isIntrinsicAnyType(type) && !tsutils4.isIntrinsicUnknownType(type) && !couldBeType(type, /^(Error|DOMException)$/)) {
|
|
2842
3009
|
context.report({
|
|
2843
3010
|
messageId: "forbidden",
|
|
2844
3011
|
node
|
|
@@ -2859,7 +3026,8 @@ const throwErrorRule = ruleCreator({
|
|
|
2859
3026
|
}
|
|
2860
3027
|
});
|
|
2861
3028
|
|
|
2862
|
-
|
|
3029
|
+
// src/index.ts
|
|
3030
|
+
var plugin = {
|
|
2863
3031
|
meta: { name, version },
|
|
2864
3032
|
rules: {
|
|
2865
3033
|
"ban-observables": banObservablesRule,
|
|
@@ -2905,11 +3073,13 @@ const plugin = {
|
|
|
2905
3073
|
"throw-error": throwErrorRule
|
|
2906
3074
|
}
|
|
2907
3075
|
};
|
|
2908
|
-
|
|
3076
|
+
var rxjsX = {
|
|
2909
3077
|
...plugin,
|
|
2910
3078
|
configs: {
|
|
2911
3079
|
recommended: createRecommendedConfig(plugin)
|
|
2912
3080
|
}
|
|
2913
3081
|
};
|
|
2914
|
-
|
|
2915
|
-
export {
|
|
3082
|
+
var src_default = rxjsX;
|
|
3083
|
+
export {
|
|
3084
|
+
src_default as default
|
|
3085
|
+
};
|