Skip to content

Commit 78cbc5a

Browse files
authored
Deprecate trivial node type check helpers (#1720)
1 parent 96a5111 commit 78cbc5a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/utils/types.js

+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

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+
310
module.exports = {
411
isAnyFunctionExpression,
512
isArrayExpression,
@@ -56,6 +63,7 @@ function isAnyFunctionExpression(node) {
5663
*
5764
* @param {Object} node The node to check.
5865
* @returns {boolean} Whether or not the node is an ArrayExpression.
66+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
5967
*/
6068
function isArrayExpression(node) {
6169
return node !== undefined && node.type === 'ArrayExpression';
@@ -66,6 +74,7 @@ function isArrayExpression(node) {
6674
*
6775
* @param {Object} node The node to check.
6876
* @returns {boolean} Whether or not the node is an ArrowFunctionExpression.
77+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
6978
*/
7079
function isArrowFunctionExpression(node) {
7180
return node !== undefined && node.type === 'ArrowFunctionExpression';
@@ -76,6 +85,7 @@ function isArrowFunctionExpression(node) {
7685
*
7786
* @param {Object} node The node to check.
7887
* @returns {boolean} Whether or not the node is an AssignmentExpression.
88+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
7989
*/
8090
function isAssignmentExpression(node) {
8191
return node.type === 'AssignmentExpression';
@@ -86,6 +96,7 @@ function isAssignmentExpression(node) {
8696
*
8797
* @param {Object} node The node to check.
8898
* @returns {boolean} Whether or not the node is an BinaryExpression.
99+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
89100
*/
90101
function isBinaryExpression(node) {
91102
return node !== undefined && node.type === 'BinaryExpression';
@@ -96,6 +107,7 @@ function isBinaryExpression(node) {
96107
*
97108
* @param {Object} node The node to check.
98109
* @returns {boolean} Whether or not the node is an CallExpression.
110+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
99111
*/
100112
function isCallExpression(node) {
101113
return node !== undefined && node.type === 'CallExpression';
@@ -125,6 +137,7 @@ function isCallWithFunctionExpression(node) {
125137
*
126138
* @param {Object} node The node to check.
127139
* @returns {boolean} Whether or not the node is a ClassDeclaration.
140+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
128141
*/
129142
function isClassDeclaration(node) {
130143
return node !== undefined && node.type === 'ClassDeclaration';
@@ -163,6 +176,7 @@ function isConciseArrowFunctionWithCallExpression(node) {
163176
*
164177
* @param {Object} node The node to check.
165178
* @returns {boolean} Whether or not the node is a ConditionalExpression.
179+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
166180
*/
167181
function isConditionalExpression(node) {
168182
return node !== undefined && node.type === 'ConditionalExpression';
@@ -173,6 +187,7 @@ function isConditionalExpression(node) {
173187
*
174188
* @param {Object} node The node to check.
175189
* @returns {boolean} Whether or not the node is a Decorator.
190+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
176191
*/
177192
function isDecorator(node) {
178193
return node !== undefined && node.type === 'Decorator';
@@ -183,6 +198,7 @@ function isDecorator(node) {
183198
*
184199
* @param {Object} node The node to check.
185200
* @returns {boolean} Whether or not the node is an ExpressionStatement.
201+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
186202
*/
187203
function isExpressionStatement(node) {
188204
return node !== undefined && node.type === 'ExpressionStatement';
@@ -193,6 +209,7 @@ function isExpressionStatement(node) {
193209
*
194210
* @param {Object} node The node to check.
195211
* @returns {boolean} Whether or not the node is a FunctionDeclaration
212+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
196213
*/
197214
function isFunctionDeclaration(node) {
198215
return node !== undefined && node.type === 'FunctionDeclaration';
@@ -203,6 +220,7 @@ function isFunctionDeclaration(node) {
203220
*
204221
* @param {Object} node The node to check.
205222
* @returns {boolean} Whether or not the node is an FunctionExpression.
223+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
206224
*/
207225
function isFunctionExpression(node) {
208226
return node !== undefined && node.type === 'FunctionExpression';
@@ -213,6 +231,7 @@ function isFunctionExpression(node) {
213231
*
214232
* @param {Object} node The node to check.
215233
* @returns {boolean} Whether or not the node is an Identifier.
234+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
216235
*/
217236
function isIdentifier(node) {
218237
return node !== undefined && node.type === 'Identifier';
@@ -223,6 +242,7 @@ function isIdentifier(node) {
223242
*
224243
* @param {Object} node The node to check.
225244
* @returns {boolean} Whether or not the node is an ImportDeclaration.
245+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
226246
*/
227247
function isImportDeclaration(node) {
228248
return node !== undefined && node.type === 'ImportDeclaration';
@@ -233,6 +253,7 @@ function isImportDeclaration(node) {
233253
*
234254
* @param {Object} node The node to check.
235255
* @returns {boolean} Whether or not the node is an ImportDefaultSpecifier.
256+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
236257
*/
237258
function isImportDefaultSpecifier(node) {
238259
return node !== undefined && node.type === 'ImportDefaultSpecifier';
@@ -243,6 +264,7 @@ function isImportDefaultSpecifier(node) {
243264
*
244265
* @param {Object} node The node to check.
245266
* @returns {boolean} Whether or not the node is an Literal.
267+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
246268
*/
247269
function isLiteral(node) {
248270
return node !== undefined && node.type === 'Literal';
@@ -253,6 +275,7 @@ function isLiteral(node) {
253275
*
254276
* @param {Object} node The node to check.
255277
* @returns {boolean} Whether or not the node is an LogicalExpression.
278+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
256279
*/
257280
function isLogicalExpression(node) {
258281
return node !== undefined && node.type === 'LogicalExpression';
@@ -263,6 +286,7 @@ function isLogicalExpression(node) {
263286
*
264287
* @param {Object} node The node to check.
265288
* @return {boolean} Whether or not the node is an MemberExpression.
289+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
266290
*/
267291
function isMemberExpression(node) {
268292
return node !== undefined && node.type === 'MemberExpression';
@@ -273,6 +297,7 @@ function isMemberExpression(node) {
273297
*
274298
* @param {Object} node The node to check.
275299
* @return {boolean} Whether or not the node is a MethodDefinition.
300+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
276301
*/
277302
function isMethodDefinition(node) {
278303
return node !== undefined && node.type === 'MethodDefinition';
@@ -283,6 +308,7 @@ function isMethodDefinition(node) {
283308
*
284309
* @param {Object} node The node to check.
285310
* @returns {boolean} Whether or not the node is an NewExpression.
311+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
286312
*/
287313
function isNewExpression(node) {
288314
return node !== undefined && node.type === 'NewExpression';
@@ -293,6 +319,7 @@ function isNewExpression(node) {
293319
*
294320
* @param {Object} node The node to check.
295321
* @returns {boolean} Whether or not the node is an ObjectExpression.
322+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
296323
*/
297324
function isObjectExpression(node) {
298325
return node !== undefined && node.type === 'ObjectExpression';
@@ -303,6 +330,7 @@ function isObjectExpression(node) {
303330
*
304331
* @param {Object} node The node to check.
305332
* @returns {boolean} Whether or not the node is an ObjectPattern.
333+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
306334
*/
307335
function isObjectPattern(node) {
308336
return node !== undefined && node.type === 'ObjectPattern';
@@ -313,6 +341,7 @@ function isObjectPattern(node) {
313341
*
314342
* @param {Object} node The node to check.
315343
* @returns {boolean} Whether or not the node is an OptionalCallExpression.
344+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
316345
*/
317346
function isOptionalCallExpression(node) {
318347
return node.type === 'OptionalCallExpression';
@@ -323,6 +352,7 @@ function isOptionalCallExpression(node) {
323352
*
324353
* @param {Object} node The node to check.
325354
* @returns {boolean} Whether or not the node is an OptionalMemberExpression.
355+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
326356
*/
327357
function isOptionalMemberExpression(node) {
328358
return node.type === 'OptionalMemberExpression';
@@ -333,6 +363,7 @@ function isOptionalMemberExpression(node) {
333363
*
334364
* @param {Object} node The node to check.
335365
* @returns {boolean} Whether or not the node is an Property.
366+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
336367
*/
337368
function isProperty(node) {
338369
return node !== undefined && node.type === 'Property';
@@ -343,6 +374,7 @@ function isProperty(node) {
343374
*
344375
* @param {Object} node The node to check.
345376
* @return {Boolean} Whether or not the node is a ReturnStatement.
377+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
346378
*/
347379
function isReturnStatement(node) {
348380
return node !== undefined && node.type && node.type === 'ReturnStatement';
@@ -353,6 +385,7 @@ function isReturnStatement(node) {
353385
*
354386
* @param {Object} node The node to check.
355387
* @return {Boolean} Whether or not the node is a SpreadElement.
388+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
356389
*/
357390
function isSpreadElement(node) {
358391
return node !== undefined && node.type === 'SpreadElement';
@@ -371,6 +404,7 @@ function isStringLiteral(node) {
371404
*
372405
* @param {Object} node The node to check.
373406
* @returns {boolean} Whether or not the node is a TaggedTemplateExpression.
407+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
374408
*/
375409
function isTaggedTemplateExpression(node) {
376410
return node !== undefined && node.type === 'TaggedTemplateExpression';
@@ -381,6 +415,7 @@ function isTaggedTemplateExpression(node) {
381415
*
382416
* @param {Object} node The node to check.
383417
* @returns {boolean} Whether or not the node is a TemplateLiteral.
418+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
384419
*/
385420
function isTemplateLiteral(node) {
386421
return node !== undefined && node.type === 'TemplateLiteral';
@@ -391,6 +426,7 @@ function isTemplateLiteral(node) {
391426
*
392427
* @param {Object} node The node to check.
393428
* @returns {boolean} Whether or not the node is an ThisExpression.
429+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
394430
*/
395431
function isThisExpression(node) {
396432
return node !== undefined && node.type === 'ThisExpression';
@@ -401,6 +437,7 @@ function isThisExpression(node) {
401437
*
402438
* @param {Object} node The node to check.
403439
* @returns {boolean} Whether or not the node is an Literal.
440+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
404441
*/
405442
function isUnaryExpression(node) {
406443
return node !== undefined && node.type === 'UnaryExpression';
@@ -411,6 +448,7 @@ function isUnaryExpression(node) {
411448
*
412449
* @param {Object} node The node to check.
413450
* @returns {boolean} Whether or not the node is a VariableDeclarator.
451+
* @deprecated trivial helpers are deprecated in favor of inlining the type check
414452
*/
415453
function isVariableDeclarator(node) {
416454
return node !== undefined && node.type === 'VariableDeclarator';

0 commit comments

Comments
 (0)