Skip to content

Commit

Permalink
[eslint] remove operator-linebreak override
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and ljharb committed Feb 22, 2020
1 parent 304590a commit 88d404d
Show file tree
Hide file tree
Showing 66 changed files with 845 additions and 846 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"ignoreTemplateLiterals": true,
"ignoreComments": true,
}],
"operator-linebreak": [2, "after"],
"consistent-return": 0,

"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
Expand Down
34 changes: 17 additions & 17 deletions lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ module.exports = {
*/
function flowCheck(prop) {
return (
prop.type === 'ObjectTypeProperty' &&
prop.value.type === 'BooleanTypeAnnotation' &&
rule.test(getPropName(prop)) === false
prop.type === 'ObjectTypeProperty'
&& prop.value.type === 'BooleanTypeAnnotation'
&& rule.test(getPropName(prop)) === false
);
}

Expand All @@ -131,9 +131,9 @@ module.exports = {
function regularCheck(prop) {
const propKey = getPropKey(prop);
return (
propKey &&
propTypeNames.indexOf(propKey) >= 0 &&
rule.test(getPropName(prop)) === false
propKey
&& propTypeNames.indexOf(propKey) >= 0
&& rule.test(getPropName(prop)) === false
);
}

Expand All @@ -144,8 +144,8 @@ module.exports = {
*/
function nestedPropTypes(prop) {
return (
prop.type === 'Property' &&
prop.value.type === 'CallExpression'
prop.type === 'Property'
&& prop.value.type === 'CallExpression'
);
}

Expand Down Expand Up @@ -222,9 +222,9 @@ module.exports = {
return;
}
if (
node.value &&
node.value.type === 'CallExpression' &&
propWrapperUtil.isPropWrapperFunction(
node.value
&& node.value.type === 'CallExpression'
&& propWrapperUtil.isPropWrapperFunction(
context,
context.getSourceCode().getText(node.value.callee)
)
Expand All @@ -249,8 +249,8 @@ module.exports = {
}
const right = node.parent.right;
if (
right.type === 'CallExpression' &&
propWrapperUtil.isPropWrapperFunction(
right.type === 'CallExpression'
&& propWrapperUtil.isPropWrapperFunction(
context,
context.getSourceCode().getText(right.callee)
)
Expand Down Expand Up @@ -292,10 +292,10 @@ module.exports = {
Object.keys(list).forEach((component) => {
// If this is a functional component that uses a global type, check it
if (
list[component].node.type === 'FunctionDeclaration' &&
list[component].node.params &&
list[component].node.params.length &&
list[component].node.params[0].typeAnnotation
list[component].node.type === 'FunctionDeclaration'
&& list[component].node.params
&& list[component].node.params.length
&& list[component].node.params[0].typeAnnotation
) {
const typeNode = list[component].node.params[0].typeAnnotation;
const annotation = typeNode.typeAnnotation;
Expand Down
12 changes: 6 additions & 6 deletions lib/rules/button-has-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const pragmaUtil = require('../util/pragma');

function isCreateElement(node, context) {
const pragma = pragmaUtil.getFromContext(context);
return node.callee &&
node.callee.type === 'MemberExpression' &&
node.callee.property.name === 'createElement' &&
node.callee.object &&
node.callee.object.name === pragma &&
node.arguments.length > 0;
return node.callee
&& node.callee.type === 'MemberExpression'
&& node.callee.property.name === 'createElement'
&& node.callee.object
&& node.callee.object.name === pragma
&& node.arguments.length > 0;
}

// ------------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/destructuring-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ module.exports = {
function handleClassUsage(node) {
// this.props.Aprop || this.context.aProp || this.state.aState
const isPropUsed = (
node.object.type === 'MemberExpression' && node.object.object.type === 'ThisExpression' &&
(node.object.property.name === 'props' || node.object.property.name === 'context' || node.object.property.name === 'state') &&
!isAssignmentLHS(node)
node.object.type === 'MemberExpression' && node.object.object.type === 'ThisExpression'
&& (node.object.property.name === 'props' || node.object.property.name === 'context' || node.object.property.name === 'state')
&& !isAssignmentLHS(node)
);

if (
isPropUsed && configuration === 'always' &&
!(ignoreClassFields && isInClassProperty(node))
isPropUsed && configuration === 'always'
&& !(ignoreClassFields && isInClassProperty(node))
) {
context.report({
node,
Expand Down Expand Up @@ -140,8 +140,8 @@ module.exports = {
}

if (
classComponent && destructuringClass && configuration === 'never' &&
!(ignoreClassFields && node.parent.type === 'ClassProperty')
classComponent && destructuringClass && configuration === 'never'
&& !(ignoreClassFields && node.parent.type === 'ClassProperty')
) {
context.report({
node,
Expand Down
54 changes: 27 additions & 27 deletions lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,45 +71,45 @@ module.exports = {
*/
function hasTranspilerName(node) {
const namedObjectAssignment = (
node.type === 'ObjectExpression' &&
node.parent &&
node.parent.parent &&
node.parent.parent.type === 'AssignmentExpression' &&
(
!node.parent.parent.left.object ||
node.parent.parent.left.object.name !== 'module' ||
node.parent.parent.left.property.name !== 'exports'
node.type === 'ObjectExpression'
&& node.parent
&& node.parent.parent
&& node.parent.parent.type === 'AssignmentExpression'
&& (
!node.parent.parent.left.object
|| node.parent.parent.left.object.name !== 'module'
|| node.parent.parent.left.property.name !== 'exports'
)
);
const namedObjectDeclaration = (
node.type === 'ObjectExpression' &&
node.parent &&
node.parent.parent &&
node.parent.parent.type === 'VariableDeclarator'
node.type === 'ObjectExpression'
&& node.parent
&& node.parent.parent
&& node.parent.parent.type === 'VariableDeclarator'
);
const namedClass = (
(node.type === 'ClassDeclaration' || node.type === 'ClassExpression') &&
node.id &&
!!node.id.name
(node.type === 'ClassDeclaration' || node.type === 'ClassExpression')
&& node.id
&& !!node.id.name
);

const namedFunctionDeclaration = (
(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') &&
node.id &&
!!node.id.name
(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
&& node.id
&& !!node.id.name
);

const namedFunctionExpression = (
astUtil.isFunctionLikeExpression(node) &&
node.parent &&
(node.parent.type === 'VariableDeclarator' || node.parent.method === true) &&
(!node.parent.parent || !utils.isES5Component(node.parent.parent))
astUtil.isFunctionLikeExpression(node)
&& node.parent
&& (node.parent.type === 'VariableDeclarator' || node.parent.method === true)
&& (!node.parent.parent || !utils.isES5Component(node.parent.parent))
);

if (
namedObjectAssignment || namedObjectDeclaration ||
namedClass ||
namedFunctionDeclaration || namedFunctionExpression
namedObjectAssignment || namedObjectDeclaration
|| namedClass
|| namedFunctionDeclaration || namedFunctionExpression
) {
return true;
}
Expand Down Expand Up @@ -215,8 +215,8 @@ module.exports = {
const isWrappedInAnotherPragma = utils.getPragmaComponentWrapper(node);

if (
!isWrappedInAnotherPragma &&
(ignoreTranspilerName || !hasTranspilerName(node.arguments[0]))
!isWrappedInAnotherPragma
&& (ignoreTranspilerName || !hasTranspilerName(node.arguments[0]))
) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/forbid-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ module.exports = {
}

function isValidCreateElement(node) {
return node.callee &&
node.callee.type === 'MemberExpression' &&
node.callee.object.name === 'React' &&
node.callee.property.name === 'createElement' &&
node.arguments.length > 0;
return node.callee
&& node.callee.type === 'MemberExpression'
&& node.callee.object.name === 'React'
&& node.callee.property.name === 'createElement'
&& node.arguments.length > 0;
}

function reportIfForbidden(element, node) {
Expand Down
36 changes: 18 additions & 18 deletions lib/rules/forbid-foreign-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ module.exports = {
const assignmentExpression = findParentAssignmentExpression(node);

if (
assignmentExpression &&
assignmentExpression.left &&
assignmentExpression.left.property &&
assignmentExpression.left.property.name === 'propTypes'
assignmentExpression
&& assignmentExpression.left
&& assignmentExpression.left.property
&& assignmentExpression.left.property.name === 'propTypes'
) {
return true;
}

const classProperty = findParentClassProperty(node);

if (
classProperty &&
classProperty.key &&
classProperty.key.name === 'propTypes'
classProperty
&& classProperty.key
&& classProperty.key.name === 'propTypes'
) {
return true;
}
Expand All @@ -93,18 +93,18 @@ module.exports = {
return {
MemberExpression(node) {
if (
node.property &&
(
!node.computed &&
node.property.type === 'Identifier' &&
node.property.name === 'propTypes' &&
!ast.isAssignmentLHS(node) &&
!isAllowedAssignment(node)
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) &&
!isAllowedAssignment(node)
(node.property.type === 'Literal' || node.property.type === 'JSXText')
&& node.property.value === 'propTypes'
&& !ast.isAssignmentLHS(node)
&& !isAllowedAssignment(node)
)
) {
context.report({
Expand Down
36 changes: 18 additions & 18 deletions lib/rules/forbid-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ module.exports = {
let target;
let value = declaration.value;
if (
value.type === 'MemberExpression' &&
value.property &&
value.property.name &&
value.property.name === 'isRequired'
value.type === 'MemberExpression'
&& value.property
&& value.property.name
&& value.property.name === 'isRequired'
) {
value = value.object;
}
if (
value.type === 'CallExpression' &&
value.callee.type === 'MemberExpression'
value.type === 'CallExpression'
&& value.callee.type === 'MemberExpression'
) {
value = value.callee;
}
Expand Down Expand Up @@ -140,9 +140,9 @@ module.exports = {
return {
ClassProperty(node) {
if (
!propsUtil.isPropTypesDeclaration(node) &&
!shouldCheckContextTypes(node) &&
!shouldCheckChildContextTypes(node)
!propsUtil.isPropTypesDeclaration(node)
&& !shouldCheckContextTypes(node)
&& !shouldCheckChildContextTypes(node)
) {
return;
}
Expand All @@ -151,9 +151,9 @@ module.exports = {

MemberExpression(node) {
if (
!propsUtil.isPropTypesDeclaration(node) &&
!shouldCheckContextTypes(node) &&
!shouldCheckChildContextTypes(node)
!propsUtil.isPropTypesDeclaration(node)
&& !shouldCheckContextTypes(node)
&& !shouldCheckChildContextTypes(node)
) {
return;
}
Expand All @@ -163,9 +163,9 @@ module.exports = {

MethodDefinition(node) {
if (
!propsUtil.isPropTypesDeclaration(node) &&
!shouldCheckContextTypes(node) &&
!shouldCheckChildContextTypes(node)
!propsUtil.isPropTypesDeclaration(node)
&& !shouldCheckContextTypes(node)
&& !shouldCheckChildContextTypes(node)
) {
return;
}
Expand All @@ -184,9 +184,9 @@ module.exports = {
}

if (
!propsUtil.isPropTypesDeclaration(property) &&
!shouldCheckContextTypes(property) &&
!shouldCheckChildContextTypes(property)
!propsUtil.isPropTypesDeclaration(property)
&& !shouldCheckContextTypes(property)
&& !shouldCheckChildContextTypes(property)
) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/function-component-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ module.exports = {
fixerOptions: {
type: namedConfig,
template: NAMED_FUNCTION_TEMPLATES[namedConfig],
range: node.type === 'FunctionDeclaration' ?
node.range :
node.parent.parent.range
range: node.type === 'FunctionDeclaration'
? node.range
: node.parent.parent.range
}
});
}
Expand Down
Loading

0 comments on commit 88d404d

Please sign in to comment.