-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no-array-callback-reference
: Check logical expressions, check terna…
…ries deeply (#2289)
- Loading branch information
Showing
8 changed files
with
519 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
rules/utils/should-add-parentheses-to-call-expression-callee.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
/** | ||
Check if parentheses should be added to a `node` when it's used as `callee` of `CallExpression`. | ||
@param {Node} node - The AST node to check. | ||
@returns {boolean} | ||
*/ | ||
function shouldAddParenthesesToCallExpressionCallee(node) { | ||
return node.type === 'SequenceExpression' | ||
|| node.type === 'YieldExpression' | ||
|| node.type === 'ArrowFunctionExpression' | ||
|| node.type === 'ConditionalExpression' | ||
|| node.type === 'AssignmentExpression' | ||
|| node.type === 'LogicalExpression' | ||
|| node.type === 'BinaryExpression' | ||
|| node.type === 'UnaryExpression' | ||
|| node.type === 'UpdateExpression' | ||
|| node.type === 'NewExpression'; | ||
} | ||
|
||
module.exports = shouldAddParenthesesToCallExpressionCallee; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.