1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 'use strict';
- function shouldAddParenthesesToLogicalExpressionChild(node, {operator, property}) {
-
-
- if (!property) {
- throw new Error('`property` is required.');
- }
- if (
- node.type === 'LogicalExpression'
- && node.operator === operator
- ) {
- return false;
- }
-
- if (
- node.type === 'AwaitExpression'
- || node.type === 'BinaryExpression'
- ) {
- return true;
- }
-
-
- if (
- node.type === 'LogicalExpression'
- || node.type === 'ConditionalExpression'
- || node.type === 'AssignmentExpression'
- || node.type === 'ArrowFunctionExpression'
- || node.type === 'YieldExpression'
- || node.type === 'SequenceExpression'
- ) {
- return true;
- }
- return false;
- }
- module.exports = shouldAddParenthesesToLogicalExpressionChild;
|