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
|
@@ -1,38 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const commonTags = require('common-tags');
|
|
5
|
-
const tsutils = require('tsutils-etc');
|
|
6
|
-
const ts = require('typescript');
|
|
7
|
-
const scopeManager = require('@typescript-eslint/scope-manager');
|
|
8
|
-
const tsutils$1 = require('tsutils');
|
|
9
|
-
const decamelize = require('decamelize');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
|
-
|
|
13
|
-
function _interopNamespaceCompat(e) {
|
|
14
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
15
|
-
const n = Object.create(null);
|
|
16
|
-
if (e) {
|
|
17
|
-
for (const k in e) {
|
|
18
|
-
n[k] = e[k];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return n;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const tsutils__namespace = /*#__PURE__*/_interopNamespaceCompat(tsutils);
|
|
26
|
-
const ts__namespace = /*#__PURE__*/_interopNamespaceCompat(ts);
|
|
27
|
-
const tsutils__namespace$1 = /*#__PURE__*/_interopNamespaceCompat(tsutils$1);
|
|
28
|
-
const decamelize__default = /*#__PURE__*/_interopDefaultCompat(decamelize);
|
|
29
|
-
|
|
30
|
-
const name = "eslint-plugin-rxjs-x";
|
|
31
|
-
const version = "0.0.2";
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// package.json
|
|
2
|
+
var name = "eslint-plugin-rxjs-x";
|
|
3
|
+
var version = "0.2.0";
|
|
32
4
|
|
|
33
|
-
|
|
5
|
+
// src/configs/recommended.ts
|
|
6
|
+
var createRecommendedConfig = (plugin2) => ({
|
|
34
7
|
plugins: {
|
|
35
|
-
"rxjs-x":
|
|
8
|
+
"rxjs-x": plugin2
|
|
36
9
|
},
|
|
37
10
|
rules: {
|
|
38
11
|
"rxjs-x/no-async-subscribe": "error",
|
|
@@ -53,8 +26,14 @@ const createRecommendedConfig = (plugin) => ({
|
|
|
53
26
|
}
|
|
54
27
|
});
|
|
55
28
|
|
|
29
|
+
// src/rules/ban-observables.ts
|
|
30
|
+
var _utils = require('@typescript-eslint/utils');
|
|
31
|
+
var _commontags = require('common-tags');
|
|
32
|
+
|
|
33
|
+
// src/utils.ts
|
|
34
|
+
|
|
56
35
|
function createRegExpForWords(config) {
|
|
57
|
-
if (!config
|
|
36
|
+
if (!(config == null ? void 0 : config.length)) {
|
|
58
37
|
return void 0;
|
|
59
38
|
}
|
|
60
39
|
const flags = "i";
|
|
@@ -68,16 +47,17 @@ function createRegExpForWords(config) {
|
|
|
68
47
|
function escapeRegExp(text) {
|
|
69
48
|
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
70
49
|
}
|
|
71
|
-
|
|
72
|
-
(
|
|
50
|
+
var ruleCreator = _utils.ESLintUtils.RuleCreator(
|
|
51
|
+
(name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
|
|
73
52
|
);
|
|
74
53
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
54
|
+
// src/rules/ban-observables.ts
|
|
55
|
+
var defaultOptions = [];
|
|
56
|
+
var banObservablesRule = ruleCreator({
|
|
57
|
+
defaultOptions,
|
|
78
58
|
meta: {
|
|
79
59
|
docs: {
|
|
80
|
-
description: "
|
|
60
|
+
description: "Disallow banned observable creators."
|
|
81
61
|
},
|
|
82
62
|
messages: {
|
|
83
63
|
forbidden: "RxJS observable is banned: {{name}}{{explanation}}."
|
|
@@ -85,7 +65,7 @@ const banObservablesRule = ruleCreator({
|
|
|
85
65
|
schema: [
|
|
86
66
|
{
|
|
87
67
|
type: "object",
|
|
88
|
-
description:
|
|
68
|
+
description: _commontags.stripIndent`
|
|
89
69
|
An object containing keys that are names of observable factory functions
|
|
90
70
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
91
71
|
}
|
|
@@ -107,14 +87,14 @@ const banObservablesRule = ruleCreator({
|
|
|
107
87
|
});
|
|
108
88
|
}
|
|
109
89
|
});
|
|
110
|
-
function getFailure(
|
|
90
|
+
function getFailure(name2) {
|
|
111
91
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
112
92
|
const ban = bans[b];
|
|
113
|
-
if (ban.regExp.test(
|
|
93
|
+
if (ban.regExp.test(name2)) {
|
|
114
94
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
115
95
|
return {
|
|
116
96
|
messageId: "forbidden",
|
|
117
|
-
data: { name, explanation }
|
|
97
|
+
data: { name: name2, explanation }
|
|
118
98
|
};
|
|
119
99
|
}
|
|
120
100
|
}
|
|
@@ -123,8 +103,8 @@ const banObservablesRule = ruleCreator({
|
|
|
123
103
|
return {
|
|
124
104
|
"ImportDeclaration[source.value='rxjs'] > ImportSpecifier": (node) => {
|
|
125
105
|
const identifier = node.imported;
|
|
126
|
-
const
|
|
127
|
-
const failure = getFailure(
|
|
106
|
+
const name2 = identifier.type === _utils.AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
107
|
+
const failure = getFailure(name2);
|
|
128
108
|
if (failure) {
|
|
129
109
|
context.report({
|
|
130
110
|
...failure,
|
|
@@ -136,12 +116,15 @@ const banObservablesRule = ruleCreator({
|
|
|
136
116
|
}
|
|
137
117
|
});
|
|
138
118
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
119
|
+
// src/rules/ban-operators.ts
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
var defaultOptions2 = [];
|
|
123
|
+
var banOperatorsRule = ruleCreator({
|
|
124
|
+
defaultOptions: defaultOptions2,
|
|
142
125
|
meta: {
|
|
143
126
|
docs: {
|
|
144
|
-
description: "
|
|
127
|
+
description: "Disallow banned operators."
|
|
145
128
|
},
|
|
146
129
|
messages: {
|
|
147
130
|
forbidden: "RxJS operator is banned: {{name}}{{explanation}}."
|
|
@@ -149,7 +132,7 @@ const banOperatorsRule = ruleCreator({
|
|
|
149
132
|
schema: [
|
|
150
133
|
{
|
|
151
134
|
type: "object",
|
|
152
|
-
description:
|
|
135
|
+
description: _commontags.stripIndent`
|
|
153
136
|
An object containing keys that are names of operators
|
|
154
137
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
155
138
|
}
|
|
@@ -171,14 +154,14 @@ const banOperatorsRule = ruleCreator({
|
|
|
171
154
|
});
|
|
172
155
|
}
|
|
173
156
|
});
|
|
174
|
-
function getFailure(
|
|
157
|
+
function getFailure(name2) {
|
|
175
158
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
176
159
|
const ban = bans[b];
|
|
177
|
-
if (ban.regExp.test(
|
|
160
|
+
if (ban.regExp.test(name2)) {
|
|
178
161
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
179
162
|
return {
|
|
180
163
|
messageId: "forbidden",
|
|
181
|
-
data: { name, explanation }
|
|
164
|
+
data: { name: name2, explanation }
|
|
182
165
|
};
|
|
183
166
|
}
|
|
184
167
|
}
|
|
@@ -187,8 +170,8 @@ const banOperatorsRule = ruleCreator({
|
|
|
187
170
|
return {
|
|
188
171
|
[String.raw`ImportDeclaration[source.value=/^rxjs\u002foperators$/] > ImportSpecifier`]: (node) => {
|
|
189
172
|
const identifier = node.imported;
|
|
190
|
-
const
|
|
191
|
-
const failure = getFailure(
|
|
173
|
+
const name2 = identifier.type === _utils.AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
174
|
+
const failure = getFailure(name2);
|
|
192
175
|
if (failure) {
|
|
193
176
|
context.report({
|
|
194
177
|
...failure,
|
|
@@ -200,6 +183,86 @@ const banOperatorsRule = ruleCreator({
|
|
|
200
183
|
}
|
|
201
184
|
});
|
|
202
185
|
|
|
186
|
+
// src/rules/finnish.ts
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
// src/etc/could-be-function.ts
|
|
190
|
+
var _typescript = require('typescript'); var ts2 = _interopRequireWildcard(_typescript); var ts = _interopRequireWildcard(_typescript); var ts3 = _interopRequireWildcard(_typescript); var ts4 = _interopRequireWildcard(_typescript); var ts5 = _interopRequireWildcard(_typescript); var ts6 = _interopRequireWildcard(_typescript);
|
|
191
|
+
|
|
192
|
+
// src/etc/could-be-type.ts
|
|
193
|
+
var _tsapiutils = require('ts-api-utils'); var tsutils = _interopRequireWildcard(_tsapiutils); var tsutils2 = _interopRequireWildcard(_tsapiutils); var tsutils3 = _interopRequireWildcard(_tsapiutils); var tsutils4 = _interopRequireWildcard(_tsapiutils);
|
|
194
|
+
|
|
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
|
|
203
266
|
function findParent(node, ...args) {
|
|
204
267
|
const [arg] = args;
|
|
205
268
|
const predicate = typeof arg === "function" ? arg : (type) => !args.includes(type) ? "continue" : "return";
|
|
@@ -210,16 +273,20 @@ function findParent(node, ...args) {
|
|
|
210
273
|
return void 0;
|
|
211
274
|
case "return":
|
|
212
275
|
return parent;
|
|
276
|
+
default:
|
|
277
|
+
break;
|
|
213
278
|
}
|
|
214
279
|
parent = parent.parent;
|
|
215
280
|
}
|
|
216
281
|
return void 0;
|
|
217
282
|
}
|
|
218
283
|
|
|
284
|
+
// src/etc/get-loc.ts
|
|
285
|
+
|
|
219
286
|
function getLoc(node) {
|
|
220
287
|
const sourceFile = node.getSourceFile();
|
|
221
|
-
const start =
|
|
222
|
-
const end =
|
|
288
|
+
const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
289
|
+
const end = ts3.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
|
|
223
290
|
return {
|
|
224
291
|
start: {
|
|
225
292
|
line: start.line + 1,
|
|
@@ -232,76 +299,85 @@ function getLoc(node) {
|
|
|
232
299
|
};
|
|
233
300
|
}
|
|
234
301
|
|
|
302
|
+
// src/etc/get-type-services.ts
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
// src/etc/is.ts
|
|
308
|
+
|
|
235
309
|
function hasTypeAnnotation(node) {
|
|
236
310
|
return "typeAnnotation" in node && !!node.typeAnnotation;
|
|
237
311
|
}
|
|
238
312
|
function isArrayExpression(node) {
|
|
239
|
-
return node.type ===
|
|
313
|
+
return node.type === _utils.AST_NODE_TYPES.ArrayExpression;
|
|
240
314
|
}
|
|
241
315
|
function isArrayPattern(node) {
|
|
242
|
-
return node.type ===
|
|
316
|
+
return node.type === _utils.AST_NODE_TYPES.ArrayPattern;
|
|
243
317
|
}
|
|
244
318
|
function isArrowFunctionExpression(node) {
|
|
245
|
-
return node.type ===
|
|
319
|
+
return node.type === _utils.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
246
320
|
}
|
|
247
321
|
function isBlockStatement(node) {
|
|
248
|
-
return node.type ===
|
|
322
|
+
return node.type === _utils.AST_NODE_TYPES.BlockStatement;
|
|
249
323
|
}
|
|
250
324
|
function isCallExpression(node) {
|
|
251
|
-
return node.type ===
|
|
325
|
+
return node.type === _utils.AST_NODE_TYPES.CallExpression;
|
|
252
326
|
}
|
|
253
327
|
function isFunctionDeclaration(node) {
|
|
254
|
-
return node.type ===
|
|
328
|
+
return node.type === _utils.AST_NODE_TYPES.FunctionDeclaration;
|
|
255
329
|
}
|
|
256
330
|
function isFunctionExpression(node) {
|
|
257
|
-
return node.type ===
|
|
331
|
+
return node.type === _utils.AST_NODE_TYPES.FunctionExpression;
|
|
258
332
|
}
|
|
259
333
|
function isIdentifier(node) {
|
|
260
|
-
return node.type ===
|
|
334
|
+
return node.type === _utils.AST_NODE_TYPES.Identifier;
|
|
261
335
|
}
|
|
262
336
|
function isLiteral(node) {
|
|
263
|
-
return node.type ===
|
|
337
|
+
return node.type === _utils.AST_NODE_TYPES.Literal;
|
|
264
338
|
}
|
|
265
339
|
function isMemberExpression(node) {
|
|
266
|
-
return node.type ===
|
|
340
|
+
return node.type === _utils.AST_NODE_TYPES.MemberExpression;
|
|
267
341
|
}
|
|
268
342
|
function isObjectExpression(node) {
|
|
269
|
-
return node.type ===
|
|
343
|
+
return node.type === _utils.AST_NODE_TYPES.ObjectExpression;
|
|
270
344
|
}
|
|
271
345
|
function isObjectPattern(node) {
|
|
272
|
-
return node.type ===
|
|
346
|
+
return node.type === _utils.AST_NODE_TYPES.ObjectPattern;
|
|
273
347
|
}
|
|
274
348
|
function isProgram(node) {
|
|
275
|
-
return node.type ===
|
|
349
|
+
return node.type === _utils.AST_NODE_TYPES.Program;
|
|
276
350
|
}
|
|
277
351
|
function isProperty(node) {
|
|
278
|
-
return node.type ===
|
|
352
|
+
return node.type === _utils.AST_NODE_TYPES.Property;
|
|
279
353
|
}
|
|
280
354
|
|
|
355
|
+
// src/etc/get-type-services.ts
|
|
281
356
|
function getTypeServices(context) {
|
|
282
|
-
const services =
|
|
357
|
+
const services = _utils.ESLintUtils.getParserServices(context);
|
|
283
358
|
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = services;
|
|
284
359
|
const typeChecker = program.getTypeChecker();
|
|
285
|
-
const
|
|
360
|
+
const couldBeType2 = (node, name2, qualified) => {
|
|
286
361
|
const type = getType(node);
|
|
287
|
-
return
|
|
362
|
+
return couldBeType(
|
|
288
363
|
type,
|
|
289
|
-
|
|
364
|
+
name2,
|
|
290
365
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
291
366
|
);
|
|
292
367
|
};
|
|
293
|
-
const couldReturnType = (node,
|
|
368
|
+
const couldReturnType = (node, name2, qualified) => {
|
|
369
|
+
var _a;
|
|
294
370
|
let tsTypeNode;
|
|
295
371
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
296
|
-
if (
|
|
297
|
-
tsTypeNode = tsNode.type
|
|
298
|
-
} 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)) {
|
|
299
375
|
tsTypeNode = tsNode.type;
|
|
300
376
|
}
|
|
301
377
|
return Boolean(
|
|
302
|
-
tsTypeNode &&
|
|
378
|
+
tsTypeNode && couldBeType(
|
|
303
379
|
typeChecker.getTypeAtLocation(tsTypeNode),
|
|
304
|
-
|
|
380
|
+
name2,
|
|
305
381
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
306
382
|
)
|
|
307
383
|
);
|
|
@@ -310,45 +386,49 @@ function getTypeServices(context) {
|
|
|
310
386
|
return getTypeAtLocation(node);
|
|
311
387
|
};
|
|
312
388
|
return {
|
|
313
|
-
couldBeBehaviorSubject: (node) =>
|
|
314
|
-
couldBeError: (node) =>
|
|
389
|
+
couldBeBehaviorSubject: (node) => couldBeType2(node, "BehaviorSubject"),
|
|
390
|
+
couldBeError: (node) => couldBeType2(node, "Error"),
|
|
315
391
|
couldBeFunction: (node) => {
|
|
316
392
|
if (isArrowFunctionExpression(node) || isFunctionDeclaration(node)) {
|
|
317
393
|
return true;
|
|
318
394
|
}
|
|
319
|
-
return
|
|
395
|
+
return couldBeFunction(getType(node));
|
|
320
396
|
},
|
|
321
|
-
couldBeMonoTypeOperatorFunction: (node) =>
|
|
322
|
-
couldBeObservable: (node) =>
|
|
323
|
-
couldBeSubject: (node) =>
|
|
324
|
-
couldBeSubscription: (node) =>
|
|
325
|
-
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,
|
|
326
402
|
couldReturnObservable: (node) => couldReturnType(node, "Observable"),
|
|
327
403
|
couldReturnType,
|
|
328
404
|
getType,
|
|
329
|
-
isAny: (node) =>
|
|
330
|
-
isReferenceType: (node) =>
|
|
331
|
-
isUnknown: (node) =>
|
|
405
|
+
isAny: (node) => tsutils2.isIntrinsicAnyType(getType(node)),
|
|
406
|
+
isReferenceType: (node) => tsutils2.isTypeReference(getType(node)),
|
|
407
|
+
isUnknown: (node) => tsutils2.isIntrinsicUnknownType(getType(node)),
|
|
332
408
|
typeChecker
|
|
333
409
|
};
|
|
334
410
|
}
|
|
335
411
|
|
|
336
|
-
|
|
337
|
-
|
|
412
|
+
// src/etc/is-import.ts
|
|
413
|
+
var _scopemanager = require('@typescript-eslint/scope-manager');
|
|
414
|
+
|
|
415
|
+
function isImport(scope, name2, source) {
|
|
416
|
+
const variable = scope.variables.find((variable2) => variable2.name === name2);
|
|
338
417
|
if (variable) {
|
|
339
418
|
return variable.defs.some(
|
|
340
|
-
(def) => def.type ===
|
|
419
|
+
(def) => def.type === _scopemanager.DefinitionType.ImportBinding && def.parent.type === _utils.AST_NODE_TYPES.ImportDeclaration && (typeof source === "string" ? def.parent.source.value === source : source.test(def.parent.source.value))
|
|
341
420
|
);
|
|
342
421
|
}
|
|
343
|
-
return scope.upper ? isImport(scope.upper,
|
|
422
|
+
return scope.upper ? isImport(scope.upper, name2, source) : false;
|
|
344
423
|
}
|
|
345
424
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
425
|
+
// src/rules/finnish.ts
|
|
426
|
+
var defaultOptions3 = [];
|
|
427
|
+
var finnishRule = ruleCreator({
|
|
428
|
+
defaultOptions: defaultOptions3,
|
|
349
429
|
meta: {
|
|
350
430
|
docs: {
|
|
351
|
-
description: "
|
|
431
|
+
description: "Enforce Finnish notation.",
|
|
352
432
|
requiresTypeChecking: true
|
|
353
433
|
},
|
|
354
434
|
messages: {
|
|
@@ -358,14 +438,14 @@ const finnishRule = ruleCreator({
|
|
|
358
438
|
schema: [
|
|
359
439
|
{
|
|
360
440
|
properties: {
|
|
361
|
-
functions: { type: "boolean" },
|
|
362
|
-
methods: { type: "boolean" },
|
|
363
|
-
names: { type: "object" },
|
|
364
|
-
parameters: { type: "boolean" },
|
|
365
|
-
properties: { type: "boolean" },
|
|
366
|
-
strict: { type: "boolean" },
|
|
367
|
-
types: { type: "object" },
|
|
368
|
-
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." }
|
|
369
449
|
},
|
|
370
450
|
type: "object"
|
|
371
451
|
}
|
|
@@ -374,10 +454,10 @@ const finnishRule = ruleCreator({
|
|
|
374
454
|
},
|
|
375
455
|
name: "finnish",
|
|
376
456
|
create: (context) => {
|
|
377
|
-
const { esTreeNodeToTSNodeMap } =
|
|
457
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
378
458
|
const {
|
|
379
459
|
couldBeObservable,
|
|
380
|
-
couldBeType,
|
|
460
|
+
couldBeType: couldBeType2,
|
|
381
461
|
couldReturnObservable,
|
|
382
462
|
couldReturnType
|
|
383
463
|
} = getTypeServices(context);
|
|
@@ -439,8 +519,8 @@ const finnishRule = ruleCreator({
|
|
|
439
519
|
} : () => {
|
|
440
520
|
};
|
|
441
521
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
442
|
-
for (const
|
|
443
|
-
const { regExp, validate: validate2 } =
|
|
522
|
+
for (const name2 of names) {
|
|
523
|
+
const { regExp, validate: validate2 } = name2;
|
|
444
524
|
if (regExp.test(text) && !validate2) {
|
|
445
525
|
shouldNotBeFinnish();
|
|
446
526
|
return;
|
|
@@ -448,7 +528,7 @@ const finnishRule = ruleCreator({
|
|
|
448
528
|
}
|
|
449
529
|
for (const type of types) {
|
|
450
530
|
const { regExp, validate: validate2 } = type;
|
|
451
|
-
if ((
|
|
531
|
+
if ((couldBeType2(typeNode || nameNode, regExp) || couldReturnType(typeNode || nameNode, regExp)) && !validate2) {
|
|
452
532
|
shouldNotBeFinnish();
|
|
453
533
|
return;
|
|
454
534
|
}
|
|
@@ -470,7 +550,7 @@ const finnishRule = ruleCreator({
|
|
|
470
550
|
if (!found) {
|
|
471
551
|
return;
|
|
472
552
|
}
|
|
473
|
-
if (!validate.variables && found.type ===
|
|
553
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
474
554
|
return;
|
|
475
555
|
}
|
|
476
556
|
if (!validate.parameters) {
|
|
@@ -549,7 +629,7 @@ const finnishRule = ruleCreator({
|
|
|
549
629
|
if (!found) {
|
|
550
630
|
return;
|
|
551
631
|
}
|
|
552
|
-
if (!validate.variables && found.type ===
|
|
632
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
553
633
|
return;
|
|
554
634
|
}
|
|
555
635
|
if (!validate.parameters) {
|
|
@@ -600,11 +680,12 @@ const finnishRule = ruleCreator({
|
|
|
600
680
|
}
|
|
601
681
|
});
|
|
602
682
|
|
|
603
|
-
|
|
683
|
+
// src/rules/just.ts
|
|
684
|
+
var justRule = ruleCreator({
|
|
604
685
|
defaultOptions: [],
|
|
605
686
|
meta: {
|
|
606
687
|
docs: {
|
|
607
|
-
description: "
|
|
688
|
+
description: "Require the use of `just` instead of `of`."
|
|
608
689
|
},
|
|
609
690
|
fixable: "code",
|
|
610
691
|
messages: {
|
|
@@ -638,11 +719,12 @@ const justRule = ruleCreator({
|
|
|
638
719
|
}
|
|
639
720
|
});
|
|
640
721
|
|
|
641
|
-
|
|
722
|
+
// src/rules/macro.ts
|
|
723
|
+
var macroRule = ruleCreator({
|
|
642
724
|
defaultOptions: [],
|
|
643
725
|
meta: {
|
|
644
726
|
docs: {
|
|
645
|
-
description: "
|
|
727
|
+
description: "Require the use of the RxJS Tools Babel macro."
|
|
646
728
|
},
|
|
647
729
|
fixable: "code",
|
|
648
730
|
messages: {
|
|
@@ -697,11 +779,12 @@ const macroRule = ruleCreator({
|
|
|
697
779
|
}
|
|
698
780
|
});
|
|
699
781
|
|
|
700
|
-
|
|
782
|
+
// src/rules/no-async-subscribe.ts
|
|
783
|
+
var noAsyncSubscribeRule = ruleCreator({
|
|
701
784
|
defaultOptions: [],
|
|
702
785
|
meta: {
|
|
703
786
|
docs: {
|
|
704
|
-
description: "
|
|
787
|
+
description: "Disallow passing `async` functions to `subscribe`.",
|
|
705
788
|
recommended: true,
|
|
706
789
|
requiresTypeChecking: true
|
|
707
790
|
},
|
|
@@ -739,11 +822,12 @@ const noAsyncSubscribeRule = ruleCreator({
|
|
|
739
822
|
}
|
|
740
823
|
});
|
|
741
824
|
|
|
742
|
-
|
|
825
|
+
// src/rules/no-compat.ts
|
|
826
|
+
var noCompatRule = ruleCreator({
|
|
743
827
|
defaultOptions: [],
|
|
744
828
|
meta: {
|
|
745
829
|
docs: {
|
|
746
|
-
description: "
|
|
830
|
+
description: "Disallow the `rxjs-compat` package."
|
|
747
831
|
},
|
|
748
832
|
messages: {
|
|
749
833
|
forbidden: "'rxjs-compat'-dependent import locations are forbidden."
|
|
@@ -764,11 +848,12 @@ const noCompatRule = ruleCreator({
|
|
|
764
848
|
}
|
|
765
849
|
});
|
|
766
850
|
|
|
767
|
-
|
|
851
|
+
// src/rules/no-connectable.ts
|
|
852
|
+
var noConnectableRule = ruleCreator({
|
|
768
853
|
defaultOptions: [],
|
|
769
854
|
meta: {
|
|
770
855
|
docs: {
|
|
771
|
-
description: "
|
|
856
|
+
description: "Disallow operators that return connectable observables.",
|
|
772
857
|
requiresTypeChecking: true
|
|
773
858
|
},
|
|
774
859
|
messages: {
|
|
@@ -779,7 +864,7 @@ const noConnectableRule = ruleCreator({
|
|
|
779
864
|
},
|
|
780
865
|
name: "no-connectable",
|
|
781
866
|
create: (context) => {
|
|
782
|
-
const { couldBeFunction } = getTypeServices(context);
|
|
867
|
+
const { couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
783
868
|
return {
|
|
784
869
|
"CallExpression[callee.name='multicast']": (node) => {
|
|
785
870
|
if (node.arguments.length === 1) {
|
|
@@ -790,7 +875,7 @@ const noConnectableRule = ruleCreator({
|
|
|
790
875
|
}
|
|
791
876
|
},
|
|
792
877
|
"CallExpression[callee.name=/^(publish|publishBehavior|publishLast|publishReplay)$/]": (node) => {
|
|
793
|
-
if (!node.arguments.some((arg) =>
|
|
878
|
+
if (!node.arguments.some((arg) => couldBeFunction2(arg))) {
|
|
794
879
|
context.report({
|
|
795
880
|
messageId: "forbidden",
|
|
796
881
|
node: node.callee
|
|
@@ -801,11 +886,12 @@ const noConnectableRule = ruleCreator({
|
|
|
801
886
|
}
|
|
802
887
|
});
|
|
803
888
|
|
|
804
|
-
|
|
889
|
+
// src/rules/no-create.ts
|
|
890
|
+
var noCreateRule = ruleCreator({
|
|
805
891
|
defaultOptions: [],
|
|
806
892
|
meta: {
|
|
807
893
|
docs: {
|
|
808
|
-
description: "
|
|
894
|
+
description: "Disallow the static `Observable.create` function.",
|
|
809
895
|
recommended: true,
|
|
810
896
|
requiresTypeChecking: true
|
|
811
897
|
},
|
|
@@ -832,17 +918,23 @@ const noCreateRule = ruleCreator({
|
|
|
832
918
|
}
|
|
833
919
|
});
|
|
834
920
|
|
|
835
|
-
|
|
921
|
+
// src/rules/no-cyclic-action.ts
|
|
922
|
+
|
|
923
|
+
|
|
836
924
|
|
|
837
|
-
|
|
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) {
|
|
838
930
|
return Boolean(type.target);
|
|
839
931
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
defaultOptions:
|
|
932
|
+
var defaultOptions4 = [];
|
|
933
|
+
var noCyclicActionRule = ruleCreator({
|
|
934
|
+
defaultOptions: defaultOptions4,
|
|
843
935
|
meta: {
|
|
844
936
|
docs: {
|
|
845
|
-
description: "
|
|
937
|
+
description: "Disallow cyclic actions in effects and epics.",
|
|
846
938
|
requiresTypeChecking: true
|
|
847
939
|
},
|
|
848
940
|
messages: {
|
|
@@ -851,10 +943,10 @@ const noCyclicActionRule = ruleCreator({
|
|
|
851
943
|
schema: [
|
|
852
944
|
{
|
|
853
945
|
properties: {
|
|
854
|
-
observable: { type: "string" }
|
|
946
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
855
947
|
},
|
|
856
948
|
type: "object",
|
|
857
|
-
description:
|
|
949
|
+
description: _commontags.stripIndent`
|
|
858
950
|
An optional object with an optional \`observable\` property.
|
|
859
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.`
|
|
860
952
|
}
|
|
@@ -877,13 +969,13 @@ const noCyclicActionRule = ruleCreator({
|
|
|
877
969
|
const operatorType = getType(operatorCallExpression);
|
|
878
970
|
const [signature] = typeChecker.getSignaturesOfType(
|
|
879
971
|
operatorType,
|
|
880
|
-
|
|
972
|
+
ts5.SignatureKind.Call
|
|
881
973
|
);
|
|
882
974
|
if (!signature) {
|
|
883
975
|
return;
|
|
884
976
|
}
|
|
885
977
|
const operatorReturnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
886
|
-
if (!
|
|
978
|
+
if (!isTypeReference3(operatorReturnType)) {
|
|
887
979
|
return;
|
|
888
980
|
}
|
|
889
981
|
const [operatorElementType] = typeChecker.getTypeArguments(operatorReturnType);
|
|
@@ -891,7 +983,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
891
983
|
return;
|
|
892
984
|
}
|
|
893
985
|
const pipeType = getType(pipeCallExpression);
|
|
894
|
-
if (!
|
|
986
|
+
if (!isTypeReference3(pipeType)) {
|
|
895
987
|
return;
|
|
896
988
|
}
|
|
897
989
|
const [pipeElementType] = typeChecker.getTypeArguments(pipeType);
|
|
@@ -919,7 +1011,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
919
1011
|
return memberActionTypes;
|
|
920
1012
|
}
|
|
921
1013
|
const symbol = typeChecker.getPropertyOfType(type, "type");
|
|
922
|
-
if (!symbol
|
|
1014
|
+
if (!(symbol == null ? void 0 : symbol.valueDeclaration)) {
|
|
923
1015
|
return [];
|
|
924
1016
|
}
|
|
925
1017
|
const actionType = typeChecker.getTypeOfSymbolAtLocation(
|
|
@@ -935,11 +1027,12 @@ const noCyclicActionRule = ruleCreator({
|
|
|
935
1027
|
}
|
|
936
1028
|
});
|
|
937
1029
|
|
|
938
|
-
|
|
1030
|
+
// src/rules/no-explicit-generics.ts
|
|
1031
|
+
var noExplicitGenericsRule = ruleCreator({
|
|
939
1032
|
defaultOptions: [],
|
|
940
1033
|
meta: {
|
|
941
1034
|
docs: {
|
|
942
|
-
description: "
|
|
1035
|
+
description: "Disallow unnecessary explicit generic type arguments."
|
|
943
1036
|
},
|
|
944
1037
|
messages: {
|
|
945
1038
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -984,13 +1077,14 @@ const noExplicitGenericsRule = ruleCreator({
|
|
|
984
1077
|
}
|
|
985
1078
|
});
|
|
986
1079
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1080
|
+
// src/rules/no-exposed-subjects.ts
|
|
1081
|
+
var defaultAllowedTypesRegExp = /^EventEmitter$/;
|
|
1082
|
+
var defaultOptions5 = [];
|
|
1083
|
+
var noExposedSubjectsRule = ruleCreator({
|
|
1084
|
+
defaultOptions: defaultOptions5,
|
|
991
1085
|
meta: {
|
|
992
1086
|
docs: {
|
|
993
|
-
description: "
|
|
1087
|
+
description: "Disallow public and protected subjects.",
|
|
994
1088
|
requiresTypeChecking: true
|
|
995
1089
|
},
|
|
996
1090
|
messages: {
|
|
@@ -1000,7 +1094,7 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1000
1094
|
schema: [
|
|
1001
1095
|
{
|
|
1002
1096
|
properties: {
|
|
1003
|
-
allowProtected: { type: "boolean" }
|
|
1097
|
+
allowProtected: { type: "boolean", description: "Allow protected subjects.", default: false }
|
|
1004
1098
|
},
|
|
1005
1099
|
type: "object"
|
|
1006
1100
|
}
|
|
@@ -1011,11 +1105,11 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1011
1105
|
create: (context) => {
|
|
1012
1106
|
const [config = {}] = context.options;
|
|
1013
1107
|
const { allowProtected = false } = config;
|
|
1014
|
-
const { couldBeSubject, couldBeType } = getTypeServices(context);
|
|
1108
|
+
const { couldBeSubject, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1015
1109
|
const messageId = allowProtected ? "forbiddenAllowProtected" : "forbidden";
|
|
1016
1110
|
const accessibilityRexExp = allowProtected ? /^(private|protected)$/ : /^private$/;
|
|
1017
1111
|
function isSubject(node) {
|
|
1018
|
-
return couldBeSubject(node) && !
|
|
1112
|
+
return couldBeSubject(node) && !couldBeType2(node, defaultAllowedTypesRegExp);
|
|
1019
1113
|
}
|
|
1020
1114
|
return {
|
|
1021
1115
|
[`PropertyDefinition[accessibility!=${accessibilityRexExp}]`]: (node) => {
|
|
@@ -1087,11 +1181,13 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1087
1181
|
}
|
|
1088
1182
|
});
|
|
1089
1183
|
|
|
1090
|
-
|
|
1184
|
+
// src/rules/no-finnish.ts
|
|
1185
|
+
|
|
1186
|
+
var noFinnishRule = ruleCreator({
|
|
1091
1187
|
defaultOptions: [],
|
|
1092
1188
|
meta: {
|
|
1093
1189
|
docs: {
|
|
1094
|
-
description: "
|
|
1190
|
+
description: "Disallow Finnish notation.",
|
|
1095
1191
|
requiresTypeChecking: true
|
|
1096
1192
|
},
|
|
1097
1193
|
messages: {
|
|
@@ -1102,7 +1198,7 @@ const noFinnishRule = ruleCreator({
|
|
|
1102
1198
|
},
|
|
1103
1199
|
name: "no-finnish",
|
|
1104
1200
|
create: (context) => {
|
|
1105
|
-
const { esTreeNodeToTSNodeMap } =
|
|
1201
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
1106
1202
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
1107
1203
|
function checkNode(nameNode, typeNode) {
|
|
1108
1204
|
if (couldBeObservable(typeNode || nameNode) || couldReturnObservable(typeNode || nameNode)) {
|
|
@@ -1174,17 +1270,19 @@ const noFinnishRule = ruleCreator({
|
|
|
1174
1270
|
}
|
|
1175
1271
|
},
|
|
1176
1272
|
"VariableDeclarator[id.name=/[$]+$/]": (node) => {
|
|
1177
|
-
|
|
1273
|
+
var _a;
|
|
1274
|
+
checkNode(node.id, (_a = node.init) != null ? _a : node);
|
|
1178
1275
|
}
|
|
1179
1276
|
};
|
|
1180
1277
|
}
|
|
1181
1278
|
});
|
|
1182
1279
|
|
|
1183
|
-
|
|
1280
|
+
// src/rules/no-ignored-error.ts
|
|
1281
|
+
var noIgnoredErrorRule = ruleCreator({
|
|
1184
1282
|
defaultOptions: [],
|
|
1185
1283
|
meta: {
|
|
1186
1284
|
docs: {
|
|
1187
|
-
description: "
|
|
1285
|
+
description: "Disallow calling `subscribe` without specifying an error handler.",
|
|
1188
1286
|
requiresTypeChecking: true
|
|
1189
1287
|
},
|
|
1190
1288
|
messages: {
|
|
@@ -1195,12 +1293,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1195
1293
|
},
|
|
1196
1294
|
name: "no-ignored-error",
|
|
1197
1295
|
create: (context) => {
|
|
1198
|
-
const { couldBeObservable, couldBeFunction } = getTypeServices(context);
|
|
1296
|
+
const { couldBeObservable, couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
1199
1297
|
return {
|
|
1200
1298
|
"CallExpression[arguments.length > 0] > MemberExpression > Identifier[name='subscribe']": (node) => {
|
|
1201
1299
|
const memberExpression = node.parent;
|
|
1202
1300
|
const callExpression = memberExpression.parent;
|
|
1203
|
-
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) &&
|
|
1301
|
+
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) && couldBeFunction2(callExpression.arguments[0])) {
|
|
1204
1302
|
context.report({
|
|
1205
1303
|
messageId: "forbidden",
|
|
1206
1304
|
node
|
|
@@ -1211,11 +1309,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1211
1309
|
}
|
|
1212
1310
|
});
|
|
1213
1311
|
|
|
1214
|
-
|
|
1312
|
+
// src/rules/no-ignored-notifier.ts
|
|
1313
|
+
var noIgnoredNotifierRule = ruleCreator({
|
|
1215
1314
|
defaultOptions: [],
|
|
1216
1315
|
meta: {
|
|
1217
1316
|
docs: {
|
|
1218
|
-
description: "
|
|
1317
|
+
description: "Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.",
|
|
1219
1318
|
recommended: true,
|
|
1220
1319
|
requiresTypeChecking: true
|
|
1221
1320
|
},
|
|
@@ -1282,11 +1381,12 @@ const noIgnoredNotifierRule = ruleCreator({
|
|
|
1282
1381
|
}
|
|
1283
1382
|
});
|
|
1284
1383
|
|
|
1285
|
-
|
|
1384
|
+
// src/rules/no-ignored-observable.ts
|
|
1385
|
+
var noIgnoredObservableRule = ruleCreator({
|
|
1286
1386
|
defaultOptions: [],
|
|
1287
1387
|
meta: {
|
|
1288
1388
|
docs: {
|
|
1289
|
-
description: "
|
|
1389
|
+
description: "Disallow ignoring observables returned by functions.",
|
|
1290
1390
|
requiresTypeChecking: true
|
|
1291
1391
|
},
|
|
1292
1392
|
messages: {
|
|
@@ -1311,11 +1411,12 @@ const noIgnoredObservableRule = ruleCreator({
|
|
|
1311
1411
|
}
|
|
1312
1412
|
});
|
|
1313
1413
|
|
|
1314
|
-
|
|
1414
|
+
// src/rules/no-ignored-replay-buffer.ts
|
|
1415
|
+
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1315
1416
|
defaultOptions: [],
|
|
1316
1417
|
meta: {
|
|
1317
1418
|
docs: {
|
|
1318
|
-
description: "
|
|
1419
|
+
description: "Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.",
|
|
1319
1420
|
recommended: true
|
|
1320
1421
|
},
|
|
1321
1422
|
messages: {
|
|
@@ -1352,11 +1453,12 @@ const noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1352
1453
|
}
|
|
1353
1454
|
});
|
|
1354
1455
|
|
|
1355
|
-
|
|
1456
|
+
// src/rules/no-ignored-subscribe.ts
|
|
1457
|
+
var noIgnoredSubscribeRule = ruleCreator({
|
|
1356
1458
|
defaultOptions: [],
|
|
1357
1459
|
meta: {
|
|
1358
1460
|
docs: {
|
|
1359
|
-
description: "
|
|
1461
|
+
description: "Disallow calling `subscribe` without specifying arguments.",
|
|
1360
1462
|
requiresTypeChecking: true
|
|
1361
1463
|
},
|
|
1362
1464
|
messages: {
|
|
@@ -1367,11 +1469,11 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1367
1469
|
},
|
|
1368
1470
|
name: "no-ignored-subscribe",
|
|
1369
1471
|
create: (context) => {
|
|
1370
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1472
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1371
1473
|
return {
|
|
1372
1474
|
"CallExpression[arguments.length = 0][callee.property.name='subscribe']": (node) => {
|
|
1373
1475
|
const callee = node.callee;
|
|
1374
|
-
if (couldBeObservable(callee.object) ||
|
|
1476
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
1375
1477
|
context.report({
|
|
1376
1478
|
messageId: "forbidden",
|
|
1377
1479
|
node: callee.property
|
|
@@ -1382,11 +1484,12 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1382
1484
|
}
|
|
1383
1485
|
});
|
|
1384
1486
|
|
|
1385
|
-
|
|
1487
|
+
// src/rules/no-ignored-subscription.ts
|
|
1488
|
+
var noIgnoredSubscriptionRule = ruleCreator({
|
|
1386
1489
|
defaultOptions: [],
|
|
1387
1490
|
meta: {
|
|
1388
1491
|
docs: {
|
|
1389
|
-
description: "
|
|
1492
|
+
description: "Disallow ignoring the subscription returned by `subscribe`.",
|
|
1390
1493
|
requiresTypeChecking: true
|
|
1391
1494
|
},
|
|
1392
1495
|
messages: {
|
|
@@ -1397,12 +1500,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1397
1500
|
},
|
|
1398
1501
|
name: "no-ignored-subscription",
|
|
1399
1502
|
create: (context) => {
|
|
1400
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1503
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1401
1504
|
return {
|
|
1402
1505
|
"ExpressionStatement > CallExpression > MemberExpression[property.name='subscribe']": (node) => {
|
|
1403
1506
|
if (couldBeObservable(node.object)) {
|
|
1404
1507
|
const callExpression = node.parent;
|
|
1405
|
-
if (callExpression.arguments.length === 1 &&
|
|
1508
|
+
if (callExpression.arguments.length === 1 && couldBeType2(callExpression.arguments[0], "Subscriber")) {
|
|
1406
1509
|
return;
|
|
1407
1510
|
}
|
|
1408
1511
|
context.report({
|
|
@@ -1415,11 +1518,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1415
1518
|
}
|
|
1416
1519
|
});
|
|
1417
1520
|
|
|
1418
|
-
|
|
1521
|
+
// src/rules/no-ignored-takewhile-value.ts
|
|
1522
|
+
var noIgnoredTakewhileValueRule = ruleCreator({
|
|
1419
1523
|
defaultOptions: [],
|
|
1420
1524
|
meta: {
|
|
1421
1525
|
docs: {
|
|
1422
|
-
description: "
|
|
1526
|
+
description: "Disallow ignoring the value within `takeWhile`.",
|
|
1423
1527
|
recommended: true
|
|
1424
1528
|
},
|
|
1425
1529
|
messages: {
|
|
@@ -1440,7 +1544,7 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1440
1544
|
if (param) {
|
|
1441
1545
|
if (isIdentifier(param)) {
|
|
1442
1546
|
const variable = scope.variables.find(
|
|
1443
|
-
({ name }) =>
|
|
1547
|
+
({ name: name2 }) => name2 === param.name
|
|
1444
1548
|
);
|
|
1445
1549
|
if (variable && variable.references.length > 0) {
|
|
1446
1550
|
ignored = false;
|
|
@@ -1469,17 +1573,21 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1469
1573
|
}
|
|
1470
1574
|
});
|
|
1471
1575
|
|
|
1576
|
+
// src/rules/no-implicit-any-catch.ts
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1472
1580
|
function isParenthesised(sourceCode, node) {
|
|
1473
1581
|
const before = sourceCode.getTokenBefore(node);
|
|
1474
1582
|
const after = sourceCode.getTokenAfter(node);
|
|
1475
1583
|
return before && after && before.value === "(" && before.range[1] <= node.range[0] && after.value === ")" && after.range[0] >= node.range[1];
|
|
1476
1584
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
defaultOptions:
|
|
1585
|
+
var defaultOptions6 = [];
|
|
1586
|
+
var noImplicitAnyCatchRule = ruleCreator({
|
|
1587
|
+
defaultOptions: defaultOptions6,
|
|
1480
1588
|
meta: {
|
|
1481
1589
|
docs: {
|
|
1482
|
-
description: "
|
|
1590
|
+
description: "Disallow implicit `any` error parameters in `catchError` operators.",
|
|
1483
1591
|
recommended: true,
|
|
1484
1592
|
requiresTypeChecking: true
|
|
1485
1593
|
},
|
|
@@ -1496,7 +1604,9 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1496
1604
|
additionalProperties: false,
|
|
1497
1605
|
properties: {
|
|
1498
1606
|
allowExplicitAny: {
|
|
1499
|
-
type: "boolean"
|
|
1607
|
+
type: "boolean",
|
|
1608
|
+
description: "Allow error variable to be explicitly typed as `any`.",
|
|
1609
|
+
default: false
|
|
1500
1610
|
}
|
|
1501
1611
|
},
|
|
1502
1612
|
type: "object"
|
|
@@ -1521,41 +1631,43 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1521
1631
|
const {
|
|
1522
1632
|
typeAnnotation: { type }
|
|
1523
1633
|
} = typeAnnotation;
|
|
1524
|
-
if (type ===
|
|
1525
|
-
let
|
|
1634
|
+
if (type === _utils.AST_NODE_TYPES.TSAnyKeyword) {
|
|
1635
|
+
let fix2 = function(fixer) {
|
|
1526
1636
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1527
1637
|
};
|
|
1638
|
+
var fix = fix2;
|
|
1528
1639
|
if (allowExplicitAny) {
|
|
1529
1640
|
return;
|
|
1530
1641
|
}
|
|
1531
1642
|
context.report({
|
|
1532
|
-
fix,
|
|
1643
|
+
fix: fix2,
|
|
1533
1644
|
messageId: "explicitAny",
|
|
1534
1645
|
node: param,
|
|
1535
1646
|
suggest: [
|
|
1536
1647
|
{
|
|
1537
1648
|
messageId: "suggestExplicitUnknown",
|
|
1538
|
-
fix
|
|
1649
|
+
fix: fix2
|
|
1539
1650
|
}
|
|
1540
1651
|
]
|
|
1541
1652
|
});
|
|
1542
|
-
} else if (type !==
|
|
1543
|
-
let
|
|
1653
|
+
} else if (type !== _utils.AST_NODE_TYPES.TSUnknownKeyword) {
|
|
1654
|
+
let fix2 = function(fixer) {
|
|
1544
1655
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1545
1656
|
};
|
|
1657
|
+
var fix = fix2;
|
|
1546
1658
|
context.report({
|
|
1547
1659
|
messageId: "narrowed",
|
|
1548
1660
|
node: param,
|
|
1549
1661
|
suggest: [
|
|
1550
1662
|
{
|
|
1551
1663
|
messageId: "suggestExplicitUnknown",
|
|
1552
|
-
fix
|
|
1664
|
+
fix: fix2
|
|
1553
1665
|
}
|
|
1554
1666
|
]
|
|
1555
1667
|
});
|
|
1556
1668
|
}
|
|
1557
1669
|
} else {
|
|
1558
|
-
let
|
|
1670
|
+
let fix2 = function(fixer) {
|
|
1559
1671
|
if (isParenthesised(sourceCode, param)) {
|
|
1560
1672
|
return fixer.insertTextAfter(param, ": unknown");
|
|
1561
1673
|
}
|
|
@@ -1564,14 +1676,15 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1564
1676
|
fixer.insertTextAfter(param, ": unknown)")
|
|
1565
1677
|
];
|
|
1566
1678
|
};
|
|
1679
|
+
var fix = fix2;
|
|
1567
1680
|
context.report({
|
|
1568
|
-
fix,
|
|
1681
|
+
fix: fix2,
|
|
1569
1682
|
messageId: "implicitAny",
|
|
1570
1683
|
node: param,
|
|
1571
1684
|
suggest: [
|
|
1572
1685
|
{
|
|
1573
1686
|
messageId: "suggestExplicitUnknown",
|
|
1574
|
-
fix
|
|
1687
|
+
fix: fix2
|
|
1575
1688
|
}
|
|
1576
1689
|
]
|
|
1577
1690
|
});
|
|
@@ -1607,11 +1720,12 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1607
1720
|
}
|
|
1608
1721
|
});
|
|
1609
1722
|
|
|
1610
|
-
|
|
1723
|
+
// src/rules/no-index.ts
|
|
1724
|
+
var noIndexRule = ruleCreator({
|
|
1611
1725
|
defaultOptions: [],
|
|
1612
1726
|
meta: {
|
|
1613
1727
|
docs: {
|
|
1614
|
-
description: "
|
|
1728
|
+
description: "Disallow importing index modules.",
|
|
1615
1729
|
recommended: true
|
|
1616
1730
|
},
|
|
1617
1731
|
messages: {
|
|
@@ -1633,11 +1747,12 @@ const noIndexRule = ruleCreator({
|
|
|
1633
1747
|
}
|
|
1634
1748
|
});
|
|
1635
1749
|
|
|
1636
|
-
|
|
1750
|
+
// src/rules/no-internal.ts
|
|
1751
|
+
var noInternalRule = ruleCreator({
|
|
1637
1752
|
defaultOptions: [],
|
|
1638
1753
|
meta: {
|
|
1639
1754
|
docs: {
|
|
1640
|
-
description: "
|
|
1755
|
+
description: "Disallow importing internal modules.",
|
|
1641
1756
|
recommended: true
|
|
1642
1757
|
},
|
|
1643
1758
|
fixable: "code",
|
|
@@ -1687,14 +1802,15 @@ const noInternalRule = ruleCreator({
|
|
|
1687
1802
|
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002finternal/]`]: (node) => {
|
|
1688
1803
|
const replacement = getReplacement(node.raw);
|
|
1689
1804
|
if (replacement) {
|
|
1690
|
-
let
|
|
1805
|
+
let fix2 = function(fixer) {
|
|
1691
1806
|
return fixer.replaceText(node, replacement);
|
|
1692
1807
|
};
|
|
1808
|
+
var fix = fix2;
|
|
1693
1809
|
context.report({
|
|
1694
|
-
fix,
|
|
1810
|
+
fix: fix2,
|
|
1695
1811
|
messageId: "forbidden",
|
|
1696
1812
|
node,
|
|
1697
|
-
suggest: [{ fix, messageId: "suggest" }]
|
|
1813
|
+
suggest: [{ fix: fix2, messageId: "suggest" }]
|
|
1698
1814
|
});
|
|
1699
1815
|
} else {
|
|
1700
1816
|
context.report({
|
|
@@ -1707,11 +1823,12 @@ const noInternalRule = ruleCreator({
|
|
|
1707
1823
|
}
|
|
1708
1824
|
});
|
|
1709
1825
|
|
|
1710
|
-
|
|
1826
|
+
// src/rules/no-nested-subscribe.ts
|
|
1827
|
+
var noNestedSubscribeRule = ruleCreator({
|
|
1711
1828
|
defaultOptions: [],
|
|
1712
1829
|
meta: {
|
|
1713
1830
|
docs: {
|
|
1714
|
-
description: "
|
|
1831
|
+
description: "Disallow calling `subscribe` within a `subscribe` callback.",
|
|
1715
1832
|
recommended: true,
|
|
1716
1833
|
requiresTypeChecking: true
|
|
1717
1834
|
},
|
|
@@ -1723,11 +1840,11 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1723
1840
|
},
|
|
1724
1841
|
name: "no-nested-subscribe",
|
|
1725
1842
|
create: (context) => {
|
|
1726
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1843
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1727
1844
|
const argumentsMap = /* @__PURE__ */ new WeakMap();
|
|
1728
1845
|
return {
|
|
1729
1846
|
[`CallExpression > MemberExpression[property.name='subscribe']`]: (node) => {
|
|
1730
|
-
if (!couldBeObservable(node.object) && !
|
|
1847
|
+
if (!couldBeObservable(node.object) && !couldBeType2(node.object, "Subscribable")) {
|
|
1731
1848
|
return;
|
|
1732
1849
|
}
|
|
1733
1850
|
const callExpression = node.parent;
|
|
@@ -1750,11 +1867,12 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1750
1867
|
}
|
|
1751
1868
|
});
|
|
1752
1869
|
|
|
1753
|
-
|
|
1870
|
+
// src/rules/no-redundant-notify.ts
|
|
1871
|
+
var noRedundantNotifyRule = ruleCreator({
|
|
1754
1872
|
defaultOptions: [],
|
|
1755
1873
|
meta: {
|
|
1756
1874
|
docs: {
|
|
1757
|
-
description: "
|
|
1875
|
+
description: "Disallow sending redundant notifications from completed or errored observables.",
|
|
1758
1876
|
recommended: true,
|
|
1759
1877
|
requiresTypeChecking: true
|
|
1760
1878
|
},
|
|
@@ -1767,7 +1885,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1767
1885
|
name: "no-redundant-notify",
|
|
1768
1886
|
create: (context) => {
|
|
1769
1887
|
const sourceCode = context.sourceCode;
|
|
1770
|
-
const { couldBeType } = getTypeServices(context);
|
|
1888
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1771
1889
|
return {
|
|
1772
1890
|
"ExpressionStatement[expression.callee.property.name=/^(complete|error)$/] + ExpressionStatement[expression.callee.property.name=/^(next|complete|error)$/]": (node) => {
|
|
1773
1891
|
const parent = node.parent;
|
|
@@ -1783,7 +1901,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1783
1901
|
if (getExpressionText(sibling, sourceCode) !== getExpressionText(node, sourceCode)) {
|
|
1784
1902
|
return;
|
|
1785
1903
|
}
|
|
1786
|
-
if (!isExpressionObserver(sibling,
|
|
1904
|
+
if (!isExpressionObserver(sibling, couldBeType2) || !isExpressionObserver(node, couldBeType2)) {
|
|
1787
1905
|
return;
|
|
1788
1906
|
}
|
|
1789
1907
|
const { expression } = node;
|
|
@@ -1814,7 +1932,7 @@ function getExpressionText(expressionStatement, sourceCode) {
|
|
|
1814
1932
|
const { object } = callExpression.callee;
|
|
1815
1933
|
return sourceCode.getText(object);
|
|
1816
1934
|
}
|
|
1817
|
-
function isExpressionObserver(expressionStatement,
|
|
1935
|
+
function isExpressionObserver(expressionStatement, couldBeType2) {
|
|
1818
1936
|
if (!isCallExpression(expressionStatement.expression)) {
|
|
1819
1937
|
return false;
|
|
1820
1938
|
}
|
|
@@ -1823,15 +1941,17 @@ function isExpressionObserver(expressionStatement, couldBeType) {
|
|
|
1823
1941
|
return false;
|
|
1824
1942
|
}
|
|
1825
1943
|
const { object } = callExpression.callee;
|
|
1826
|
-
return
|
|
1944
|
+
return couldBeType2(object, /^(Subject|Subscriber)$/);
|
|
1827
1945
|
}
|
|
1828
1946
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1947
|
+
// src/rules/no-sharereplay.ts
|
|
1948
|
+
|
|
1949
|
+
var defaultOptions7 = [];
|
|
1950
|
+
var noSharereplayRule = ruleCreator({
|
|
1951
|
+
defaultOptions: defaultOptions7,
|
|
1832
1952
|
meta: {
|
|
1833
1953
|
docs: {
|
|
1834
|
-
description: "
|
|
1954
|
+
description: "Disallow unsafe `shareReplay` usage.",
|
|
1835
1955
|
recommended: true
|
|
1836
1956
|
},
|
|
1837
1957
|
messages: {
|
|
@@ -1841,7 +1961,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1841
1961
|
schema: [
|
|
1842
1962
|
{
|
|
1843
1963
|
properties: {
|
|
1844
|
-
allowConfig: { type: "boolean" }
|
|
1964
|
+
allowConfig: { type: "boolean", description: "Allow shareReplay if a config argument is specified.", default: true }
|
|
1845
1965
|
},
|
|
1846
1966
|
type: "object"
|
|
1847
1967
|
}
|
|
@@ -1856,7 +1976,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1856
1976
|
"CallExpression[callee.name='shareReplay']": (node) => {
|
|
1857
1977
|
let report = true;
|
|
1858
1978
|
if (allowConfig) {
|
|
1859
|
-
report = node.arguments.length !== 1 || node.arguments[0].type !==
|
|
1979
|
+
report = node.arguments.length !== 1 || node.arguments[0].type !== _utils.AST_NODE_TYPES.ObjectExpression;
|
|
1860
1980
|
}
|
|
1861
1981
|
if (report) {
|
|
1862
1982
|
context.report({
|
|
@@ -1869,11 +1989,12 @@ const noSharereplayRule = ruleCreator({
|
|
|
1869
1989
|
}
|
|
1870
1990
|
});
|
|
1871
1991
|
|
|
1872
|
-
|
|
1992
|
+
// src/rules/no-subclass.ts
|
|
1993
|
+
var noSubclassRule = ruleCreator({
|
|
1873
1994
|
defaultOptions: [],
|
|
1874
1995
|
meta: {
|
|
1875
1996
|
docs: {
|
|
1876
|
-
description: "
|
|
1997
|
+
description: "Disallow subclassing RxJS classes.",
|
|
1877
1998
|
requiresTypeChecking: true
|
|
1878
1999
|
},
|
|
1879
2000
|
messages: {
|
|
@@ -1884,7 +2005,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1884
2005
|
},
|
|
1885
2006
|
name: "no-subclass",
|
|
1886
2007
|
create: (context) => {
|
|
1887
|
-
const { couldBeType } = getTypeServices(context);
|
|
2008
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1888
2009
|
const queryNames = [
|
|
1889
2010
|
"AsyncSubject",
|
|
1890
2011
|
"BehaviorSubject",
|
|
@@ -1899,7 +2020,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1899
2020
|
"|"
|
|
1900
2021
|
)})$/] > Identifier.superClass`]: (node) => {
|
|
1901
2022
|
if (queryNames.some(
|
|
1902
|
-
(
|
|
2023
|
+
(name2) => couldBeType2(node, name2, { name: /[/\\]rxjs[/\\]/ })
|
|
1903
2024
|
)) {
|
|
1904
2025
|
context.report({
|
|
1905
2026
|
messageId: "forbidden",
|
|
@@ -1911,11 +2032,12 @@ const noSubclassRule = ruleCreator({
|
|
|
1911
2032
|
}
|
|
1912
2033
|
});
|
|
1913
2034
|
|
|
1914
|
-
|
|
2035
|
+
// src/rules/no-subject-unsubscribe.ts
|
|
2036
|
+
var noSubjectUnsubscribeRule = ruleCreator({
|
|
1915
2037
|
defaultOptions: [],
|
|
1916
2038
|
meta: {
|
|
1917
2039
|
docs: {
|
|
1918
|
-
description: "
|
|
2040
|
+
description: "Disallow calling the `unsubscribe` method of subjects.",
|
|
1919
2041
|
recommended: true,
|
|
1920
2042
|
requiresTypeChecking: true
|
|
1921
2043
|
},
|
|
@@ -1953,11 +2075,12 @@ const noSubjectUnsubscribeRule = ruleCreator({
|
|
|
1953
2075
|
}
|
|
1954
2076
|
});
|
|
1955
2077
|
|
|
1956
|
-
|
|
2078
|
+
// src/rules/no-subject-value.ts
|
|
2079
|
+
var noSubjectValueRule = ruleCreator({
|
|
1957
2080
|
defaultOptions: [],
|
|
1958
2081
|
meta: {
|
|
1959
2082
|
docs: {
|
|
1960
|
-
description: "
|
|
2083
|
+
description: "Disallow accessing the `value` property of a `BehaviorSubject` instance.",
|
|
1961
2084
|
requiresTypeChecking: true
|
|
1962
2085
|
},
|
|
1963
2086
|
messages: {
|
|
@@ -1986,11 +2109,12 @@ const noSubjectValueRule = ruleCreator({
|
|
|
1986
2109
|
}
|
|
1987
2110
|
});
|
|
1988
2111
|
|
|
1989
|
-
|
|
2112
|
+
// src/rules/no-subscribe-handlers.ts
|
|
2113
|
+
var noSubscribeHandlersRule = ruleCreator({
|
|
1990
2114
|
defaultOptions: [],
|
|
1991
2115
|
meta: {
|
|
1992
2116
|
docs: {
|
|
1993
|
-
description: "
|
|
2117
|
+
description: "Disallow passing handlers to `subscribe`.",
|
|
1994
2118
|
requiresTypeChecking: true
|
|
1995
2119
|
},
|
|
1996
2120
|
messages: {
|
|
@@ -2001,11 +2125,11 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2001
2125
|
},
|
|
2002
2126
|
name: "no-subscribe-handlers",
|
|
2003
2127
|
create: (context) => {
|
|
2004
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
2128
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2005
2129
|
return {
|
|
2006
2130
|
"CallExpression[arguments.length > 0][callee.property.name='subscribe']": (node) => {
|
|
2007
2131
|
const callee = node.callee;
|
|
2008
|
-
if (couldBeObservable(callee.object) ||
|
|
2132
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
2009
2133
|
context.report({
|
|
2010
2134
|
messageId: "forbidden",
|
|
2011
2135
|
node: callee.property
|
|
@@ -2016,12 +2140,13 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2016
2140
|
}
|
|
2017
2141
|
});
|
|
2018
2142
|
|
|
2019
|
-
|
|
2143
|
+
// src/rules/no-tap.ts
|
|
2144
|
+
var noTapRule = ruleCreator({
|
|
2020
2145
|
defaultOptions: [],
|
|
2021
2146
|
meta: {
|
|
2022
2147
|
deprecated: true,
|
|
2023
2148
|
docs: {
|
|
2024
|
-
description: "
|
|
2149
|
+
description: "Disallow the `tap` operator."
|
|
2025
2150
|
},
|
|
2026
2151
|
messages: {
|
|
2027
2152
|
forbidden: "The tap operator is forbidden."
|
|
@@ -2050,11 +2175,12 @@ const noTapRule = ruleCreator({
|
|
|
2050
2175
|
}
|
|
2051
2176
|
});
|
|
2052
2177
|
|
|
2053
|
-
|
|
2178
|
+
// src/rules/no-topromise.ts
|
|
2179
|
+
var noTopromiseRule = ruleCreator({
|
|
2054
2180
|
defaultOptions: [],
|
|
2055
2181
|
meta: {
|
|
2056
2182
|
docs: {
|
|
2057
|
-
description: "
|
|
2183
|
+
description: "Disallow use of the `toPromise` method.",
|
|
2058
2184
|
requiresTypeChecking: true
|
|
2059
2185
|
},
|
|
2060
2186
|
messages: {
|
|
@@ -2079,11 +2205,12 @@ const noTopromiseRule = ruleCreator({
|
|
|
2079
2205
|
}
|
|
2080
2206
|
});
|
|
2081
2207
|
|
|
2082
|
-
|
|
2208
|
+
// src/rules/no-unbound-methods.ts
|
|
2209
|
+
var noUnboundMethodsRule = ruleCreator({
|
|
2083
2210
|
defaultOptions: [],
|
|
2084
2211
|
meta: {
|
|
2085
2212
|
docs: {
|
|
2086
|
-
description: "
|
|
2213
|
+
description: "Disallow passing unbound methods.",
|
|
2087
2214
|
recommended: true,
|
|
2088
2215
|
requiresTypeChecking: true
|
|
2089
2216
|
},
|
|
@@ -2140,12 +2267,14 @@ const noUnboundMethodsRule = ruleCreator({
|
|
|
2140
2267
|
}
|
|
2141
2268
|
});
|
|
2142
2269
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2270
|
+
// src/rules/no-unsafe-catch.ts
|
|
2271
|
+
|
|
2272
|
+
var defaultOptions8 = [];
|
|
2273
|
+
var noUnsafeCatchRule = ruleCreator({
|
|
2274
|
+
defaultOptions: defaultOptions8,
|
|
2146
2275
|
meta: {
|
|
2147
2276
|
docs: {
|
|
2148
|
-
description: "
|
|
2277
|
+
description: "Disallow unsafe `catchError` usage in effects and epics.",
|
|
2149
2278
|
requiresTypeChecking: true
|
|
2150
2279
|
},
|
|
2151
2280
|
messages: {
|
|
@@ -2154,10 +2283,10 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2154
2283
|
schema: [
|
|
2155
2284
|
{
|
|
2156
2285
|
properties: {
|
|
2157
|
-
observable: { type: "string" }
|
|
2286
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2158
2287
|
},
|
|
2159
2288
|
type: "object",
|
|
2160
|
-
description:
|
|
2289
|
+
description: _commontags.stripIndent`
|
|
2161
2290
|
An optional object with an optional \`observable\` property.
|
|
2162
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.`
|
|
2163
2292
|
}
|
|
@@ -2199,12 +2328,14 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2199
2328
|
}
|
|
2200
2329
|
});
|
|
2201
2330
|
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2331
|
+
// src/rules/no-unsafe-first.ts
|
|
2332
|
+
|
|
2333
|
+
var defaultOptions9 = [];
|
|
2334
|
+
var noUnsafeFirstRule = ruleCreator({
|
|
2335
|
+
defaultOptions: defaultOptions9,
|
|
2205
2336
|
meta: {
|
|
2206
2337
|
docs: {
|
|
2207
|
-
description: "
|
|
2338
|
+
description: "Disallow unsafe `first`/`take` usage in effects and epics.",
|
|
2208
2339
|
requiresTypeChecking: true
|
|
2209
2340
|
},
|
|
2210
2341
|
messages: {
|
|
@@ -2213,10 +2344,10 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2213
2344
|
schema: [
|
|
2214
2345
|
{
|
|
2215
2346
|
properties: {
|
|
2216
|
-
observable: { type: "string" }
|
|
2347
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2217
2348
|
},
|
|
2218
2349
|
type: "object",
|
|
2219
|
-
description:
|
|
2350
|
+
description: _commontags.stripIndent`
|
|
2220
2351
|
An optional object with an optional \`observable\` property.
|
|
2221
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.`
|
|
2222
2353
|
}
|
|
@@ -2267,11 +2398,14 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2267
2398
|
}
|
|
2268
2399
|
});
|
|
2269
2400
|
|
|
2270
|
-
|
|
2401
|
+
// src/rules/no-unsafe-subject-next.ts
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
var noUnsafeSubjectNext = ruleCreator({
|
|
2271
2405
|
defaultOptions: [],
|
|
2272
2406
|
meta: {
|
|
2273
2407
|
docs: {
|
|
2274
|
-
description: "
|
|
2408
|
+
description: "Disallow unsafe optional `next` calls.",
|
|
2275
2409
|
recommended: true,
|
|
2276
2410
|
requiresTypeChecking: true
|
|
2277
2411
|
},
|
|
@@ -2288,19 +2422,19 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2288
2422
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
2289
2423
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
2290
2424
|
const type = getType(node.callee.object);
|
|
2291
|
-
if (
|
|
2425
|
+
if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
2292
2426
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
2293
|
-
if (
|
|
2427
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
|
|
2294
2428
|
return;
|
|
2295
2429
|
}
|
|
2296
|
-
if (
|
|
2430
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
|
|
2297
2431
|
return;
|
|
2298
2432
|
}
|
|
2299
|
-
if (
|
|
2433
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
|
|
2300
2434
|
return;
|
|
2301
2435
|
}
|
|
2302
|
-
if (
|
|
2303
|
-
(t) =>
|
|
2436
|
+
if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
|
|
2437
|
+
(t) => tsutils3.isTypeFlagSet(t, ts6.TypeFlags.Void)
|
|
2304
2438
|
)) {
|
|
2305
2439
|
return;
|
|
2306
2440
|
}
|
|
@@ -2315,12 +2449,15 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2315
2449
|
}
|
|
2316
2450
|
});
|
|
2317
2451
|
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2452
|
+
// src/rules/no-unsafe-switchmap.ts
|
|
2453
|
+
|
|
2454
|
+
var _decamelize = require('decamelize'); var _decamelize2 = _interopRequireDefault(_decamelize);
|
|
2455
|
+
var defaultOptions10 = [];
|
|
2456
|
+
var noUnsafeSwitchmapRule = ruleCreator({
|
|
2457
|
+
defaultOptions: defaultOptions10,
|
|
2321
2458
|
meta: {
|
|
2322
2459
|
docs: {
|
|
2323
|
-
description: "
|
|
2460
|
+
description: "Disallow unsafe `switchMap` usage in effects and epics.",
|
|
2324
2461
|
requiresTypeChecking: true
|
|
2325
2462
|
},
|
|
2326
2463
|
messages: {
|
|
@@ -2330,26 +2467,27 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2330
2467
|
{
|
|
2331
2468
|
properties: {
|
|
2332
2469
|
allow: {
|
|
2470
|
+
description: "Action types that are allowed to be used with switchMap. Mutually exclusive with `disallow`.",
|
|
2333
2471
|
oneOf: [
|
|
2334
|
-
{ type: "string" },
|
|
2335
|
-
{ type: "array", items: { type: "string" } }
|
|
2472
|
+
{ type: "string", description: "A regular expression string." },
|
|
2473
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2336
2474
|
]
|
|
2337
2475
|
},
|
|
2338
2476
|
disallow: {
|
|
2477
|
+
description: "Action types that are disallowed to be used with switchMap. Mutually exclusive with `allow`.",
|
|
2339
2478
|
oneOf: [
|
|
2340
|
-
{ type: "string" },
|
|
2341
|
-
{ type: "array", items: { type: "string" } }
|
|
2479
|
+
{ type: "string", description: "A regular expression string." },
|
|
2480
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2342
2481
|
]
|
|
2343
2482
|
},
|
|
2344
2483
|
observable: {
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
]
|
|
2484
|
+
type: "string",
|
|
2485
|
+
description: "A RegExp that matches an effect or epic's actions observable.",
|
|
2486
|
+
default: defaultObservable
|
|
2349
2487
|
}
|
|
2350
2488
|
},
|
|
2351
2489
|
type: "object",
|
|
2352
|
-
description:
|
|
2490
|
+
description: _commontags.stripIndent`
|
|
2353
2491
|
An optional object with optional \`allow\`, \`disallow\` and \`observable\` properties.
|
|
2354
2492
|
The properties can be specified as regular expression strings or as arrays of words.
|
|
2355
2493
|
The \`allow\` or \`disallow\` properties are mutually exclusive. Whether or not
|
|
@@ -2362,6 +2500,7 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2362
2500
|
},
|
|
2363
2501
|
name: "no-unsafe-switchmap",
|
|
2364
2502
|
create: (context) => {
|
|
2503
|
+
var _a, _b, _c;
|
|
2365
2504
|
const defaultDisallow = [
|
|
2366
2505
|
"add",
|
|
2367
2506
|
"create",
|
|
@@ -2377,9 +2516,9 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2377
2516
|
let observableRegExp;
|
|
2378
2517
|
const [config = {}] = context.options;
|
|
2379
2518
|
if (config.allow || config.disallow) {
|
|
2380
|
-
allowRegExp = createRegExpForWords(config.allow
|
|
2381
|
-
disallowRegExp = createRegExpForWords(config.disallow
|
|
2382
|
-
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);
|
|
2383
2522
|
} else {
|
|
2384
2523
|
allowRegExp = void 0;
|
|
2385
2524
|
disallowRegExp = createRegExpForWords(defaultDisallow);
|
|
@@ -2398,12 +2537,12 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2398
2537
|
return arg.property.name;
|
|
2399
2538
|
}
|
|
2400
2539
|
return "";
|
|
2401
|
-
}).map((
|
|
2540
|
+
}).map((name2) => _decamelize2.default.call(void 0, name2));
|
|
2402
2541
|
if (allowRegExp) {
|
|
2403
|
-
return !names.every((
|
|
2542
|
+
return !names.every((name2) => allowRegExp == null ? void 0 : allowRegExp.test(name2));
|
|
2404
2543
|
}
|
|
2405
2544
|
if (disallowRegExp) {
|
|
2406
|
-
return names.some((
|
|
2545
|
+
return names.some((name2) => disallowRegExp == null ? void 0 : disallowRegExp.test(name2));
|
|
2407
2546
|
}
|
|
2408
2547
|
return false;
|
|
2409
2548
|
}
|
|
@@ -2436,12 +2575,37 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2436
2575
|
}
|
|
2437
2576
|
});
|
|
2438
2577
|
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2578
|
+
// src/rules/no-unsafe-takeuntil.ts
|
|
2579
|
+
|
|
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,
|
|
2442
2606
|
meta: {
|
|
2443
2607
|
docs: {
|
|
2444
|
-
description: "
|
|
2608
|
+
description: "Disallow applying operators after `takeUntil`.",
|
|
2445
2609
|
recommended: true,
|
|
2446
2610
|
requiresTypeChecking: true
|
|
2447
2611
|
},
|
|
@@ -2451,11 +2615,11 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2451
2615
|
schema: [
|
|
2452
2616
|
{
|
|
2453
2617
|
properties: {
|
|
2454
|
-
alias: { type: "array", items: { type: "string" } },
|
|
2455
|
-
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 }
|
|
2456
2620
|
},
|
|
2457
2621
|
type: "object",
|
|
2458
|
-
description:
|
|
2622
|
+
description: _commontags.stripIndent`
|
|
2459
2623
|
An optional object with optional \`alias\` and \`allow\` properties.
|
|
2460
2624
|
The \`alias\` property is an array containing the names of operators that aliases for \`takeUntil\`.
|
|
2461
2625
|
The \`allow\` property is an array containing the names of the operators that are allowed to follow \`takeUntil\`.`
|
|
@@ -2466,29 +2630,6 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2466
2630
|
name: "no-unsafe-takeuntil",
|
|
2467
2631
|
create: (context) => {
|
|
2468
2632
|
let checkedOperatorsRegExp = /^takeUntil$/;
|
|
2469
|
-
const allowedOperators = [
|
|
2470
|
-
"count",
|
|
2471
|
-
"defaultIfEmpty",
|
|
2472
|
-
"endWith",
|
|
2473
|
-
"every",
|
|
2474
|
-
"finalize",
|
|
2475
|
-
"finally",
|
|
2476
|
-
"isEmpty",
|
|
2477
|
-
"last",
|
|
2478
|
-
"max",
|
|
2479
|
-
"min",
|
|
2480
|
-
"publish",
|
|
2481
|
-
"publishBehavior",
|
|
2482
|
-
"publishLast",
|
|
2483
|
-
"publishReplay",
|
|
2484
|
-
"reduce",
|
|
2485
|
-
"share",
|
|
2486
|
-
"shareReplay",
|
|
2487
|
-
"skipLast",
|
|
2488
|
-
"takeLast",
|
|
2489
|
-
"throwIfEmpty",
|
|
2490
|
-
"toArray"
|
|
2491
|
-
];
|
|
2492
2633
|
const [config = {}] = context.options;
|
|
2493
2634
|
const { alias, allow = allowedOperators } = config;
|
|
2494
2635
|
if (alias) {
|
|
@@ -2539,12 +2680,13 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2539
2680
|
}
|
|
2540
2681
|
});
|
|
2541
2682
|
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2683
|
+
// src/rules/prefer-observer.ts
|
|
2684
|
+
var defaultOptions12 = [];
|
|
2685
|
+
var preferObserverRule = ruleCreator({
|
|
2686
|
+
defaultOptions: defaultOptions12,
|
|
2545
2687
|
meta: {
|
|
2546
2688
|
docs: {
|
|
2547
|
-
description: "
|
|
2689
|
+
description: "Disallow passing separate handlers to `subscribe` and `tap`.",
|
|
2548
2690
|
requiresTypeChecking: true
|
|
2549
2691
|
},
|
|
2550
2692
|
fixable: "code",
|
|
@@ -2555,7 +2697,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2555
2697
|
schema: [
|
|
2556
2698
|
{
|
|
2557
2699
|
properties: {
|
|
2558
|
-
allowNext: { type: "boolean" }
|
|
2700
|
+
allowNext: { type: "boolean", description: "Allows a single `next` callback.", default: true }
|
|
2559
2701
|
},
|
|
2560
2702
|
type: "object"
|
|
2561
2703
|
}
|
|
@@ -2564,7 +2706,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2564
2706
|
},
|
|
2565
2707
|
name: "prefer-observer",
|
|
2566
2708
|
create: (context) => {
|
|
2567
|
-
const { couldBeFunction, couldBeObservable } = getTypeServices(context);
|
|
2709
|
+
const { couldBeFunction: couldBeFunction2, couldBeObservable } = getTypeServices(context);
|
|
2568
2710
|
const [config = {}] = context.options;
|
|
2569
2711
|
const { allowNext = true } = config;
|
|
2570
2712
|
function checkArgs(callExpression, reportNode) {
|
|
@@ -2608,7 +2750,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2608
2750
|
});
|
|
2609
2751
|
} else if (args.length === 1 && !allowNext) {
|
|
2610
2752
|
const [arg] = args;
|
|
2611
|
-
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) ||
|
|
2753
|
+
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) || couldBeFunction2(arg)) {
|
|
2612
2754
|
context.report({
|
|
2613
2755
|
messageId: "forbidden",
|
|
2614
2756
|
node: reportNode,
|
|
@@ -2637,12 +2779,14 @@ function isValidArgText(argText) {
|
|
|
2637
2779
|
return argText && argText !== "undefined" && argText !== "null";
|
|
2638
2780
|
}
|
|
2639
2781
|
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2782
|
+
// src/rules/suffix-subjects.ts
|
|
2783
|
+
|
|
2784
|
+
var defaultOptions13 = [];
|
|
2785
|
+
var suffixSubjectsRule = ruleCreator({
|
|
2786
|
+
defaultOptions: defaultOptions13,
|
|
2643
2787
|
meta: {
|
|
2644
2788
|
docs: {
|
|
2645
|
-
description: "
|
|
2789
|
+
description: "Enforce the use of a suffix in subject identifiers.",
|
|
2646
2790
|
requiresTypeChecking: true
|
|
2647
2791
|
},
|
|
2648
2792
|
messages: {
|
|
@@ -2651,11 +2795,11 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2651
2795
|
schema: [
|
|
2652
2796
|
{
|
|
2653
2797
|
properties: {
|
|
2654
|
-
parameters: { type: "boolean" },
|
|
2655
|
-
properties: { type: "boolean" },
|
|
2656
|
-
suffix: { type: "string" },
|
|
2657
|
-
types: { type: "object" },
|
|
2658
|
-
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." }
|
|
2659
2803
|
},
|
|
2660
2804
|
type: "object"
|
|
2661
2805
|
}
|
|
@@ -2664,8 +2808,8 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2664
2808
|
},
|
|
2665
2809
|
name: "suffix-subjects",
|
|
2666
2810
|
create: (context) => {
|
|
2667
|
-
const { esTreeNodeToTSNodeMap } =
|
|
2668
|
-
const { couldBeType } = getTypeServices(context);
|
|
2811
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
2812
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2669
2813
|
const [config = {}] = context.options;
|
|
2670
2814
|
const validate = {
|
|
2671
2815
|
parameters: true,
|
|
@@ -2694,10 +2838,10 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2694
2838
|
function checkNode(nameNode, typeNode) {
|
|
2695
2839
|
const tsNode = esTreeNodeToTSNodeMap.get(nameNode);
|
|
2696
2840
|
const text = tsNode.getText();
|
|
2697
|
-
if (!suffixRegex.test(text) &&
|
|
2841
|
+
if (!suffixRegex.test(text) && couldBeType2(typeNode || nameNode, "Subject")) {
|
|
2698
2842
|
for (const type of types) {
|
|
2699
2843
|
const { regExp, validate: validate2 } = type;
|
|
2700
|
-
if (
|
|
2844
|
+
if (couldBeType2(typeNode || nameNode, regExp) && !validate2) {
|
|
2701
2845
|
return;
|
|
2702
2846
|
}
|
|
2703
2847
|
}
|
|
@@ -2720,7 +2864,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2720
2864
|
if (!found) {
|
|
2721
2865
|
return;
|
|
2722
2866
|
}
|
|
2723
|
-
if (!validate.variables && found.type ===
|
|
2867
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
2724
2868
|
return;
|
|
2725
2869
|
}
|
|
2726
2870
|
if (!validate.parameters) {
|
|
@@ -2787,7 +2931,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2787
2931
|
if (!found) {
|
|
2788
2932
|
return;
|
|
2789
2933
|
}
|
|
2790
|
-
if (!validate.variables && found.type ===
|
|
2934
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
2791
2935
|
return;
|
|
2792
2936
|
}
|
|
2793
2937
|
if (!validate.parameters) {
|
|
@@ -2833,11 +2977,14 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2833
2977
|
}
|
|
2834
2978
|
});
|
|
2835
2979
|
|
|
2836
|
-
|
|
2980
|
+
// src/rules/throw-error.ts
|
|
2981
|
+
|
|
2982
|
+
|
|
2983
|
+
var throwErrorRule = ruleCreator({
|
|
2837
2984
|
defaultOptions: [],
|
|
2838
2985
|
meta: {
|
|
2839
2986
|
docs: {
|
|
2840
|
-
description: "
|
|
2987
|
+
description: "Enforce passing only `Error` values to error notifications.",
|
|
2841
2988
|
requiresTypeChecking: true
|
|
2842
2989
|
},
|
|
2843
2990
|
messages: {
|
|
@@ -2848,17 +2995,17 @@ const throwErrorRule = ruleCreator({
|
|
|
2848
2995
|
},
|
|
2849
2996
|
name: "throw-error",
|
|
2850
2997
|
create: (context) => {
|
|
2851
|
-
const { esTreeNodeToTSNodeMap, program } =
|
|
2998
|
+
const { esTreeNodeToTSNodeMap, program } = _utils.ESLintUtils.getParserServices(context);
|
|
2852
2999
|
const { couldBeObservable, getType } = getTypeServices(context);
|
|
2853
3000
|
function checkNode(node) {
|
|
2854
3001
|
let type = getType(node);
|
|
2855
|
-
if (
|
|
3002
|
+
if (couldBeFunction(type)) {
|
|
2856
3003
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
2857
3004
|
const annotation = tsNode.type;
|
|
2858
3005
|
const body = tsNode.body;
|
|
2859
|
-
type = program.getTypeChecker().getTypeAtLocation(annotation
|
|
3006
|
+
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
2860
3007
|
}
|
|
2861
|
-
if (!
|
|
3008
|
+
if (!tsutils4.isIntrinsicAnyType(type) && !tsutils4.isIntrinsicUnknownType(type) && !couldBeType(type, /^(Error|DOMException)$/)) {
|
|
2862
3009
|
context.report({
|
|
2863
3010
|
messageId: "forbidden",
|
|
2864
3011
|
node
|
|
@@ -2879,7 +3026,8 @@ const throwErrorRule = ruleCreator({
|
|
|
2879
3026
|
}
|
|
2880
3027
|
});
|
|
2881
3028
|
|
|
2882
|
-
|
|
3029
|
+
// src/index.ts
|
|
3030
|
+
var plugin = {
|
|
2883
3031
|
meta: { name, version },
|
|
2884
3032
|
rules: {
|
|
2885
3033
|
"ban-observables": banObservablesRule,
|
|
@@ -2925,11 +3073,15 @@ const plugin = {
|
|
|
2925
3073
|
"throw-error": throwErrorRule
|
|
2926
3074
|
}
|
|
2927
3075
|
};
|
|
2928
|
-
|
|
3076
|
+
var rxjsX = {
|
|
2929
3077
|
...plugin,
|
|
2930
3078
|
configs: {
|
|
2931
3079
|
recommended: createRecommendedConfig(plugin)
|
|
2932
3080
|
}
|
|
2933
3081
|
};
|
|
3082
|
+
var src_default = rxjsX;
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
exports.default = src_default;
|
|
2934
3086
|
|
|
2935
|
-
exports
|
|
3087
|
+
module.exports = exports.default;
|