1
1
'use strict' ;
2
2
3
+ /**
4
+ * Trivial helpers in this file that only check a node's existence and/or type are deprecated in favor of inlining that check.
5
+ * We don't need a function for every type of node.
6
+ * And as written, these functions won't correctly narrow the type of the node, which we would need if we incorporate TypeScript: https://github.com/ember-cli/eslint-plugin-ember/issues/1613
7
+ * TODO: we should inline these trivial checks and only check for node existence when it's actually a possibility a node might not exist.
8
+ */
9
+
3
10
module . exports = {
4
11
isAnyFunctionExpression,
5
12
isArrayExpression,
@@ -56,6 +63,7 @@ function isAnyFunctionExpression(node) {
56
63
*
57
64
* @param {Object } node The node to check.
58
65
* @returns {boolean } Whether or not the node is an ArrayExpression.
66
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
59
67
*/
60
68
function isArrayExpression ( node ) {
61
69
return node !== undefined && node . type === 'ArrayExpression' ;
@@ -66,6 +74,7 @@ function isArrayExpression(node) {
66
74
*
67
75
* @param {Object } node The node to check.
68
76
* @returns {boolean } Whether or not the node is an ArrowFunctionExpression.
77
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
69
78
*/
70
79
function isArrowFunctionExpression ( node ) {
71
80
return node !== undefined && node . type === 'ArrowFunctionExpression' ;
@@ -76,6 +85,7 @@ function isArrowFunctionExpression(node) {
76
85
*
77
86
* @param {Object } node The node to check.
78
87
* @returns {boolean } Whether or not the node is an AssignmentExpression.
88
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
79
89
*/
80
90
function isAssignmentExpression ( node ) {
81
91
return node . type === 'AssignmentExpression' ;
@@ -86,6 +96,7 @@ function isAssignmentExpression(node) {
86
96
*
87
97
* @param {Object } node The node to check.
88
98
* @returns {boolean } Whether or not the node is an BinaryExpression.
99
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
89
100
*/
90
101
function isBinaryExpression ( node ) {
91
102
return node !== undefined && node . type === 'BinaryExpression' ;
@@ -96,6 +107,7 @@ function isBinaryExpression(node) {
96
107
*
97
108
* @param {Object } node The node to check.
98
109
* @returns {boolean } Whether or not the node is an CallExpression.
110
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
99
111
*/
100
112
function isCallExpression ( node ) {
101
113
return node !== undefined && node . type === 'CallExpression' ;
@@ -125,6 +137,7 @@ function isCallWithFunctionExpression(node) {
125
137
*
126
138
* @param {Object } node The node to check.
127
139
* @returns {boolean } Whether or not the node is a ClassDeclaration.
140
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
128
141
*/
129
142
function isClassDeclaration ( node ) {
130
143
return node !== undefined && node . type === 'ClassDeclaration' ;
@@ -163,6 +176,7 @@ function isConciseArrowFunctionWithCallExpression(node) {
163
176
*
164
177
* @param {Object } node The node to check.
165
178
* @returns {boolean } Whether or not the node is a ConditionalExpression.
179
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
166
180
*/
167
181
function isConditionalExpression ( node ) {
168
182
return node !== undefined && node . type === 'ConditionalExpression' ;
@@ -173,6 +187,7 @@ function isConditionalExpression(node) {
173
187
*
174
188
* @param {Object } node The node to check.
175
189
* @returns {boolean } Whether or not the node is a Decorator.
190
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
176
191
*/
177
192
function isDecorator ( node ) {
178
193
return node !== undefined && node . type === 'Decorator' ;
@@ -183,6 +198,7 @@ function isDecorator(node) {
183
198
*
184
199
* @param {Object } node The node to check.
185
200
* @returns {boolean } Whether or not the node is an ExpressionStatement.
201
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
186
202
*/
187
203
function isExpressionStatement ( node ) {
188
204
return node !== undefined && node . type === 'ExpressionStatement' ;
@@ -193,6 +209,7 @@ function isExpressionStatement(node) {
193
209
*
194
210
* @param {Object } node The node to check.
195
211
* @returns {boolean } Whether or not the node is a FunctionDeclaration
212
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
196
213
*/
197
214
function isFunctionDeclaration ( node ) {
198
215
return node !== undefined && node . type === 'FunctionDeclaration' ;
@@ -203,6 +220,7 @@ function isFunctionDeclaration(node) {
203
220
*
204
221
* @param {Object } node The node to check.
205
222
* @returns {boolean } Whether or not the node is an FunctionExpression.
223
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
206
224
*/
207
225
function isFunctionExpression ( node ) {
208
226
return node !== undefined && node . type === 'FunctionExpression' ;
@@ -213,6 +231,7 @@ function isFunctionExpression(node) {
213
231
*
214
232
* @param {Object } node The node to check.
215
233
* @returns {boolean } Whether or not the node is an Identifier.
234
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
216
235
*/
217
236
function isIdentifier ( node ) {
218
237
return node !== undefined && node . type === 'Identifier' ;
@@ -223,6 +242,7 @@ function isIdentifier(node) {
223
242
*
224
243
* @param {Object } node The node to check.
225
244
* @returns {boolean } Whether or not the node is an ImportDeclaration.
245
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
226
246
*/
227
247
function isImportDeclaration ( node ) {
228
248
return node !== undefined && node . type === 'ImportDeclaration' ;
@@ -233,6 +253,7 @@ function isImportDeclaration(node) {
233
253
*
234
254
* @param {Object } node The node to check.
235
255
* @returns {boolean } Whether or not the node is an ImportDefaultSpecifier.
256
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
236
257
*/
237
258
function isImportDefaultSpecifier ( node ) {
238
259
return node !== undefined && node . type === 'ImportDefaultSpecifier' ;
@@ -243,6 +264,7 @@ function isImportDefaultSpecifier(node) {
243
264
*
244
265
* @param {Object } node The node to check.
245
266
* @returns {boolean } Whether or not the node is an Literal.
267
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
246
268
*/
247
269
function isLiteral ( node ) {
248
270
return node !== undefined && node . type === 'Literal' ;
@@ -253,6 +275,7 @@ function isLiteral(node) {
253
275
*
254
276
* @param {Object } node The node to check.
255
277
* @returns {boolean } Whether or not the node is an LogicalExpression.
278
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
256
279
*/
257
280
function isLogicalExpression ( node ) {
258
281
return node !== undefined && node . type === 'LogicalExpression' ;
@@ -263,6 +286,7 @@ function isLogicalExpression(node) {
263
286
*
264
287
* @param {Object } node The node to check.
265
288
* @return {boolean } Whether or not the node is an MemberExpression.
289
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
266
290
*/
267
291
function isMemberExpression ( node ) {
268
292
return node !== undefined && node . type === 'MemberExpression' ;
@@ -273,6 +297,7 @@ function isMemberExpression(node) {
273
297
*
274
298
* @param {Object } node The node to check.
275
299
* @return {boolean } Whether or not the node is a MethodDefinition.
300
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
276
301
*/
277
302
function isMethodDefinition ( node ) {
278
303
return node !== undefined && node . type === 'MethodDefinition' ;
@@ -283,6 +308,7 @@ function isMethodDefinition(node) {
283
308
*
284
309
* @param {Object } node The node to check.
285
310
* @returns {boolean } Whether or not the node is an NewExpression.
311
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
286
312
*/
287
313
function isNewExpression ( node ) {
288
314
return node !== undefined && node . type === 'NewExpression' ;
@@ -293,6 +319,7 @@ function isNewExpression(node) {
293
319
*
294
320
* @param {Object } node The node to check.
295
321
* @returns {boolean } Whether or not the node is an ObjectExpression.
322
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
296
323
*/
297
324
function isObjectExpression ( node ) {
298
325
return node !== undefined && node . type === 'ObjectExpression' ;
@@ -303,6 +330,7 @@ function isObjectExpression(node) {
303
330
*
304
331
* @param {Object } node The node to check.
305
332
* @returns {boolean } Whether or not the node is an ObjectPattern.
333
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
306
334
*/
307
335
function isObjectPattern ( node ) {
308
336
return node !== undefined && node . type === 'ObjectPattern' ;
@@ -313,6 +341,7 @@ function isObjectPattern(node) {
313
341
*
314
342
* @param {Object } node The node to check.
315
343
* @returns {boolean } Whether or not the node is an OptionalCallExpression.
344
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
316
345
*/
317
346
function isOptionalCallExpression ( node ) {
318
347
return node . type === 'OptionalCallExpression' ;
@@ -323,6 +352,7 @@ function isOptionalCallExpression(node) {
323
352
*
324
353
* @param {Object } node The node to check.
325
354
* @returns {boolean } Whether or not the node is an OptionalMemberExpression.
355
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
326
356
*/
327
357
function isOptionalMemberExpression ( node ) {
328
358
return node . type === 'OptionalMemberExpression' ;
@@ -333,6 +363,7 @@ function isOptionalMemberExpression(node) {
333
363
*
334
364
* @param {Object } node The node to check.
335
365
* @returns {boolean } Whether or not the node is an Property.
366
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
336
367
*/
337
368
function isProperty ( node ) {
338
369
return node !== undefined && node . type === 'Property' ;
@@ -343,6 +374,7 @@ function isProperty(node) {
343
374
*
344
375
* @param {Object } node The node to check.
345
376
* @return {Boolean } Whether or not the node is a ReturnStatement.
377
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
346
378
*/
347
379
function isReturnStatement ( node ) {
348
380
return node !== undefined && node . type && node . type === 'ReturnStatement' ;
@@ -353,6 +385,7 @@ function isReturnStatement(node) {
353
385
*
354
386
* @param {Object } node The node to check.
355
387
* @return {Boolean } Whether or not the node is a SpreadElement.
388
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
356
389
*/
357
390
function isSpreadElement ( node ) {
358
391
return node !== undefined && node . type === 'SpreadElement' ;
@@ -371,6 +404,7 @@ function isStringLiteral(node) {
371
404
*
372
405
* @param {Object } node The node to check.
373
406
* @returns {boolean } Whether or not the node is a TaggedTemplateExpression.
407
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
374
408
*/
375
409
function isTaggedTemplateExpression ( node ) {
376
410
return node !== undefined && node . type === 'TaggedTemplateExpression' ;
@@ -381,6 +415,7 @@ function isTaggedTemplateExpression(node) {
381
415
*
382
416
* @param {Object } node The node to check.
383
417
* @returns {boolean } Whether or not the node is a TemplateLiteral.
418
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
384
419
*/
385
420
function isTemplateLiteral ( node ) {
386
421
return node !== undefined && node . type === 'TemplateLiteral' ;
@@ -391,6 +426,7 @@ function isTemplateLiteral(node) {
391
426
*
392
427
* @param {Object } node The node to check.
393
428
* @returns {boolean } Whether or not the node is an ThisExpression.
429
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
394
430
*/
395
431
function isThisExpression ( node ) {
396
432
return node !== undefined && node . type === 'ThisExpression' ;
@@ -401,6 +437,7 @@ function isThisExpression(node) {
401
437
*
402
438
* @param {Object } node The node to check.
403
439
* @returns {boolean } Whether or not the node is an Literal.
440
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
404
441
*/
405
442
function isUnaryExpression ( node ) {
406
443
return node !== undefined && node . type === 'UnaryExpression' ;
@@ -411,6 +448,7 @@ function isUnaryExpression(node) {
411
448
*
412
449
* @param {Object } node The node to check.
413
450
* @returns {boolean } Whether or not the node is a VariableDeclarator.
451
+ * @deprecated trivial helpers are deprecated in favor of inlining the type check
414
452
*/
415
453
function isVariableDeclarator ( node ) {
416
454
return node !== undefined && node . type === 'VariableDeclarator' ;
0 commit comments