diff --git a/.eslintrc b/.eslintrc index 0f29493fbe..c910dcddbe 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,7 +32,6 @@ "function-paren-newline": 0, "no-plusplus": 1, "no-param-reassign": 1, - "no-mixed-operators": 1, "no-restricted-syntax": [2, { "selector": "ObjectPattern", "message": "Object destructuring is not compatible with Node v4" diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index 4716b2aa04..dc3589ad77 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -37,7 +37,7 @@ module.exports = { create: Components.detect((context, components, utils) => { const configuration = context.options[0] || DEFAULT_OPTION; - const ignoreClassFields = context.options[1] && context.options[1].ignoreClassFields === true || false; + const ignoreClassFields = (context.options[1] && (context.options[1].ignoreClassFields === true)) || false; /** * @param {ASTNode} node We expect either an ArrowFunctionExpression, diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index 630e21a634..a13aa2b839 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -93,14 +93,14 @@ module.exports = { return { MemberExpression(node) { if ( - node.property + (node.property && ( !node.computed && node.property.type === 'Identifier' && node.property.name === 'propTypes' && !ast.isAssignmentLHS(node) && !isAllowedAssignment(node) - ) || ( + )) || ( (node.property.type === 'Literal' || node.property.type === 'JSXText') && node.property.value === 'propTypes' && !ast.isAssignmentLHS(node) diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index 9e11f60afa..d8a4f5f734 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -327,7 +327,7 @@ module.exports = { return; } // Use the parent in a list or an array - if (prevToken.type === 'JSXText' || prevToken.type === 'Punctuator' && prevToken.value === ',') { + if (prevToken.type === 'JSXText' || ((prevToken.type === 'Punctuator') && prevToken.value === ',')) { prevToken = sourceCode.getNodeByRangeIndex(prevToken.range[0]); prevToken = prevToken.type === 'Literal' || prevToken.type === 'JSXText' ? prevToken.parent : prevToken; // Use the first non-punctuator token in a conditional expression diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index 2afb94ff37..2fe87b81c2 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -46,7 +46,7 @@ module.exports = { } function hasJSX(node) { - return jsxUtil.isJSX(node) || isExpression(node) && jsxUtil.isJSX(node.expression); + return jsxUtil.isJSX(node) || (isExpression(node) && jsxUtil.isJSX(node.expression)); } function isLeaf(node) { @@ -87,10 +87,10 @@ module.exports = { if (has(refs[i], 'writeExpr')) { const writeExpr = refs[i].writeExpr; - return jsxUtil.isJSX(writeExpr) - && writeExpr - || (writeExpr && writeExpr.type === 'Identifier') - && findJSXElementOrFragment(variables, writeExpr.name); + return (jsxUtil.isJSX(writeExpr) + && writeExpr) + || ((writeExpr && writeExpr.type === 'Identifier') + && findJSXElementOrFragment(variables, writeExpr.name)); } } diff --git a/lib/rules/jsx-one-expression-per-line.js b/lib/rules/jsx-one-expression-per-line.js index e0fb19d9da..13774cafa1 100644 --- a/lib/rules/jsx-one-expression-per-line.js +++ b/lib/rules/jsx-one-expression-per-line.js @@ -75,7 +75,7 @@ module.exports = { ) { if ( options.allow === 'single-child' - || options.allow === 'literal' && (child.type === 'Literal' || child.type === 'JSXText') + || (options.allow === 'literal' && (child.type === 'Literal' || child.type === 'JSXText')) ) { return; } diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index 269cb6f6ed..2b5cafcbbe 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -64,7 +64,7 @@ module.exports = { return; } const component = components.get(utils.getParentComponent()); - const setStateUsages = component && component.setStateUsages || []; + const setStateUsages = (component && component.setStateUsages) || []; setStateUsages.push(callee); components.set(node, { useSetState: true, diff --git a/lib/rules/no-this-in-sfc.js b/lib/rules/no-this-in-sfc.js index 54c1488414..32589639f9 100644 --- a/lib/rules/no-this-in-sfc.js +++ b/lib/rules/no-this-in-sfc.js @@ -32,7 +32,7 @@ module.exports = { MemberExpression(node) { if (node.object.type === 'ThisExpression') { const component = components.get(utils.getParentStatelessComponent()); - if (!component || component.node && component.node.parent && component.node.parent.type === 'Property') { + if (!component || (component.node && component.node.parent && component.node.parent.type === 'Property')) { return; } context.report({ diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 352c8e24e1..ecbcf0541a 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -239,7 +239,7 @@ module.exports = { create(context) { function getIgnoreConfig() { - return context.options[0] && context.options[0].ignore || DEFAULTS.ignore; + return (context.options[0] && context.options[0].ignore) || DEFAULTS.ignore; } return { diff --git a/lib/rules/no-unused-state.js b/lib/rules/no-unused-state.js index bee19d1b78..f9c862e7bc 100644 --- a/lib/rules/no-unused-state.js +++ b/lib/rules/no-unused-state.js @@ -105,7 +105,7 @@ module.exports = { if ( parent && parent.type === 'MethodDefinition' && ( - parent.static && parent.key.name === 'getDerivedStateFromProps' + (parent.static && parent.key.name === 'getDerivedStateFromProps') || classMethods.indexOf(parent.key.name) !== -1 ) && parent.value.type === 'FunctionExpression' diff --git a/lib/rules/prefer-read-only-props.js b/lib/rules/prefer-read-only-props.js index 3a1faff94a..d0187d5e57 100644 --- a/lib/rules/prefer-read-only-props.js +++ b/lib/rules/prefer-read-only-props.js @@ -13,7 +13,7 @@ function isFlowPropertyType(node) { } function isCovariant(node) { - return node.variance && node.variance.kind === 'plus' || node.parent.parent.parent.id && node.parent.parent.parent.id.name === '$ReadOnly'; + return (node.variance && (node.variance.kind === 'plus')) || (node.parent.parent.parent.id && (node.parent.parent.parent.id.name === '$ReadOnly')); } // ------------------------------------------------------------------------------ diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index 2800de3e0d..641ffc704b 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -182,7 +182,7 @@ module.exports = { return properties.some((property) => { const name = astUtil.getPropertyName(property); const isDisplayName = name === 'displayName'; - const isPropTypes = name === 'propTypes' || name === 'props' && property.typeAnnotation; + const isPropTypes = name === 'propTypes' || ((name === 'props') && property.typeAnnotation); const contextTypes = name === 'contextTypes'; const defaultProps = name === 'defaultProps'; const isUselessConstructor = property.kind === 'constructor' diff --git a/lib/rules/self-closing-comp.js b/lib/rules/self-closing-comp.js index 8c8472f683..d2220ca522 100644 --- a/lib/rules/self-closing-comp.js +++ b/lib/rules/self-closing-comp.js @@ -67,8 +67,8 @@ module.exports = { function isShouldBeSelfClosed(node) { const configuration = Object.assign({}, optionDefaults, context.options[0]); return ( - configuration.component && isComponent(node) - || configuration.html && jsxUtil.isDOMComponent(node) + (configuration.component && isComponent(node)) + || (configuration.html && jsxUtil.isDOMComponent(node)) ) && !node.selfClosing && (childrenIsEmpty(node) || childrenIsMultilineSpaces(node)); } diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index 7d1f725866..9d25f08d6b 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -354,9 +354,9 @@ module.exports = { // Comparing the same properties refIndexA === refIndexB // 1st property is placed before the 2nd one in reference and in current component - || refIndexA < refIndexB && classIndexA < classIndexB + || ((refIndexA < refIndexB) && (classIndexA < classIndexB)) // 1st property is placed after the 2nd one in reference and in current component - || refIndexA > refIndexB && classIndexA > classIndexB + || ((refIndexA > refIndexB) && (classIndexA > classIndexB)) ) { return { correct: true, diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 0e6f968b18..e963f50398 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -38,7 +38,7 @@ module.exports = { }, create(context) { - const allowed = new Set(context.options.length > 0 && context.options[0].allow || []); + const allowed = new Set(((context.options.length > 0) && context.options[0].allow) || []); /** * @param {ASTNode} expression An Identifier node diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 1d32ea84c9..56cbbf0ab0 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -749,8 +749,8 @@ module.exports = function propTypesInstructions(context, components, utils) { componentNode = componentNode.parent; } const component = components.get(componentNode); - let declaredPropTypes = component && component.declaredPropTypes || {}; - let ignorePropsValidation = component && component.ignorePropsValidation || false; + let declaredPropTypes = (component && component.declaredPropTypes) || {}; + let ignorePropsValidation = (component && component.ignorePropsValidation) || false; switch (propTypes && propTypes.type) { case 'ObjectTypeAnnotation': ignorePropsValidation = declarePropTypesForObjectTypeAnnotation(propTypes, declaredPropTypes); @@ -810,8 +810,8 @@ module.exports = function propTypesInstructions(context, components, utils) { let isUsedInPropTypes = false; let n = propTypes; while (n) { - if (n.type === 'AssignmentExpression' && propsUtil.isPropTypesDeclaration(n.left) - || (n.type === 'ClassProperty' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n)) { + if (((n.type === 'AssignmentExpression') && propsUtil.isPropTypesDeclaration(n.left)) + || ((n.type === 'ClassProperty' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n))) { // Found a propType used inside of another propType. This is not considered usage, we'll still validate // this component. isUsedInPropTypes = true; diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index eb11698d4c..dc62c8b3ba 100644 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -356,8 +356,8 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } const component = components.get(utils.getParentComponent()); - const usedPropTypes = component && component.usedPropTypes || []; - let ignoreUnusedPropTypesValidation = component && component.ignoreUnusedPropTypesValidation || false; + const usedPropTypes = (component && component.usedPropTypes) || []; + let ignoreUnusedPropTypesValidation = (component && component.ignoreUnusedPropTypesValidation) || false; switch (type) { case 'direct': { @@ -419,7 +419,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) const destructuring = param && ( param.type === 'ObjectPattern' - || param.type === 'AssignmentPattern' && param.left.type === 'ObjectPattern' + || ((param.type === 'AssignmentPattern') && (param.left.type === 'ObjectPattern')) ); if (destructuring && (components.get(node) || components.get(node.parent))) {