eslint-plugin-rxjs-x 0.1.0 → 0.2.1
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 +63 -44
- package/dist/index.d.ts +1 -1
- package/dist/{index.cjs → index.js} +429 -344
- package/dist/index.mjs +424 -321
- 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 +23 -16
- package/dist/index.d.cts +0 -121
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const commonTags = require('common-tags');
|
|
5
|
-
const tsutils = require('ts-api-utils');
|
|
6
|
-
const ts = require('typescript');
|
|
7
|
-
const scopeManager = require('@typescript-eslint/scope-manager');
|
|
8
|
-
const decamelize = require('decamelize');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
-
|
|
12
|
-
function _interopNamespaceCompat(e) {
|
|
13
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
14
|
-
const n = Object.create(null);
|
|
15
|
-
if (e) {
|
|
16
|
-
for (const k in e) {
|
|
17
|
-
n[k] = e[k];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return n;
|
|
22
|
-
}
|
|
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.1";
|
|
23
4
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const decamelize__default = /*#__PURE__*/_interopDefaultCompat(decamelize);
|
|
27
|
-
|
|
28
|
-
const name = "eslint-plugin-rxjs-x";
|
|
29
|
-
const version = "0.1.0";
|
|
30
|
-
|
|
31
|
-
const createRecommendedConfig = (plugin) => ({
|
|
5
|
+
// src/configs/recommended.ts
|
|
6
|
+
var createRecommendedConfig = (plugin2) => ({
|
|
32
7
|
plugins: {
|
|
33
|
-
"rxjs-x":
|
|
8
|
+
"rxjs-x": plugin2
|
|
34
9
|
},
|
|
35
10
|
rules: {
|
|
36
11
|
"rxjs-x/no-async-subscribe": "error",
|
|
@@ -51,8 +26,14 @@ const createRecommendedConfig = (plugin) => ({
|
|
|
51
26
|
}
|
|
52
27
|
});
|
|
53
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
|
+
|
|
54
35
|
function createRegExpForWords(config) {
|
|
55
|
-
if (!config
|
|
36
|
+
if (!(config == null ? void 0 : config.length)) {
|
|
56
37
|
return void 0;
|
|
57
38
|
}
|
|
58
39
|
const flags = "i";
|
|
@@ -66,16 +47,17 @@ function createRegExpForWords(config) {
|
|
|
66
47
|
function escapeRegExp(text) {
|
|
67
48
|
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
68
49
|
}
|
|
69
|
-
|
|
70
|
-
(
|
|
50
|
+
var ruleCreator = _utils.ESLintUtils.RuleCreator(
|
|
51
|
+
(name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
|
|
71
52
|
);
|
|
72
53
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
// src/rules/ban-observables.ts
|
|
55
|
+
var defaultOptions = [];
|
|
56
|
+
var banObservablesRule = ruleCreator({
|
|
57
|
+
defaultOptions,
|
|
76
58
|
meta: {
|
|
77
59
|
docs: {
|
|
78
|
-
description: "
|
|
60
|
+
description: "Disallow banned observable creators."
|
|
79
61
|
},
|
|
80
62
|
messages: {
|
|
81
63
|
forbidden: "RxJS observable is banned: {{name}}{{explanation}}."
|
|
@@ -83,7 +65,7 @@ const banObservablesRule = ruleCreator({
|
|
|
83
65
|
schema: [
|
|
84
66
|
{
|
|
85
67
|
type: "object",
|
|
86
|
-
description:
|
|
68
|
+
description: _commontags.stripIndent`
|
|
87
69
|
An object containing keys that are names of observable factory functions
|
|
88
70
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
89
71
|
}
|
|
@@ -105,14 +87,14 @@ const banObservablesRule = ruleCreator({
|
|
|
105
87
|
});
|
|
106
88
|
}
|
|
107
89
|
});
|
|
108
|
-
function getFailure(
|
|
90
|
+
function getFailure(name2) {
|
|
109
91
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
110
92
|
const ban = bans[b];
|
|
111
|
-
if (ban.regExp.test(
|
|
93
|
+
if (ban.regExp.test(name2)) {
|
|
112
94
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
113
95
|
return {
|
|
114
96
|
messageId: "forbidden",
|
|
115
|
-
data: { name, explanation }
|
|
97
|
+
data: { name: name2, explanation }
|
|
116
98
|
};
|
|
117
99
|
}
|
|
118
100
|
}
|
|
@@ -121,8 +103,8 @@ const banObservablesRule = ruleCreator({
|
|
|
121
103
|
return {
|
|
122
104
|
"ImportDeclaration[source.value='rxjs'] > ImportSpecifier": (node) => {
|
|
123
105
|
const identifier = node.imported;
|
|
124
|
-
const
|
|
125
|
-
const failure = getFailure(
|
|
106
|
+
const name2 = identifier.type === _utils.AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
107
|
+
const failure = getFailure(name2);
|
|
126
108
|
if (failure) {
|
|
127
109
|
context.report({
|
|
128
110
|
...failure,
|
|
@@ -134,12 +116,15 @@ const banObservablesRule = ruleCreator({
|
|
|
134
116
|
}
|
|
135
117
|
});
|
|
136
118
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
119
|
+
// src/rules/ban-operators.ts
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
var defaultOptions2 = [];
|
|
123
|
+
var banOperatorsRule = ruleCreator({
|
|
124
|
+
defaultOptions: defaultOptions2,
|
|
140
125
|
meta: {
|
|
141
126
|
docs: {
|
|
142
|
-
description: "
|
|
127
|
+
description: "Disallow banned operators."
|
|
143
128
|
},
|
|
144
129
|
messages: {
|
|
145
130
|
forbidden: "RxJS operator is banned: {{name}}{{explanation}}."
|
|
@@ -147,7 +132,7 @@ const banOperatorsRule = ruleCreator({
|
|
|
147
132
|
schema: [
|
|
148
133
|
{
|
|
149
134
|
type: "object",
|
|
150
|
-
description:
|
|
135
|
+
description: _commontags.stripIndent`
|
|
151
136
|
An object containing keys that are names of operators
|
|
152
137
|
and values that are either booleans or strings containing the explanation for the ban.`
|
|
153
138
|
}
|
|
@@ -169,14 +154,14 @@ const banOperatorsRule = ruleCreator({
|
|
|
169
154
|
});
|
|
170
155
|
}
|
|
171
156
|
});
|
|
172
|
-
function getFailure(
|
|
157
|
+
function getFailure(name2) {
|
|
173
158
|
for (let b = 0, length = bans.length; b < length; ++b) {
|
|
174
159
|
const ban = bans[b];
|
|
175
|
-
if (ban.regExp.test(
|
|
160
|
+
if (ban.regExp.test(name2)) {
|
|
176
161
|
const explanation = ban.explanation ? `: ${ban.explanation}` : "";
|
|
177
162
|
return {
|
|
178
163
|
messageId: "forbidden",
|
|
179
|
-
data: { name, explanation }
|
|
164
|
+
data: { name: name2, explanation }
|
|
180
165
|
};
|
|
181
166
|
}
|
|
182
167
|
}
|
|
@@ -185,8 +170,8 @@ const banOperatorsRule = ruleCreator({
|
|
|
185
170
|
return {
|
|
186
171
|
[String.raw`ImportDeclaration[source.value=/^rxjs\u002foperators$/] > ImportSpecifier`]: (node) => {
|
|
187
172
|
const identifier = node.imported;
|
|
188
|
-
const
|
|
189
|
-
const failure = getFailure(
|
|
173
|
+
const name2 = identifier.type === _utils.AST_NODE_TYPES.Identifier ? identifier.name : identifier.value;
|
|
174
|
+
const failure = getFailure(name2);
|
|
190
175
|
if (failure) {
|
|
191
176
|
context.report({
|
|
192
177
|
...failure,
|
|
@@ -198,26 +183,35 @@ const banOperatorsRule = ruleCreator({
|
|
|
198
183
|
}
|
|
199
184
|
});
|
|
200
185
|
|
|
201
|
-
|
|
202
|
-
|
|
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)) {
|
|
203
197
|
type = type.target;
|
|
204
198
|
}
|
|
205
|
-
if (isType(type,
|
|
199
|
+
if (isType(type, name2, qualified)) {
|
|
206
200
|
return true;
|
|
207
201
|
}
|
|
208
|
-
if (
|
|
209
|
-
return type.types.some((t) => couldBeType(t,
|
|
202
|
+
if (tsutils.isUnionOrIntersectionType(type)) {
|
|
203
|
+
return type.types.some((t) => couldBeType(t, name2, qualified));
|
|
210
204
|
}
|
|
211
205
|
const baseTypes = type.getBaseTypes();
|
|
212
|
-
if (baseTypes
|
|
206
|
+
if (baseTypes == null ? void 0 : baseTypes.some((t) => couldBeType(t, name2, qualified))) {
|
|
213
207
|
return true;
|
|
214
208
|
}
|
|
215
|
-
if (couldImplement(type,
|
|
209
|
+
if (couldImplement(type, name2, qualified)) {
|
|
216
210
|
return true;
|
|
217
211
|
}
|
|
218
212
|
return false;
|
|
219
213
|
}
|
|
220
|
-
function isType(type,
|
|
214
|
+
function isType(type, name2, qualified) {
|
|
221
215
|
if (!type.symbol) {
|
|
222
216
|
return false;
|
|
223
217
|
}
|
|
@@ -226,17 +220,17 @@ function isType(type, name, qualified) {
|
|
|
226
220
|
)) {
|
|
227
221
|
return false;
|
|
228
222
|
}
|
|
229
|
-
return typeof
|
|
223
|
+
return typeof name2 === "string" ? type.symbol.name === name2 : Boolean(type.symbol.name.match(name2));
|
|
230
224
|
}
|
|
231
|
-
function couldImplement(type,
|
|
225
|
+
function couldImplement(type, name2, qualified) {
|
|
232
226
|
const { symbol } = type;
|
|
233
227
|
if (symbol) {
|
|
234
228
|
const { valueDeclaration } = symbol;
|
|
235
|
-
if (valueDeclaration &&
|
|
229
|
+
if (valueDeclaration && ts.isClassDeclaration(valueDeclaration)) {
|
|
236
230
|
const { heritageClauses } = valueDeclaration;
|
|
237
231
|
if (heritageClauses) {
|
|
238
232
|
const implemented = heritageClauses.some(
|
|
239
|
-
({ token, types }) => token ===
|
|
233
|
+
({ token, types }) => token === ts.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node, name2, qualified))
|
|
240
234
|
);
|
|
241
235
|
if (implemented) {
|
|
242
236
|
return true;
|
|
@@ -246,7 +240,7 @@ function couldImplement(type, name, qualified) {
|
|
|
246
240
|
}
|
|
247
241
|
return false;
|
|
248
242
|
}
|
|
249
|
-
function isMatchingNode(node,
|
|
243
|
+
function isMatchingNode(node, name2, qualified) {
|
|
250
244
|
const { expression } = node;
|
|
251
245
|
if (qualified) {
|
|
252
246
|
const type = qualified.typeChecker.getTypeAtLocation(expression);
|
|
@@ -260,13 +254,15 @@ function isMatchingNode(node, name, qualified) {
|
|
|
260
254
|
}
|
|
261
255
|
}
|
|
262
256
|
const text = expression.getText();
|
|
263
|
-
return typeof
|
|
257
|
+
return typeof name2 === "string" ? text === name2 : Boolean(text.match(name2));
|
|
264
258
|
}
|
|
265
259
|
|
|
260
|
+
// src/etc/could-be-function.ts
|
|
266
261
|
function couldBeFunction(type) {
|
|
267
|
-
return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type,
|
|
262
|
+
return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type, ts2.InternalSymbolName.Function);
|
|
268
263
|
}
|
|
269
264
|
|
|
265
|
+
// src/etc/find-parent.ts
|
|
270
266
|
function findParent(node, ...args) {
|
|
271
267
|
const [arg] = args;
|
|
272
268
|
const predicate = typeof arg === "function" ? arg : (type) => !args.includes(type) ? "continue" : "return";
|
|
@@ -277,16 +273,20 @@ function findParent(node, ...args) {
|
|
|
277
273
|
return void 0;
|
|
278
274
|
case "return":
|
|
279
275
|
return parent;
|
|
276
|
+
default:
|
|
277
|
+
break;
|
|
280
278
|
}
|
|
281
279
|
parent = parent.parent;
|
|
282
280
|
}
|
|
283
281
|
return void 0;
|
|
284
282
|
}
|
|
285
283
|
|
|
284
|
+
// src/etc/get-loc.ts
|
|
285
|
+
|
|
286
286
|
function getLoc(node) {
|
|
287
287
|
const sourceFile = node.getSourceFile();
|
|
288
|
-
const start =
|
|
289
|
-
const end =
|
|
288
|
+
const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
289
|
+
const end = ts3.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
|
|
290
290
|
return {
|
|
291
291
|
start: {
|
|
292
292
|
line: start.line + 1,
|
|
@@ -299,76 +299,85 @@ function getLoc(node) {
|
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
+
// src/etc/get-type-services.ts
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
// src/etc/is.ts
|
|
308
|
+
|
|
302
309
|
function hasTypeAnnotation(node) {
|
|
303
310
|
return "typeAnnotation" in node && !!node.typeAnnotation;
|
|
304
311
|
}
|
|
305
312
|
function isArrayExpression(node) {
|
|
306
|
-
return node.type ===
|
|
313
|
+
return node.type === _utils.AST_NODE_TYPES.ArrayExpression;
|
|
307
314
|
}
|
|
308
315
|
function isArrayPattern(node) {
|
|
309
|
-
return node.type ===
|
|
316
|
+
return node.type === _utils.AST_NODE_TYPES.ArrayPattern;
|
|
310
317
|
}
|
|
311
318
|
function isArrowFunctionExpression(node) {
|
|
312
|
-
return node.type ===
|
|
319
|
+
return node.type === _utils.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
313
320
|
}
|
|
314
321
|
function isBlockStatement(node) {
|
|
315
|
-
return node.type ===
|
|
322
|
+
return node.type === _utils.AST_NODE_TYPES.BlockStatement;
|
|
316
323
|
}
|
|
317
324
|
function isCallExpression(node) {
|
|
318
|
-
return node.type ===
|
|
325
|
+
return node.type === _utils.AST_NODE_TYPES.CallExpression;
|
|
319
326
|
}
|
|
320
327
|
function isFunctionDeclaration(node) {
|
|
321
|
-
return node.type ===
|
|
328
|
+
return node.type === _utils.AST_NODE_TYPES.FunctionDeclaration;
|
|
322
329
|
}
|
|
323
330
|
function isFunctionExpression(node) {
|
|
324
|
-
return node.type ===
|
|
331
|
+
return node.type === _utils.AST_NODE_TYPES.FunctionExpression;
|
|
325
332
|
}
|
|
326
333
|
function isIdentifier(node) {
|
|
327
|
-
return node.type ===
|
|
334
|
+
return node.type === _utils.AST_NODE_TYPES.Identifier;
|
|
328
335
|
}
|
|
329
336
|
function isLiteral(node) {
|
|
330
|
-
return node.type ===
|
|
337
|
+
return node.type === _utils.AST_NODE_TYPES.Literal;
|
|
331
338
|
}
|
|
332
339
|
function isMemberExpression(node) {
|
|
333
|
-
return node.type ===
|
|
340
|
+
return node.type === _utils.AST_NODE_TYPES.MemberExpression;
|
|
334
341
|
}
|
|
335
342
|
function isObjectExpression(node) {
|
|
336
|
-
return node.type ===
|
|
343
|
+
return node.type === _utils.AST_NODE_TYPES.ObjectExpression;
|
|
337
344
|
}
|
|
338
345
|
function isObjectPattern(node) {
|
|
339
|
-
return node.type ===
|
|
346
|
+
return node.type === _utils.AST_NODE_TYPES.ObjectPattern;
|
|
340
347
|
}
|
|
341
348
|
function isProgram(node) {
|
|
342
|
-
return node.type ===
|
|
349
|
+
return node.type === _utils.AST_NODE_TYPES.Program;
|
|
343
350
|
}
|
|
344
351
|
function isProperty(node) {
|
|
345
|
-
return node.type ===
|
|
352
|
+
return node.type === _utils.AST_NODE_TYPES.Property;
|
|
346
353
|
}
|
|
347
354
|
|
|
355
|
+
// src/etc/get-type-services.ts
|
|
348
356
|
function getTypeServices(context) {
|
|
349
|
-
const services =
|
|
357
|
+
const services = _utils.ESLintUtils.getParserServices(context);
|
|
350
358
|
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = services;
|
|
351
359
|
const typeChecker = program.getTypeChecker();
|
|
352
|
-
const
|
|
360
|
+
const couldBeType2 = (node, name2, qualified) => {
|
|
353
361
|
const type = getType(node);
|
|
354
362
|
return couldBeType(
|
|
355
363
|
type,
|
|
356
|
-
|
|
364
|
+
name2,
|
|
357
365
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
358
366
|
);
|
|
359
367
|
};
|
|
360
|
-
const couldReturnType = (node,
|
|
368
|
+
const couldReturnType = (node, name2, qualified) => {
|
|
369
|
+
var _a;
|
|
361
370
|
let tsTypeNode;
|
|
362
371
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
363
|
-
if (
|
|
364
|
-
tsTypeNode = tsNode.type
|
|
365
|
-
} 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)) {
|
|
366
375
|
tsTypeNode = tsNode.type;
|
|
367
376
|
}
|
|
368
377
|
return Boolean(
|
|
369
378
|
tsTypeNode && couldBeType(
|
|
370
379
|
typeChecker.getTypeAtLocation(tsTypeNode),
|
|
371
|
-
|
|
380
|
+
name2,
|
|
372
381
|
qualified ? { ...qualified, typeChecker } : void 0
|
|
373
382
|
)
|
|
374
383
|
);
|
|
@@ -377,45 +386,49 @@ function getTypeServices(context) {
|
|
|
377
386
|
return getTypeAtLocation(node);
|
|
378
387
|
};
|
|
379
388
|
return {
|
|
380
|
-
couldBeBehaviorSubject: (node) =>
|
|
381
|
-
couldBeError: (node) =>
|
|
389
|
+
couldBeBehaviorSubject: (node) => couldBeType2(node, "BehaviorSubject"),
|
|
390
|
+
couldBeError: (node) => couldBeType2(node, "Error"),
|
|
382
391
|
couldBeFunction: (node) => {
|
|
383
392
|
if (isArrowFunctionExpression(node) || isFunctionDeclaration(node)) {
|
|
384
393
|
return true;
|
|
385
394
|
}
|
|
386
395
|
return couldBeFunction(getType(node));
|
|
387
396
|
},
|
|
388
|
-
couldBeMonoTypeOperatorFunction: (node) =>
|
|
389
|
-
couldBeObservable: (node) =>
|
|
390
|
-
couldBeSubject: (node) =>
|
|
391
|
-
couldBeSubscription: (node) =>
|
|
392
|
-
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,
|
|
393
402
|
couldReturnObservable: (node) => couldReturnType(node, "Observable"),
|
|
394
403
|
couldReturnType,
|
|
395
404
|
getType,
|
|
396
|
-
isAny: (node) =>
|
|
397
|
-
isReferenceType: (node) =>
|
|
398
|
-
isUnknown: (node) =>
|
|
405
|
+
isAny: (node) => tsutils2.isIntrinsicAnyType(getType(node)),
|
|
406
|
+
isReferenceType: (node) => tsutils2.isTypeReference(getType(node)),
|
|
407
|
+
isUnknown: (node) => tsutils2.isIntrinsicUnknownType(getType(node)),
|
|
399
408
|
typeChecker
|
|
400
409
|
};
|
|
401
410
|
}
|
|
402
411
|
|
|
403
|
-
|
|
404
|
-
|
|
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);
|
|
405
417
|
if (variable) {
|
|
406
418
|
return variable.defs.some(
|
|
407
|
-
(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))
|
|
408
420
|
);
|
|
409
421
|
}
|
|
410
|
-
return scope.upper ? isImport(scope.upper,
|
|
422
|
+
return scope.upper ? isImport(scope.upper, name2, source) : false;
|
|
411
423
|
}
|
|
412
424
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
425
|
+
// src/rules/finnish.ts
|
|
426
|
+
var defaultOptions3 = [];
|
|
427
|
+
var finnishRule = ruleCreator({
|
|
428
|
+
defaultOptions: defaultOptions3,
|
|
416
429
|
meta: {
|
|
417
430
|
docs: {
|
|
418
|
-
description: "
|
|
431
|
+
description: "Enforce Finnish notation.",
|
|
419
432
|
requiresTypeChecking: true
|
|
420
433
|
},
|
|
421
434
|
messages: {
|
|
@@ -425,14 +438,14 @@ const finnishRule = ruleCreator({
|
|
|
425
438
|
schema: [
|
|
426
439
|
{
|
|
427
440
|
properties: {
|
|
428
|
-
functions: { type: "boolean" },
|
|
429
|
-
methods: { type: "boolean" },
|
|
430
|
-
names: { type: "object" },
|
|
431
|
-
parameters: { type: "boolean" },
|
|
432
|
-
properties: { type: "boolean" },
|
|
433
|
-
strict: { type: "boolean" },
|
|
434
|
-
types: { type: "object" },
|
|
435
|
-
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." }
|
|
436
449
|
},
|
|
437
450
|
type: "object"
|
|
438
451
|
}
|
|
@@ -441,10 +454,10 @@ const finnishRule = ruleCreator({
|
|
|
441
454
|
},
|
|
442
455
|
name: "finnish",
|
|
443
456
|
create: (context) => {
|
|
444
|
-
const { esTreeNodeToTSNodeMap } =
|
|
457
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
445
458
|
const {
|
|
446
459
|
couldBeObservable,
|
|
447
|
-
couldBeType,
|
|
460
|
+
couldBeType: couldBeType2,
|
|
448
461
|
couldReturnObservable,
|
|
449
462
|
couldReturnType
|
|
450
463
|
} = getTypeServices(context);
|
|
@@ -505,9 +518,9 @@ const finnishRule = ruleCreator({
|
|
|
505
518
|
});
|
|
506
519
|
} : () => {
|
|
507
520
|
};
|
|
508
|
-
if (couldBeObservable(typeNode
|
|
509
|
-
for (const
|
|
510
|
-
const { regExp, validate: validate2 } =
|
|
521
|
+
if (couldBeObservable(typeNode != null ? typeNode : nameNode) || couldReturnObservable(typeNode != null ? typeNode : nameNode)) {
|
|
522
|
+
for (const name2 of names) {
|
|
523
|
+
const { regExp, validate: validate2 } = name2;
|
|
511
524
|
if (regExp.test(text) && !validate2) {
|
|
512
525
|
shouldNotBeFinnish();
|
|
513
526
|
return;
|
|
@@ -515,7 +528,7 @@ const finnishRule = ruleCreator({
|
|
|
515
528
|
}
|
|
516
529
|
for (const type of types) {
|
|
517
530
|
const { regExp, validate: validate2 } = type;
|
|
518
|
-
if ((
|
|
531
|
+
if ((couldBeType2(typeNode != null ? typeNode : nameNode, regExp) || couldReturnType(typeNode != null ? typeNode : nameNode, regExp)) && !validate2) {
|
|
519
532
|
shouldNotBeFinnish();
|
|
520
533
|
return;
|
|
521
534
|
}
|
|
@@ -537,7 +550,7 @@ const finnishRule = ruleCreator({
|
|
|
537
550
|
if (!found) {
|
|
538
551
|
return;
|
|
539
552
|
}
|
|
540
|
-
if (!validate.variables && found.type ===
|
|
553
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
541
554
|
return;
|
|
542
555
|
}
|
|
543
556
|
if (!validate.parameters) {
|
|
@@ -616,7 +629,7 @@ const finnishRule = ruleCreator({
|
|
|
616
629
|
if (!found) {
|
|
617
630
|
return;
|
|
618
631
|
}
|
|
619
|
-
if (!validate.variables && found.type ===
|
|
632
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
620
633
|
return;
|
|
621
634
|
}
|
|
622
635
|
if (!validate.parameters) {
|
|
@@ -667,11 +680,12 @@ const finnishRule = ruleCreator({
|
|
|
667
680
|
}
|
|
668
681
|
});
|
|
669
682
|
|
|
670
|
-
|
|
683
|
+
// src/rules/just.ts
|
|
684
|
+
var justRule = ruleCreator({
|
|
671
685
|
defaultOptions: [],
|
|
672
686
|
meta: {
|
|
673
687
|
docs: {
|
|
674
|
-
description: "
|
|
688
|
+
description: "Require the use of `just` instead of `of`."
|
|
675
689
|
},
|
|
676
690
|
fixable: "code",
|
|
677
691
|
messages: {
|
|
@@ -705,11 +719,12 @@ const justRule = ruleCreator({
|
|
|
705
719
|
}
|
|
706
720
|
});
|
|
707
721
|
|
|
708
|
-
|
|
722
|
+
// src/rules/macro.ts
|
|
723
|
+
var macroRule = ruleCreator({
|
|
709
724
|
defaultOptions: [],
|
|
710
725
|
meta: {
|
|
711
726
|
docs: {
|
|
712
|
-
description: "
|
|
727
|
+
description: "Require the use of the RxJS Tools Babel macro."
|
|
713
728
|
},
|
|
714
729
|
fixable: "code",
|
|
715
730
|
messages: {
|
|
@@ -764,11 +779,12 @@ const macroRule = ruleCreator({
|
|
|
764
779
|
}
|
|
765
780
|
});
|
|
766
781
|
|
|
767
|
-
|
|
782
|
+
// src/rules/no-async-subscribe.ts
|
|
783
|
+
var noAsyncSubscribeRule = ruleCreator({
|
|
768
784
|
defaultOptions: [],
|
|
769
785
|
meta: {
|
|
770
786
|
docs: {
|
|
771
|
-
description: "
|
|
787
|
+
description: "Disallow passing `async` functions to `subscribe`.",
|
|
772
788
|
recommended: true,
|
|
773
789
|
requiresTypeChecking: true
|
|
774
790
|
},
|
|
@@ -806,11 +822,12 @@ const noAsyncSubscribeRule = ruleCreator({
|
|
|
806
822
|
}
|
|
807
823
|
});
|
|
808
824
|
|
|
809
|
-
|
|
825
|
+
// src/rules/no-compat.ts
|
|
826
|
+
var noCompatRule = ruleCreator({
|
|
810
827
|
defaultOptions: [],
|
|
811
828
|
meta: {
|
|
812
829
|
docs: {
|
|
813
|
-
description: "
|
|
830
|
+
description: "Disallow the `rxjs-compat` package."
|
|
814
831
|
},
|
|
815
832
|
messages: {
|
|
816
833
|
forbidden: "'rxjs-compat'-dependent import locations are forbidden."
|
|
@@ -831,11 +848,12 @@ const noCompatRule = ruleCreator({
|
|
|
831
848
|
}
|
|
832
849
|
});
|
|
833
850
|
|
|
834
|
-
|
|
851
|
+
// src/rules/no-connectable.ts
|
|
852
|
+
var noConnectableRule = ruleCreator({
|
|
835
853
|
defaultOptions: [],
|
|
836
854
|
meta: {
|
|
837
855
|
docs: {
|
|
838
|
-
description: "
|
|
856
|
+
description: "Disallow operators that return connectable observables.",
|
|
839
857
|
requiresTypeChecking: true
|
|
840
858
|
},
|
|
841
859
|
messages: {
|
|
@@ -846,7 +864,7 @@ const noConnectableRule = ruleCreator({
|
|
|
846
864
|
},
|
|
847
865
|
name: "no-connectable",
|
|
848
866
|
create: (context) => {
|
|
849
|
-
const { couldBeFunction } = getTypeServices(context);
|
|
867
|
+
const { couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
850
868
|
return {
|
|
851
869
|
"CallExpression[callee.name='multicast']": (node) => {
|
|
852
870
|
if (node.arguments.length === 1) {
|
|
@@ -857,7 +875,7 @@ const noConnectableRule = ruleCreator({
|
|
|
857
875
|
}
|
|
858
876
|
},
|
|
859
877
|
"CallExpression[callee.name=/^(publish|publishBehavior|publishLast|publishReplay)$/]": (node) => {
|
|
860
|
-
if (!node.arguments.some((arg) =>
|
|
878
|
+
if (!node.arguments.some((arg) => couldBeFunction2(arg))) {
|
|
861
879
|
context.report({
|
|
862
880
|
messageId: "forbidden",
|
|
863
881
|
node: node.callee
|
|
@@ -868,11 +886,12 @@ const noConnectableRule = ruleCreator({
|
|
|
868
886
|
}
|
|
869
887
|
});
|
|
870
888
|
|
|
871
|
-
|
|
889
|
+
// src/rules/no-create.ts
|
|
890
|
+
var noCreateRule = ruleCreator({
|
|
872
891
|
defaultOptions: [],
|
|
873
892
|
meta: {
|
|
874
893
|
docs: {
|
|
875
|
-
description: "
|
|
894
|
+
description: "Disallow the static `Observable.create` function.",
|
|
876
895
|
recommended: true,
|
|
877
896
|
requiresTypeChecking: true
|
|
878
897
|
},
|
|
@@ -899,17 +918,23 @@ const noCreateRule = ruleCreator({
|
|
|
899
918
|
}
|
|
900
919
|
});
|
|
901
920
|
|
|
902
|
-
|
|
921
|
+
// src/rules/no-cyclic-action.ts
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
// src/constants.ts
|
|
926
|
+
var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
|
|
903
927
|
|
|
904
|
-
|
|
928
|
+
// src/rules/no-cyclic-action.ts
|
|
929
|
+
function isTypeReference3(type) {
|
|
905
930
|
return Boolean(type.target);
|
|
906
931
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
defaultOptions:
|
|
932
|
+
var defaultOptions4 = [];
|
|
933
|
+
var noCyclicActionRule = ruleCreator({
|
|
934
|
+
defaultOptions: defaultOptions4,
|
|
910
935
|
meta: {
|
|
911
936
|
docs: {
|
|
912
|
-
description: "
|
|
937
|
+
description: "Disallow cyclic actions in effects and epics.",
|
|
913
938
|
requiresTypeChecking: true
|
|
914
939
|
},
|
|
915
940
|
messages: {
|
|
@@ -918,10 +943,10 @@ const noCyclicActionRule = ruleCreator({
|
|
|
918
943
|
schema: [
|
|
919
944
|
{
|
|
920
945
|
properties: {
|
|
921
|
-
observable: { type: "string" }
|
|
946
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
922
947
|
},
|
|
923
948
|
type: "object",
|
|
924
|
-
description:
|
|
949
|
+
description: _commontags.stripIndent`
|
|
925
950
|
An optional object with an optional \`observable\` property.
|
|
926
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.`
|
|
927
952
|
}
|
|
@@ -944,13 +969,13 @@ const noCyclicActionRule = ruleCreator({
|
|
|
944
969
|
const operatorType = getType(operatorCallExpression);
|
|
945
970
|
const [signature] = typeChecker.getSignaturesOfType(
|
|
946
971
|
operatorType,
|
|
947
|
-
|
|
972
|
+
ts5.SignatureKind.Call
|
|
948
973
|
);
|
|
949
974
|
if (!signature) {
|
|
950
975
|
return;
|
|
951
976
|
}
|
|
952
977
|
const operatorReturnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
953
|
-
if (!
|
|
978
|
+
if (!isTypeReference3(operatorReturnType)) {
|
|
954
979
|
return;
|
|
955
980
|
}
|
|
956
981
|
const [operatorElementType] = typeChecker.getTypeArguments(operatorReturnType);
|
|
@@ -958,7 +983,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
958
983
|
return;
|
|
959
984
|
}
|
|
960
985
|
const pipeType = getType(pipeCallExpression);
|
|
961
|
-
if (!
|
|
986
|
+
if (!isTypeReference3(pipeType)) {
|
|
962
987
|
return;
|
|
963
988
|
}
|
|
964
989
|
const [pipeElementType] = typeChecker.getTypeArguments(pipeType);
|
|
@@ -986,7 +1011,7 @@ const noCyclicActionRule = ruleCreator({
|
|
|
986
1011
|
return memberActionTypes;
|
|
987
1012
|
}
|
|
988
1013
|
const symbol = typeChecker.getPropertyOfType(type, "type");
|
|
989
|
-
if (!symbol
|
|
1014
|
+
if (!(symbol == null ? void 0 : symbol.valueDeclaration)) {
|
|
990
1015
|
return [];
|
|
991
1016
|
}
|
|
992
1017
|
const actionType = typeChecker.getTypeOfSymbolAtLocation(
|
|
@@ -1002,11 +1027,12 @@ const noCyclicActionRule = ruleCreator({
|
|
|
1002
1027
|
}
|
|
1003
1028
|
});
|
|
1004
1029
|
|
|
1005
|
-
|
|
1030
|
+
// src/rules/no-explicit-generics.ts
|
|
1031
|
+
var noExplicitGenericsRule = ruleCreator({
|
|
1006
1032
|
defaultOptions: [],
|
|
1007
1033
|
meta: {
|
|
1008
1034
|
docs: {
|
|
1009
|
-
description: "
|
|
1035
|
+
description: "Disallow unnecessary explicit generic type arguments."
|
|
1010
1036
|
},
|
|
1011
1037
|
messages: {
|
|
1012
1038
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -1051,13 +1077,14 @@ const noExplicitGenericsRule = ruleCreator({
|
|
|
1051
1077
|
}
|
|
1052
1078
|
});
|
|
1053
1079
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1080
|
+
// src/rules/no-exposed-subjects.ts
|
|
1081
|
+
var defaultAllowedTypesRegExp = /^EventEmitter$/;
|
|
1082
|
+
var defaultOptions5 = [];
|
|
1083
|
+
var noExposedSubjectsRule = ruleCreator({
|
|
1084
|
+
defaultOptions: defaultOptions5,
|
|
1058
1085
|
meta: {
|
|
1059
1086
|
docs: {
|
|
1060
|
-
description: "
|
|
1087
|
+
description: "Disallow public and protected subjects.",
|
|
1061
1088
|
requiresTypeChecking: true
|
|
1062
1089
|
},
|
|
1063
1090
|
messages: {
|
|
@@ -1067,7 +1094,7 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1067
1094
|
schema: [
|
|
1068
1095
|
{
|
|
1069
1096
|
properties: {
|
|
1070
|
-
allowProtected: { type: "boolean" }
|
|
1097
|
+
allowProtected: { type: "boolean", description: "Allow protected subjects.", default: false }
|
|
1071
1098
|
},
|
|
1072
1099
|
type: "object"
|
|
1073
1100
|
}
|
|
@@ -1078,11 +1105,11 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1078
1105
|
create: (context) => {
|
|
1079
1106
|
const [config = {}] = context.options;
|
|
1080
1107
|
const { allowProtected = false } = config;
|
|
1081
|
-
const { couldBeSubject, couldBeType } = getTypeServices(context);
|
|
1108
|
+
const { couldBeSubject, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1082
1109
|
const messageId = allowProtected ? "forbiddenAllowProtected" : "forbidden";
|
|
1083
1110
|
const accessibilityRexExp = allowProtected ? /^(private|protected)$/ : /^private$/;
|
|
1084
1111
|
function isSubject(node) {
|
|
1085
|
-
return couldBeSubject(node) && !
|
|
1112
|
+
return couldBeSubject(node) && !couldBeType2(node, defaultAllowedTypesRegExp);
|
|
1086
1113
|
}
|
|
1087
1114
|
return {
|
|
1088
1115
|
[`PropertyDefinition[accessibility!=${accessibilityRexExp}]`]: (node) => {
|
|
@@ -1154,11 +1181,13 @@ const noExposedSubjectsRule = ruleCreator({
|
|
|
1154
1181
|
}
|
|
1155
1182
|
});
|
|
1156
1183
|
|
|
1157
|
-
|
|
1184
|
+
// src/rules/no-finnish.ts
|
|
1185
|
+
|
|
1186
|
+
var noFinnishRule = ruleCreator({
|
|
1158
1187
|
defaultOptions: [],
|
|
1159
1188
|
meta: {
|
|
1160
1189
|
docs: {
|
|
1161
|
-
description: "
|
|
1190
|
+
description: "Disallow Finnish notation.",
|
|
1162
1191
|
requiresTypeChecking: true
|
|
1163
1192
|
},
|
|
1164
1193
|
messages: {
|
|
@@ -1169,10 +1198,10 @@ const noFinnishRule = ruleCreator({
|
|
|
1169
1198
|
},
|
|
1170
1199
|
name: "no-finnish",
|
|
1171
1200
|
create: (context) => {
|
|
1172
|
-
const { esTreeNodeToTSNodeMap } =
|
|
1201
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
1173
1202
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
1174
1203
|
function checkNode(nameNode, typeNode) {
|
|
1175
|
-
if (couldBeObservable(typeNode
|
|
1204
|
+
if (couldBeObservable(typeNode != null ? typeNode : nameNode) || couldReturnObservable(typeNode != null ? typeNode : nameNode)) {
|
|
1176
1205
|
const tsNode = esTreeNodeToTSNodeMap.get(nameNode);
|
|
1177
1206
|
if (/[$]+$/.test(tsNode.getText())) {
|
|
1178
1207
|
context.report({
|
|
@@ -1241,17 +1270,19 @@ const noFinnishRule = ruleCreator({
|
|
|
1241
1270
|
}
|
|
1242
1271
|
},
|
|
1243
1272
|
"VariableDeclarator[id.name=/[$]+$/]": (node) => {
|
|
1244
|
-
|
|
1273
|
+
var _a;
|
|
1274
|
+
checkNode(node.id, (_a = node.init) != null ? _a : node);
|
|
1245
1275
|
}
|
|
1246
1276
|
};
|
|
1247
1277
|
}
|
|
1248
1278
|
});
|
|
1249
1279
|
|
|
1250
|
-
|
|
1280
|
+
// src/rules/no-ignored-error.ts
|
|
1281
|
+
var noIgnoredErrorRule = ruleCreator({
|
|
1251
1282
|
defaultOptions: [],
|
|
1252
1283
|
meta: {
|
|
1253
1284
|
docs: {
|
|
1254
|
-
description: "
|
|
1285
|
+
description: "Disallow calling `subscribe` without specifying an error handler.",
|
|
1255
1286
|
requiresTypeChecking: true
|
|
1256
1287
|
},
|
|
1257
1288
|
messages: {
|
|
@@ -1262,12 +1293,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1262
1293
|
},
|
|
1263
1294
|
name: "no-ignored-error",
|
|
1264
1295
|
create: (context) => {
|
|
1265
|
-
const { couldBeObservable, couldBeFunction } = getTypeServices(context);
|
|
1296
|
+
const { couldBeObservable, couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
1266
1297
|
return {
|
|
1267
1298
|
"CallExpression[arguments.length > 0] > MemberExpression > Identifier[name='subscribe']": (node) => {
|
|
1268
1299
|
const memberExpression = node.parent;
|
|
1269
1300
|
const callExpression = memberExpression.parent;
|
|
1270
|
-
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) &&
|
|
1301
|
+
if (callExpression.arguments.length < 2 && couldBeObservable(memberExpression.object) && couldBeFunction2(callExpression.arguments[0])) {
|
|
1271
1302
|
context.report({
|
|
1272
1303
|
messageId: "forbidden",
|
|
1273
1304
|
node
|
|
@@ -1278,11 +1309,12 @@ const noIgnoredErrorRule = ruleCreator({
|
|
|
1278
1309
|
}
|
|
1279
1310
|
});
|
|
1280
1311
|
|
|
1281
|
-
|
|
1312
|
+
// src/rules/no-ignored-notifier.ts
|
|
1313
|
+
var noIgnoredNotifierRule = ruleCreator({
|
|
1282
1314
|
defaultOptions: [],
|
|
1283
1315
|
meta: {
|
|
1284
1316
|
docs: {
|
|
1285
|
-
description: "
|
|
1317
|
+
description: "Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier.",
|
|
1286
1318
|
recommended: true,
|
|
1287
1319
|
requiresTypeChecking: true
|
|
1288
1320
|
},
|
|
@@ -1349,11 +1381,12 @@ const noIgnoredNotifierRule = ruleCreator({
|
|
|
1349
1381
|
}
|
|
1350
1382
|
});
|
|
1351
1383
|
|
|
1352
|
-
|
|
1384
|
+
// src/rules/no-ignored-observable.ts
|
|
1385
|
+
var noIgnoredObservableRule = ruleCreator({
|
|
1353
1386
|
defaultOptions: [],
|
|
1354
1387
|
meta: {
|
|
1355
1388
|
docs: {
|
|
1356
|
-
description: "
|
|
1389
|
+
description: "Disallow ignoring observables returned by functions.",
|
|
1357
1390
|
requiresTypeChecking: true
|
|
1358
1391
|
},
|
|
1359
1392
|
messages: {
|
|
@@ -1378,11 +1411,12 @@ const noIgnoredObservableRule = ruleCreator({
|
|
|
1378
1411
|
}
|
|
1379
1412
|
});
|
|
1380
1413
|
|
|
1381
|
-
|
|
1414
|
+
// src/rules/no-ignored-replay-buffer.ts
|
|
1415
|
+
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1382
1416
|
defaultOptions: [],
|
|
1383
1417
|
meta: {
|
|
1384
1418
|
docs: {
|
|
1385
|
-
description: "
|
|
1419
|
+
description: "Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size.",
|
|
1386
1420
|
recommended: true
|
|
1387
1421
|
},
|
|
1388
1422
|
messages: {
|
|
@@ -1419,11 +1453,12 @@ const noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1419
1453
|
}
|
|
1420
1454
|
});
|
|
1421
1455
|
|
|
1422
|
-
|
|
1456
|
+
// src/rules/no-ignored-subscribe.ts
|
|
1457
|
+
var noIgnoredSubscribeRule = ruleCreator({
|
|
1423
1458
|
defaultOptions: [],
|
|
1424
1459
|
meta: {
|
|
1425
1460
|
docs: {
|
|
1426
|
-
description: "
|
|
1461
|
+
description: "Disallow calling `subscribe` without specifying arguments.",
|
|
1427
1462
|
requiresTypeChecking: true
|
|
1428
1463
|
},
|
|
1429
1464
|
messages: {
|
|
@@ -1434,11 +1469,11 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1434
1469
|
},
|
|
1435
1470
|
name: "no-ignored-subscribe",
|
|
1436
1471
|
create: (context) => {
|
|
1437
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1472
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1438
1473
|
return {
|
|
1439
1474
|
"CallExpression[arguments.length = 0][callee.property.name='subscribe']": (node) => {
|
|
1440
1475
|
const callee = node.callee;
|
|
1441
|
-
if (couldBeObservable(callee.object) ||
|
|
1476
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
1442
1477
|
context.report({
|
|
1443
1478
|
messageId: "forbidden",
|
|
1444
1479
|
node: callee.property
|
|
@@ -1449,11 +1484,12 @@ const noIgnoredSubscribeRule = ruleCreator({
|
|
|
1449
1484
|
}
|
|
1450
1485
|
});
|
|
1451
1486
|
|
|
1452
|
-
|
|
1487
|
+
// src/rules/no-ignored-subscription.ts
|
|
1488
|
+
var noIgnoredSubscriptionRule = ruleCreator({
|
|
1453
1489
|
defaultOptions: [],
|
|
1454
1490
|
meta: {
|
|
1455
1491
|
docs: {
|
|
1456
|
-
description: "
|
|
1492
|
+
description: "Disallow ignoring the subscription returned by `subscribe`.",
|
|
1457
1493
|
requiresTypeChecking: true
|
|
1458
1494
|
},
|
|
1459
1495
|
messages: {
|
|
@@ -1464,12 +1500,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1464
1500
|
},
|
|
1465
1501
|
name: "no-ignored-subscription",
|
|
1466
1502
|
create: (context) => {
|
|
1467
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1503
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1468
1504
|
return {
|
|
1469
1505
|
"ExpressionStatement > CallExpression > MemberExpression[property.name='subscribe']": (node) => {
|
|
1470
1506
|
if (couldBeObservable(node.object)) {
|
|
1471
1507
|
const callExpression = node.parent;
|
|
1472
|
-
if (callExpression.arguments.length === 1 &&
|
|
1508
|
+
if (callExpression.arguments.length === 1 && couldBeType2(callExpression.arguments[0], "Subscriber")) {
|
|
1473
1509
|
return;
|
|
1474
1510
|
}
|
|
1475
1511
|
context.report({
|
|
@@ -1482,11 +1518,12 @@ const noIgnoredSubscriptionRule = ruleCreator({
|
|
|
1482
1518
|
}
|
|
1483
1519
|
});
|
|
1484
1520
|
|
|
1485
|
-
|
|
1521
|
+
// src/rules/no-ignored-takewhile-value.ts
|
|
1522
|
+
var noIgnoredTakewhileValueRule = ruleCreator({
|
|
1486
1523
|
defaultOptions: [],
|
|
1487
1524
|
meta: {
|
|
1488
1525
|
docs: {
|
|
1489
|
-
description: "
|
|
1526
|
+
description: "Disallow ignoring the value within `takeWhile`.",
|
|
1490
1527
|
recommended: true
|
|
1491
1528
|
},
|
|
1492
1529
|
messages: {
|
|
@@ -1507,7 +1544,7 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1507
1544
|
if (param) {
|
|
1508
1545
|
if (isIdentifier(param)) {
|
|
1509
1546
|
const variable = scope.variables.find(
|
|
1510
|
-
({ name }) =>
|
|
1547
|
+
({ name: name2 }) => name2 === param.name
|
|
1511
1548
|
);
|
|
1512
1549
|
if (variable && variable.references.length > 0) {
|
|
1513
1550
|
ignored = false;
|
|
@@ -1536,17 +1573,21 @@ const noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1536
1573
|
}
|
|
1537
1574
|
});
|
|
1538
1575
|
|
|
1576
|
+
// src/rules/no-implicit-any-catch.ts
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1539
1580
|
function isParenthesised(sourceCode, node) {
|
|
1540
1581
|
const before = sourceCode.getTokenBefore(node);
|
|
1541
1582
|
const after = sourceCode.getTokenAfter(node);
|
|
1542
1583
|
return before && after && before.value === "(" && before.range[1] <= node.range[0] && after.value === ")" && after.range[0] >= node.range[1];
|
|
1543
1584
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
defaultOptions:
|
|
1585
|
+
var defaultOptions6 = [];
|
|
1586
|
+
var noImplicitAnyCatchRule = ruleCreator({
|
|
1587
|
+
defaultOptions: defaultOptions6,
|
|
1547
1588
|
meta: {
|
|
1548
1589
|
docs: {
|
|
1549
|
-
description: "
|
|
1590
|
+
description: "Disallow implicit `any` error parameters in `catchError` operators.",
|
|
1550
1591
|
recommended: true,
|
|
1551
1592
|
requiresTypeChecking: true
|
|
1552
1593
|
},
|
|
@@ -1563,7 +1604,9 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1563
1604
|
additionalProperties: false,
|
|
1564
1605
|
properties: {
|
|
1565
1606
|
allowExplicitAny: {
|
|
1566
|
-
type: "boolean"
|
|
1607
|
+
type: "boolean",
|
|
1608
|
+
description: "Allow error variable to be explicitly typed as `any`.",
|
|
1609
|
+
default: false
|
|
1567
1610
|
}
|
|
1568
1611
|
},
|
|
1569
1612
|
type: "object"
|
|
@@ -1588,41 +1631,43 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1588
1631
|
const {
|
|
1589
1632
|
typeAnnotation: { type }
|
|
1590
1633
|
} = typeAnnotation;
|
|
1591
|
-
if (type ===
|
|
1592
|
-
let
|
|
1634
|
+
if (type === _utils.AST_NODE_TYPES.TSAnyKeyword) {
|
|
1635
|
+
let fix2 = function(fixer) {
|
|
1593
1636
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1594
1637
|
};
|
|
1638
|
+
var fix = fix2;
|
|
1595
1639
|
if (allowExplicitAny) {
|
|
1596
1640
|
return;
|
|
1597
1641
|
}
|
|
1598
1642
|
context.report({
|
|
1599
|
-
fix,
|
|
1643
|
+
fix: fix2,
|
|
1600
1644
|
messageId: "explicitAny",
|
|
1601
1645
|
node: param,
|
|
1602
1646
|
suggest: [
|
|
1603
1647
|
{
|
|
1604
1648
|
messageId: "suggestExplicitUnknown",
|
|
1605
|
-
fix
|
|
1649
|
+
fix: fix2
|
|
1606
1650
|
}
|
|
1607
1651
|
]
|
|
1608
1652
|
});
|
|
1609
|
-
} else if (type !==
|
|
1610
|
-
let
|
|
1653
|
+
} else if (type !== _utils.AST_NODE_TYPES.TSUnknownKeyword) {
|
|
1654
|
+
let fix2 = function(fixer) {
|
|
1611
1655
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1612
1656
|
};
|
|
1657
|
+
var fix = fix2;
|
|
1613
1658
|
context.report({
|
|
1614
1659
|
messageId: "narrowed",
|
|
1615
1660
|
node: param,
|
|
1616
1661
|
suggest: [
|
|
1617
1662
|
{
|
|
1618
1663
|
messageId: "suggestExplicitUnknown",
|
|
1619
|
-
fix
|
|
1664
|
+
fix: fix2
|
|
1620
1665
|
}
|
|
1621
1666
|
]
|
|
1622
1667
|
});
|
|
1623
1668
|
}
|
|
1624
1669
|
} else {
|
|
1625
|
-
let
|
|
1670
|
+
let fix2 = function(fixer) {
|
|
1626
1671
|
if (isParenthesised(sourceCode, param)) {
|
|
1627
1672
|
return fixer.insertTextAfter(param, ": unknown");
|
|
1628
1673
|
}
|
|
@@ -1631,14 +1676,15 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1631
1676
|
fixer.insertTextAfter(param, ": unknown)")
|
|
1632
1677
|
];
|
|
1633
1678
|
};
|
|
1679
|
+
var fix = fix2;
|
|
1634
1680
|
context.report({
|
|
1635
|
-
fix,
|
|
1681
|
+
fix: fix2,
|
|
1636
1682
|
messageId: "implicitAny",
|
|
1637
1683
|
node: param,
|
|
1638
1684
|
suggest: [
|
|
1639
1685
|
{
|
|
1640
1686
|
messageId: "suggestExplicitUnknown",
|
|
1641
|
-
fix
|
|
1687
|
+
fix: fix2
|
|
1642
1688
|
}
|
|
1643
1689
|
]
|
|
1644
1690
|
});
|
|
@@ -1674,11 +1720,12 @@ const noImplicitAnyCatchRule = ruleCreator({
|
|
|
1674
1720
|
}
|
|
1675
1721
|
});
|
|
1676
1722
|
|
|
1677
|
-
|
|
1723
|
+
// src/rules/no-index.ts
|
|
1724
|
+
var noIndexRule = ruleCreator({
|
|
1678
1725
|
defaultOptions: [],
|
|
1679
1726
|
meta: {
|
|
1680
1727
|
docs: {
|
|
1681
|
-
description: "
|
|
1728
|
+
description: "Disallow importing index modules.",
|
|
1682
1729
|
recommended: true
|
|
1683
1730
|
},
|
|
1684
1731
|
messages: {
|
|
@@ -1700,11 +1747,12 @@ const noIndexRule = ruleCreator({
|
|
|
1700
1747
|
}
|
|
1701
1748
|
});
|
|
1702
1749
|
|
|
1703
|
-
|
|
1750
|
+
// src/rules/no-internal.ts
|
|
1751
|
+
var noInternalRule = ruleCreator({
|
|
1704
1752
|
defaultOptions: [],
|
|
1705
1753
|
meta: {
|
|
1706
1754
|
docs: {
|
|
1707
|
-
description: "
|
|
1755
|
+
description: "Disallow importing internal modules.",
|
|
1708
1756
|
recommended: true
|
|
1709
1757
|
},
|
|
1710
1758
|
fixable: "code",
|
|
@@ -1754,14 +1802,15 @@ const noInternalRule = ruleCreator({
|
|
|
1754
1802
|
[String.raw`ImportDeclaration Literal[value=/^rxjs\u002finternal/]`]: (node) => {
|
|
1755
1803
|
const replacement = getReplacement(node.raw);
|
|
1756
1804
|
if (replacement) {
|
|
1757
|
-
let
|
|
1805
|
+
let fix2 = function(fixer) {
|
|
1758
1806
|
return fixer.replaceText(node, replacement);
|
|
1759
1807
|
};
|
|
1808
|
+
var fix = fix2;
|
|
1760
1809
|
context.report({
|
|
1761
|
-
fix,
|
|
1810
|
+
fix: fix2,
|
|
1762
1811
|
messageId: "forbidden",
|
|
1763
1812
|
node,
|
|
1764
|
-
suggest: [{ fix, messageId: "suggest" }]
|
|
1813
|
+
suggest: [{ fix: fix2, messageId: "suggest" }]
|
|
1765
1814
|
});
|
|
1766
1815
|
} else {
|
|
1767
1816
|
context.report({
|
|
@@ -1774,11 +1823,12 @@ const noInternalRule = ruleCreator({
|
|
|
1774
1823
|
}
|
|
1775
1824
|
});
|
|
1776
1825
|
|
|
1777
|
-
|
|
1826
|
+
// src/rules/no-nested-subscribe.ts
|
|
1827
|
+
var noNestedSubscribeRule = ruleCreator({
|
|
1778
1828
|
defaultOptions: [],
|
|
1779
1829
|
meta: {
|
|
1780
1830
|
docs: {
|
|
1781
|
-
description: "
|
|
1831
|
+
description: "Disallow calling `subscribe` within a `subscribe` callback.",
|
|
1782
1832
|
recommended: true,
|
|
1783
1833
|
requiresTypeChecking: true
|
|
1784
1834
|
},
|
|
@@ -1790,11 +1840,11 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1790
1840
|
},
|
|
1791
1841
|
name: "no-nested-subscribe",
|
|
1792
1842
|
create: (context) => {
|
|
1793
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
1843
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1794
1844
|
const argumentsMap = /* @__PURE__ */ new WeakMap();
|
|
1795
1845
|
return {
|
|
1796
1846
|
[`CallExpression > MemberExpression[property.name='subscribe']`]: (node) => {
|
|
1797
|
-
if (!couldBeObservable(node.object) && !
|
|
1847
|
+
if (!couldBeObservable(node.object) && !couldBeType2(node.object, "Subscribable")) {
|
|
1798
1848
|
return;
|
|
1799
1849
|
}
|
|
1800
1850
|
const callExpression = node.parent;
|
|
@@ -1817,11 +1867,12 @@ const noNestedSubscribeRule = ruleCreator({
|
|
|
1817
1867
|
}
|
|
1818
1868
|
});
|
|
1819
1869
|
|
|
1820
|
-
|
|
1870
|
+
// src/rules/no-redundant-notify.ts
|
|
1871
|
+
var noRedundantNotifyRule = ruleCreator({
|
|
1821
1872
|
defaultOptions: [],
|
|
1822
1873
|
meta: {
|
|
1823
1874
|
docs: {
|
|
1824
|
-
description: "
|
|
1875
|
+
description: "Disallow sending redundant notifications from completed or errored observables.",
|
|
1825
1876
|
recommended: true,
|
|
1826
1877
|
requiresTypeChecking: true
|
|
1827
1878
|
},
|
|
@@ -1834,7 +1885,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1834
1885
|
name: "no-redundant-notify",
|
|
1835
1886
|
create: (context) => {
|
|
1836
1887
|
const sourceCode = context.sourceCode;
|
|
1837
|
-
const { couldBeType } = getTypeServices(context);
|
|
1888
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1838
1889
|
return {
|
|
1839
1890
|
"ExpressionStatement[expression.callee.property.name=/^(complete|error)$/] + ExpressionStatement[expression.callee.property.name=/^(next|complete|error)$/]": (node) => {
|
|
1840
1891
|
const parent = node.parent;
|
|
@@ -1850,7 +1901,7 @@ const noRedundantNotifyRule = ruleCreator({
|
|
|
1850
1901
|
if (getExpressionText(sibling, sourceCode) !== getExpressionText(node, sourceCode)) {
|
|
1851
1902
|
return;
|
|
1852
1903
|
}
|
|
1853
|
-
if (!isExpressionObserver(sibling,
|
|
1904
|
+
if (!isExpressionObserver(sibling, couldBeType2) || !isExpressionObserver(node, couldBeType2)) {
|
|
1854
1905
|
return;
|
|
1855
1906
|
}
|
|
1856
1907
|
const { expression } = node;
|
|
@@ -1881,7 +1932,7 @@ function getExpressionText(expressionStatement, sourceCode) {
|
|
|
1881
1932
|
const { object } = callExpression.callee;
|
|
1882
1933
|
return sourceCode.getText(object);
|
|
1883
1934
|
}
|
|
1884
|
-
function isExpressionObserver(expressionStatement,
|
|
1935
|
+
function isExpressionObserver(expressionStatement, couldBeType2) {
|
|
1885
1936
|
if (!isCallExpression(expressionStatement.expression)) {
|
|
1886
1937
|
return false;
|
|
1887
1938
|
}
|
|
@@ -1890,15 +1941,17 @@ function isExpressionObserver(expressionStatement, couldBeType) {
|
|
|
1890
1941
|
return false;
|
|
1891
1942
|
}
|
|
1892
1943
|
const { object } = callExpression.callee;
|
|
1893
|
-
return
|
|
1944
|
+
return couldBeType2(object, /^(Subject|Subscriber)$/);
|
|
1894
1945
|
}
|
|
1895
1946
|
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1947
|
+
// src/rules/no-sharereplay.ts
|
|
1948
|
+
|
|
1949
|
+
var defaultOptions7 = [];
|
|
1950
|
+
var noSharereplayRule = ruleCreator({
|
|
1951
|
+
defaultOptions: defaultOptions7,
|
|
1899
1952
|
meta: {
|
|
1900
1953
|
docs: {
|
|
1901
|
-
description: "
|
|
1954
|
+
description: "Disallow unsafe `shareReplay` usage.",
|
|
1902
1955
|
recommended: true
|
|
1903
1956
|
},
|
|
1904
1957
|
messages: {
|
|
@@ -1908,7 +1961,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1908
1961
|
schema: [
|
|
1909
1962
|
{
|
|
1910
1963
|
properties: {
|
|
1911
|
-
allowConfig: { type: "boolean" }
|
|
1964
|
+
allowConfig: { type: "boolean", description: "Allow shareReplay if a config argument is specified.", default: true }
|
|
1912
1965
|
},
|
|
1913
1966
|
type: "object"
|
|
1914
1967
|
}
|
|
@@ -1923,7 +1976,7 @@ const noSharereplayRule = ruleCreator({
|
|
|
1923
1976
|
"CallExpression[callee.name='shareReplay']": (node) => {
|
|
1924
1977
|
let report = true;
|
|
1925
1978
|
if (allowConfig) {
|
|
1926
|
-
report = node.arguments.length !== 1 || node.arguments[0].type !==
|
|
1979
|
+
report = node.arguments.length !== 1 || node.arguments[0].type !== _utils.AST_NODE_TYPES.ObjectExpression;
|
|
1927
1980
|
}
|
|
1928
1981
|
if (report) {
|
|
1929
1982
|
context.report({
|
|
@@ -1936,11 +1989,12 @@ const noSharereplayRule = ruleCreator({
|
|
|
1936
1989
|
}
|
|
1937
1990
|
});
|
|
1938
1991
|
|
|
1939
|
-
|
|
1992
|
+
// src/rules/no-subclass.ts
|
|
1993
|
+
var noSubclassRule = ruleCreator({
|
|
1940
1994
|
defaultOptions: [],
|
|
1941
1995
|
meta: {
|
|
1942
1996
|
docs: {
|
|
1943
|
-
description: "
|
|
1997
|
+
description: "Disallow subclassing RxJS classes.",
|
|
1944
1998
|
requiresTypeChecking: true
|
|
1945
1999
|
},
|
|
1946
2000
|
messages: {
|
|
@@ -1951,7 +2005,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1951
2005
|
},
|
|
1952
2006
|
name: "no-subclass",
|
|
1953
2007
|
create: (context) => {
|
|
1954
|
-
const { couldBeType } = getTypeServices(context);
|
|
2008
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1955
2009
|
const queryNames = [
|
|
1956
2010
|
"AsyncSubject",
|
|
1957
2011
|
"BehaviorSubject",
|
|
@@ -1966,7 +2020,7 @@ const noSubclassRule = ruleCreator({
|
|
|
1966
2020
|
"|"
|
|
1967
2021
|
)})$/] > Identifier.superClass`]: (node) => {
|
|
1968
2022
|
if (queryNames.some(
|
|
1969
|
-
(
|
|
2023
|
+
(name2) => couldBeType2(node, name2, { name: /[/\\]rxjs[/\\]/ })
|
|
1970
2024
|
)) {
|
|
1971
2025
|
context.report({
|
|
1972
2026
|
messageId: "forbidden",
|
|
@@ -1978,11 +2032,12 @@ const noSubclassRule = ruleCreator({
|
|
|
1978
2032
|
}
|
|
1979
2033
|
});
|
|
1980
2034
|
|
|
1981
|
-
|
|
2035
|
+
// src/rules/no-subject-unsubscribe.ts
|
|
2036
|
+
var noSubjectUnsubscribeRule = ruleCreator({
|
|
1982
2037
|
defaultOptions: [],
|
|
1983
2038
|
meta: {
|
|
1984
2039
|
docs: {
|
|
1985
|
-
description: "
|
|
2040
|
+
description: "Disallow calling the `unsubscribe` method of subjects.",
|
|
1986
2041
|
recommended: true,
|
|
1987
2042
|
requiresTypeChecking: true
|
|
1988
2043
|
},
|
|
@@ -2020,11 +2075,12 @@ const noSubjectUnsubscribeRule = ruleCreator({
|
|
|
2020
2075
|
}
|
|
2021
2076
|
});
|
|
2022
2077
|
|
|
2023
|
-
|
|
2078
|
+
// src/rules/no-subject-value.ts
|
|
2079
|
+
var noSubjectValueRule = ruleCreator({
|
|
2024
2080
|
defaultOptions: [],
|
|
2025
2081
|
meta: {
|
|
2026
2082
|
docs: {
|
|
2027
|
-
description: "
|
|
2083
|
+
description: "Disallow accessing the `value` property of a `BehaviorSubject` instance.",
|
|
2028
2084
|
requiresTypeChecking: true
|
|
2029
2085
|
},
|
|
2030
2086
|
messages: {
|
|
@@ -2053,11 +2109,12 @@ const noSubjectValueRule = ruleCreator({
|
|
|
2053
2109
|
}
|
|
2054
2110
|
});
|
|
2055
2111
|
|
|
2056
|
-
|
|
2112
|
+
// src/rules/no-subscribe-handlers.ts
|
|
2113
|
+
var noSubscribeHandlersRule = ruleCreator({
|
|
2057
2114
|
defaultOptions: [],
|
|
2058
2115
|
meta: {
|
|
2059
2116
|
docs: {
|
|
2060
|
-
description: "
|
|
2117
|
+
description: "Disallow passing handlers to `subscribe`.",
|
|
2061
2118
|
requiresTypeChecking: true
|
|
2062
2119
|
},
|
|
2063
2120
|
messages: {
|
|
@@ -2068,11 +2125,11 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2068
2125
|
},
|
|
2069
2126
|
name: "no-subscribe-handlers",
|
|
2070
2127
|
create: (context) => {
|
|
2071
|
-
const { couldBeObservable, couldBeType } = getTypeServices(context);
|
|
2128
|
+
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2072
2129
|
return {
|
|
2073
2130
|
"CallExpression[arguments.length > 0][callee.property.name='subscribe']": (node) => {
|
|
2074
2131
|
const callee = node.callee;
|
|
2075
|
-
if (couldBeObservable(callee.object) ||
|
|
2132
|
+
if (couldBeObservable(callee.object) || couldBeType2(callee.object, "Subscribable")) {
|
|
2076
2133
|
context.report({
|
|
2077
2134
|
messageId: "forbidden",
|
|
2078
2135
|
node: callee.property
|
|
@@ -2083,12 +2140,13 @@ const noSubscribeHandlersRule = ruleCreator({
|
|
|
2083
2140
|
}
|
|
2084
2141
|
});
|
|
2085
2142
|
|
|
2086
|
-
|
|
2143
|
+
// src/rules/no-tap.ts
|
|
2144
|
+
var noTapRule = ruleCreator({
|
|
2087
2145
|
defaultOptions: [],
|
|
2088
2146
|
meta: {
|
|
2089
2147
|
deprecated: true,
|
|
2090
2148
|
docs: {
|
|
2091
|
-
description: "
|
|
2149
|
+
description: "Disallow the `tap` operator."
|
|
2092
2150
|
},
|
|
2093
2151
|
messages: {
|
|
2094
2152
|
forbidden: "The tap operator is forbidden."
|
|
@@ -2117,11 +2175,12 @@ const noTapRule = ruleCreator({
|
|
|
2117
2175
|
}
|
|
2118
2176
|
});
|
|
2119
2177
|
|
|
2120
|
-
|
|
2178
|
+
// src/rules/no-topromise.ts
|
|
2179
|
+
var noTopromiseRule = ruleCreator({
|
|
2121
2180
|
defaultOptions: [],
|
|
2122
2181
|
meta: {
|
|
2123
2182
|
docs: {
|
|
2124
|
-
description: "
|
|
2183
|
+
description: "Disallow use of the `toPromise` method.",
|
|
2125
2184
|
requiresTypeChecking: true
|
|
2126
2185
|
},
|
|
2127
2186
|
messages: {
|
|
@@ -2146,11 +2205,12 @@ const noTopromiseRule = ruleCreator({
|
|
|
2146
2205
|
}
|
|
2147
2206
|
});
|
|
2148
2207
|
|
|
2149
|
-
|
|
2208
|
+
// src/rules/no-unbound-methods.ts
|
|
2209
|
+
var noUnboundMethodsRule = ruleCreator({
|
|
2150
2210
|
defaultOptions: [],
|
|
2151
2211
|
meta: {
|
|
2152
2212
|
docs: {
|
|
2153
|
-
description: "
|
|
2213
|
+
description: "Disallow passing unbound methods.",
|
|
2154
2214
|
recommended: true,
|
|
2155
2215
|
requiresTypeChecking: true
|
|
2156
2216
|
},
|
|
@@ -2207,12 +2267,14 @@ const noUnboundMethodsRule = ruleCreator({
|
|
|
2207
2267
|
}
|
|
2208
2268
|
});
|
|
2209
2269
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2270
|
+
// src/rules/no-unsafe-catch.ts
|
|
2271
|
+
|
|
2272
|
+
var defaultOptions8 = [];
|
|
2273
|
+
var noUnsafeCatchRule = ruleCreator({
|
|
2274
|
+
defaultOptions: defaultOptions8,
|
|
2213
2275
|
meta: {
|
|
2214
2276
|
docs: {
|
|
2215
|
-
description: "
|
|
2277
|
+
description: "Disallow unsafe `catchError` usage in effects and epics.",
|
|
2216
2278
|
requiresTypeChecking: true
|
|
2217
2279
|
},
|
|
2218
2280
|
messages: {
|
|
@@ -2221,10 +2283,10 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2221
2283
|
schema: [
|
|
2222
2284
|
{
|
|
2223
2285
|
properties: {
|
|
2224
|
-
observable: { type: "string" }
|
|
2286
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2225
2287
|
},
|
|
2226
2288
|
type: "object",
|
|
2227
|
-
description:
|
|
2289
|
+
description: _commontags.stripIndent`
|
|
2228
2290
|
An optional object with an optional \`observable\` property.
|
|
2229
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.`
|
|
2230
2292
|
}
|
|
@@ -2266,12 +2328,14 @@ const noUnsafeCatchRule = ruleCreator({
|
|
|
2266
2328
|
}
|
|
2267
2329
|
});
|
|
2268
2330
|
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2331
|
+
// src/rules/no-unsafe-first.ts
|
|
2332
|
+
|
|
2333
|
+
var defaultOptions9 = [];
|
|
2334
|
+
var noUnsafeFirstRule = ruleCreator({
|
|
2335
|
+
defaultOptions: defaultOptions9,
|
|
2272
2336
|
meta: {
|
|
2273
2337
|
docs: {
|
|
2274
|
-
description: "
|
|
2338
|
+
description: "Disallow unsafe `first`/`take` usage in effects and epics.",
|
|
2275
2339
|
requiresTypeChecking: true
|
|
2276
2340
|
},
|
|
2277
2341
|
messages: {
|
|
@@ -2280,10 +2344,10 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2280
2344
|
schema: [
|
|
2281
2345
|
{
|
|
2282
2346
|
properties: {
|
|
2283
|
-
observable: { type: "string" }
|
|
2347
|
+
observable: { type: "string", description: "A RegExp that matches an effect or epic's actions observable.", default: defaultObservable }
|
|
2284
2348
|
},
|
|
2285
2349
|
type: "object",
|
|
2286
|
-
description:
|
|
2350
|
+
description: _commontags.stripIndent`
|
|
2287
2351
|
An optional object with an optional \`observable\` property.
|
|
2288
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.`
|
|
2289
2353
|
}
|
|
@@ -2334,11 +2398,14 @@ const noUnsafeFirstRule = ruleCreator({
|
|
|
2334
2398
|
}
|
|
2335
2399
|
});
|
|
2336
2400
|
|
|
2337
|
-
|
|
2401
|
+
// src/rules/no-unsafe-subject-next.ts
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
var noUnsafeSubjectNext = ruleCreator({
|
|
2338
2405
|
defaultOptions: [],
|
|
2339
2406
|
meta: {
|
|
2340
2407
|
docs: {
|
|
2341
|
-
description: "
|
|
2408
|
+
description: "Disallow unsafe optional `next` calls.",
|
|
2342
2409
|
recommended: true,
|
|
2343
2410
|
requiresTypeChecking: true
|
|
2344
2411
|
},
|
|
@@ -2355,19 +2422,19 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2355
2422
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
2356
2423
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
2357
2424
|
const type = getType(node.callee.object);
|
|
2358
|
-
if (
|
|
2425
|
+
if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
2359
2426
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
2360
|
-
if (
|
|
2427
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
|
|
2361
2428
|
return;
|
|
2362
2429
|
}
|
|
2363
|
-
if (
|
|
2430
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
|
|
2364
2431
|
return;
|
|
2365
2432
|
}
|
|
2366
|
-
if (
|
|
2433
|
+
if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
|
|
2367
2434
|
return;
|
|
2368
2435
|
}
|
|
2369
|
-
if (
|
|
2370
|
-
(t) =>
|
|
2436
|
+
if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
|
|
2437
|
+
(t) => tsutils3.isTypeFlagSet(t, ts6.TypeFlags.Void)
|
|
2371
2438
|
)) {
|
|
2372
2439
|
return;
|
|
2373
2440
|
}
|
|
@@ -2382,12 +2449,15 @@ const noUnsafeSubjectNext = ruleCreator({
|
|
|
2382
2449
|
}
|
|
2383
2450
|
});
|
|
2384
2451
|
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
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,
|
|
2388
2458
|
meta: {
|
|
2389
2459
|
docs: {
|
|
2390
|
-
description: "
|
|
2460
|
+
description: "Disallow unsafe `switchMap` usage in effects and epics.",
|
|
2391
2461
|
requiresTypeChecking: true
|
|
2392
2462
|
},
|
|
2393
2463
|
messages: {
|
|
@@ -2397,26 +2467,27 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2397
2467
|
{
|
|
2398
2468
|
properties: {
|
|
2399
2469
|
allow: {
|
|
2470
|
+
description: "Action types that are allowed to be used with switchMap. Mutually exclusive with `disallow`.",
|
|
2400
2471
|
oneOf: [
|
|
2401
|
-
{ type: "string" },
|
|
2402
|
-
{ type: "array", items: { type: "string" } }
|
|
2472
|
+
{ type: "string", description: "A regular expression string." },
|
|
2473
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2403
2474
|
]
|
|
2404
2475
|
},
|
|
2405
2476
|
disallow: {
|
|
2477
|
+
description: "Action types that are disallowed to be used with switchMap. Mutually exclusive with `allow`.",
|
|
2406
2478
|
oneOf: [
|
|
2407
|
-
{ type: "string" },
|
|
2408
|
-
{ type: "array", items: { type: "string" } }
|
|
2479
|
+
{ type: "string", description: "A regular expression string." },
|
|
2480
|
+
{ type: "array", items: { type: "string" }, description: "An array of words." }
|
|
2409
2481
|
]
|
|
2410
2482
|
},
|
|
2411
2483
|
observable: {
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
]
|
|
2484
|
+
type: "string",
|
|
2485
|
+
description: "A RegExp that matches an effect or epic's actions observable.",
|
|
2486
|
+
default: defaultObservable
|
|
2416
2487
|
}
|
|
2417
2488
|
},
|
|
2418
2489
|
type: "object",
|
|
2419
|
-
description:
|
|
2490
|
+
description: _commontags.stripIndent`
|
|
2420
2491
|
An optional object with optional \`allow\`, \`disallow\` and \`observable\` properties.
|
|
2421
2492
|
The properties can be specified as regular expression strings or as arrays of words.
|
|
2422
2493
|
The \`allow\` or \`disallow\` properties are mutually exclusive. Whether or not
|
|
@@ -2429,6 +2500,7 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2429
2500
|
},
|
|
2430
2501
|
name: "no-unsafe-switchmap",
|
|
2431
2502
|
create: (context) => {
|
|
2503
|
+
var _a, _b, _c;
|
|
2432
2504
|
const defaultDisallow = [
|
|
2433
2505
|
"add",
|
|
2434
2506
|
"create",
|
|
@@ -2444,9 +2516,9 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2444
2516
|
let observableRegExp;
|
|
2445
2517
|
const [config = {}] = context.options;
|
|
2446
2518
|
if (config.allow || config.disallow) {
|
|
2447
|
-
allowRegExp = createRegExpForWords(config.allow
|
|
2448
|
-
disallowRegExp = createRegExpForWords(config.disallow
|
|
2449
|
-
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);
|
|
2450
2522
|
} else {
|
|
2451
2523
|
allowRegExp = void 0;
|
|
2452
2524
|
disallowRegExp = createRegExpForWords(defaultDisallow);
|
|
@@ -2465,12 +2537,12 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2465
2537
|
return arg.property.name;
|
|
2466
2538
|
}
|
|
2467
2539
|
return "";
|
|
2468
|
-
}).map((
|
|
2540
|
+
}).map((name2) => _decamelize2.default.call(void 0, name2));
|
|
2469
2541
|
if (allowRegExp) {
|
|
2470
|
-
return !names.every((
|
|
2542
|
+
return !names.every((name2) => allowRegExp == null ? void 0 : allowRegExp.test(name2));
|
|
2471
2543
|
}
|
|
2472
2544
|
if (disallowRegExp) {
|
|
2473
|
-
return names.some((
|
|
2545
|
+
return names.some((name2) => disallowRegExp == null ? void 0 : disallowRegExp.test(name2));
|
|
2474
2546
|
}
|
|
2475
2547
|
return false;
|
|
2476
2548
|
}
|
|
@@ -2503,12 +2575,37 @@ const noUnsafeSwitchmapRule = ruleCreator({
|
|
|
2503
2575
|
}
|
|
2504
2576
|
});
|
|
2505
2577
|
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
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,
|
|
2509
2606
|
meta: {
|
|
2510
2607
|
docs: {
|
|
2511
|
-
description: "
|
|
2608
|
+
description: "Disallow applying operators after `takeUntil`.",
|
|
2512
2609
|
recommended: true,
|
|
2513
2610
|
requiresTypeChecking: true
|
|
2514
2611
|
},
|
|
@@ -2518,11 +2615,11 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2518
2615
|
schema: [
|
|
2519
2616
|
{
|
|
2520
2617
|
properties: {
|
|
2521
|
-
alias: { type: "array", items: { type: "string" } },
|
|
2522
|
-
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 }
|
|
2523
2620
|
},
|
|
2524
2621
|
type: "object",
|
|
2525
|
-
description:
|
|
2622
|
+
description: _commontags.stripIndent`
|
|
2526
2623
|
An optional object with optional \`alias\` and \`allow\` properties.
|
|
2527
2624
|
The \`alias\` property is an array containing the names of operators that aliases for \`takeUntil\`.
|
|
2528
2625
|
The \`allow\` property is an array containing the names of the operators that are allowed to follow \`takeUntil\`.`
|
|
@@ -2533,29 +2630,6 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2533
2630
|
name: "no-unsafe-takeuntil",
|
|
2534
2631
|
create: (context) => {
|
|
2535
2632
|
let checkedOperatorsRegExp = /^takeUntil$/;
|
|
2536
|
-
const allowedOperators = [
|
|
2537
|
-
"count",
|
|
2538
|
-
"defaultIfEmpty",
|
|
2539
|
-
"endWith",
|
|
2540
|
-
"every",
|
|
2541
|
-
"finalize",
|
|
2542
|
-
"finally",
|
|
2543
|
-
"isEmpty",
|
|
2544
|
-
"last",
|
|
2545
|
-
"max",
|
|
2546
|
-
"min",
|
|
2547
|
-
"publish",
|
|
2548
|
-
"publishBehavior",
|
|
2549
|
-
"publishLast",
|
|
2550
|
-
"publishReplay",
|
|
2551
|
-
"reduce",
|
|
2552
|
-
"share",
|
|
2553
|
-
"shareReplay",
|
|
2554
|
-
"skipLast",
|
|
2555
|
-
"takeLast",
|
|
2556
|
-
"throwIfEmpty",
|
|
2557
|
-
"toArray"
|
|
2558
|
-
];
|
|
2559
2633
|
const [config = {}] = context.options;
|
|
2560
2634
|
const { alias, allow = allowedOperators } = config;
|
|
2561
2635
|
if (alias) {
|
|
@@ -2606,12 +2680,13 @@ const noUnsafeTakeuntilRule = ruleCreator({
|
|
|
2606
2680
|
}
|
|
2607
2681
|
});
|
|
2608
2682
|
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2683
|
+
// src/rules/prefer-observer.ts
|
|
2684
|
+
var defaultOptions12 = [];
|
|
2685
|
+
var preferObserverRule = ruleCreator({
|
|
2686
|
+
defaultOptions: defaultOptions12,
|
|
2612
2687
|
meta: {
|
|
2613
2688
|
docs: {
|
|
2614
|
-
description: "
|
|
2689
|
+
description: "Disallow passing separate handlers to `subscribe` and `tap`.",
|
|
2615
2690
|
requiresTypeChecking: true
|
|
2616
2691
|
},
|
|
2617
2692
|
fixable: "code",
|
|
@@ -2622,7 +2697,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2622
2697
|
schema: [
|
|
2623
2698
|
{
|
|
2624
2699
|
properties: {
|
|
2625
|
-
allowNext: { type: "boolean" }
|
|
2700
|
+
allowNext: { type: "boolean", description: "Allows a single `next` callback.", default: true }
|
|
2626
2701
|
},
|
|
2627
2702
|
type: "object"
|
|
2628
2703
|
}
|
|
@@ -2631,7 +2706,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2631
2706
|
},
|
|
2632
2707
|
name: "prefer-observer",
|
|
2633
2708
|
create: (context) => {
|
|
2634
|
-
const { couldBeFunction, couldBeObservable } = getTypeServices(context);
|
|
2709
|
+
const { couldBeFunction: couldBeFunction2, couldBeObservable } = getTypeServices(context);
|
|
2635
2710
|
const [config = {}] = context.options;
|
|
2636
2711
|
const { allowNext = true } = config;
|
|
2637
2712
|
function checkArgs(callExpression, reportNode) {
|
|
@@ -2675,7 +2750,7 @@ const preferObserverRule = ruleCreator({
|
|
|
2675
2750
|
});
|
|
2676
2751
|
} else if (args.length === 1 && !allowNext) {
|
|
2677
2752
|
const [arg] = args;
|
|
2678
|
-
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) ||
|
|
2753
|
+
if (isArrowFunctionExpression(arg) || isFunctionExpression(arg) || couldBeFunction2(arg)) {
|
|
2679
2754
|
context.report({
|
|
2680
2755
|
messageId: "forbidden",
|
|
2681
2756
|
node: reportNode,
|
|
@@ -2704,12 +2779,14 @@ function isValidArgText(argText) {
|
|
|
2704
2779
|
return argText && argText !== "undefined" && argText !== "null";
|
|
2705
2780
|
}
|
|
2706
2781
|
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2782
|
+
// src/rules/suffix-subjects.ts
|
|
2783
|
+
|
|
2784
|
+
var defaultOptions13 = [];
|
|
2785
|
+
var suffixSubjectsRule = ruleCreator({
|
|
2786
|
+
defaultOptions: defaultOptions13,
|
|
2710
2787
|
meta: {
|
|
2711
2788
|
docs: {
|
|
2712
|
-
description: "
|
|
2789
|
+
description: "Enforce the use of a suffix in subject identifiers.",
|
|
2713
2790
|
requiresTypeChecking: true
|
|
2714
2791
|
},
|
|
2715
2792
|
messages: {
|
|
@@ -2718,11 +2795,11 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2718
2795
|
schema: [
|
|
2719
2796
|
{
|
|
2720
2797
|
properties: {
|
|
2721
|
-
parameters: { type: "boolean" },
|
|
2722
|
-
properties: { type: "boolean" },
|
|
2723
|
-
suffix: { type: "string" },
|
|
2724
|
-
types: { type: "object" },
|
|
2725
|
-
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." }
|
|
2726
2803
|
},
|
|
2727
2804
|
type: "object"
|
|
2728
2805
|
}
|
|
@@ -2731,8 +2808,8 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2731
2808
|
},
|
|
2732
2809
|
name: "suffix-subjects",
|
|
2733
2810
|
create: (context) => {
|
|
2734
|
-
const { esTreeNodeToTSNodeMap } =
|
|
2735
|
-
const { couldBeType } = getTypeServices(context);
|
|
2811
|
+
const { esTreeNodeToTSNodeMap } = _utils.ESLintUtils.getParserServices(context);
|
|
2812
|
+
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
2736
2813
|
const [config = {}] = context.options;
|
|
2737
2814
|
const validate = {
|
|
2738
2815
|
parameters: true,
|
|
@@ -2761,10 +2838,10 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2761
2838
|
function checkNode(nameNode, typeNode) {
|
|
2762
2839
|
const tsNode = esTreeNodeToTSNodeMap.get(nameNode);
|
|
2763
2840
|
const text = tsNode.getText();
|
|
2764
|
-
if (!suffixRegex.test(text) &&
|
|
2841
|
+
if (!suffixRegex.test(text) && couldBeType2(typeNode != null ? typeNode : nameNode, "Subject")) {
|
|
2765
2842
|
for (const type of types) {
|
|
2766
2843
|
const { regExp, validate: validate2 } = type;
|
|
2767
|
-
if (
|
|
2844
|
+
if (couldBeType2(typeNode != null ? typeNode : nameNode, regExp) && !validate2) {
|
|
2768
2845
|
return;
|
|
2769
2846
|
}
|
|
2770
2847
|
}
|
|
@@ -2787,7 +2864,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2787
2864
|
if (!found) {
|
|
2788
2865
|
return;
|
|
2789
2866
|
}
|
|
2790
|
-
if (!validate.variables && found.type ===
|
|
2867
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
2791
2868
|
return;
|
|
2792
2869
|
}
|
|
2793
2870
|
if (!validate.parameters) {
|
|
@@ -2854,7 +2931,7 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2854
2931
|
if (!found) {
|
|
2855
2932
|
return;
|
|
2856
2933
|
}
|
|
2857
|
-
if (!validate.variables && found.type ===
|
|
2934
|
+
if (!validate.variables && found.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
|
|
2858
2935
|
return;
|
|
2859
2936
|
}
|
|
2860
2937
|
if (!validate.parameters) {
|
|
@@ -2900,11 +2977,14 @@ const suffixSubjectsRule = ruleCreator({
|
|
|
2900
2977
|
}
|
|
2901
2978
|
});
|
|
2902
2979
|
|
|
2903
|
-
|
|
2980
|
+
// src/rules/throw-error.ts
|
|
2981
|
+
|
|
2982
|
+
|
|
2983
|
+
var throwErrorRule = ruleCreator({
|
|
2904
2984
|
defaultOptions: [],
|
|
2905
2985
|
meta: {
|
|
2906
2986
|
docs: {
|
|
2907
|
-
description: "
|
|
2987
|
+
description: "Enforce passing only `Error` values to error notifications.",
|
|
2908
2988
|
requiresTypeChecking: true
|
|
2909
2989
|
},
|
|
2910
2990
|
messages: {
|
|
@@ -2915,7 +2995,7 @@ const throwErrorRule = ruleCreator({
|
|
|
2915
2995
|
},
|
|
2916
2996
|
name: "throw-error",
|
|
2917
2997
|
create: (context) => {
|
|
2918
|
-
const { esTreeNodeToTSNodeMap, program } =
|
|
2998
|
+
const { esTreeNodeToTSNodeMap, program } = _utils.ESLintUtils.getParserServices(context);
|
|
2919
2999
|
const { couldBeObservable, getType } = getTypeServices(context);
|
|
2920
3000
|
function checkNode(node) {
|
|
2921
3001
|
let type = getType(node);
|
|
@@ -2923,9 +3003,9 @@ const throwErrorRule = ruleCreator({
|
|
|
2923
3003
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
2924
3004
|
const annotation = tsNode.type;
|
|
2925
3005
|
const body = tsNode.body;
|
|
2926
|
-
type = program.getTypeChecker().getTypeAtLocation(annotation
|
|
3006
|
+
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
2927
3007
|
}
|
|
2928
|
-
if (!
|
|
3008
|
+
if (!tsutils4.isIntrinsicAnyType(type) && !tsutils4.isIntrinsicUnknownType(type) && !couldBeType(type, /^(Error|DOMException)$/)) {
|
|
2929
3009
|
context.report({
|
|
2930
3010
|
messageId: "forbidden",
|
|
2931
3011
|
node
|
|
@@ -2946,7 +3026,8 @@ const throwErrorRule = ruleCreator({
|
|
|
2946
3026
|
}
|
|
2947
3027
|
});
|
|
2948
3028
|
|
|
2949
|
-
|
|
3029
|
+
// src/index.ts
|
|
3030
|
+
var plugin = {
|
|
2950
3031
|
meta: { name, version },
|
|
2951
3032
|
rules: {
|
|
2952
3033
|
"ban-observables": banObservablesRule,
|
|
@@ -2992,11 +3073,15 @@ const plugin = {
|
|
|
2992
3073
|
"throw-error": throwErrorRule
|
|
2993
3074
|
}
|
|
2994
3075
|
};
|
|
2995
|
-
|
|
3076
|
+
var rxjsX = {
|
|
2996
3077
|
...plugin,
|
|
2997
3078
|
configs: {
|
|
2998
3079
|
recommended: createRecommendedConfig(plugin)
|
|
2999
3080
|
}
|
|
3000
3081
|
};
|
|
3082
|
+
var src_default = rxjsX;
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
exports.default = src_default;
|
|
3001
3086
|
|
|
3002
|
-
exports
|
|
3087
|
+
module.exports = exports.default;
|