Skip to content

Commit fe9e09f

Browse files
HenryBrown0ljharb
authored andcommitted
refactor: invert if statement in bool prop naming
1 parent de1d53c commit fe9e09f

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lib/rules/boolean-prop-naming.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,22 @@ module.exports = {
240240
}
241241

242242
if (
243-
component.node.parent
244-
&& component.node.parent.type === 'VariableDeclarator'
245-
&& component.node.parent.id
246-
&& component.node.parent.id.type === 'Identifier'
247-
&& component.node.parent.id.typeAnnotation
248-
&& component.node.parent.id.typeAnnotation.typeAnnotation
249-
&& component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters
250-
&& (
251-
component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters.type === 'TSTypeParameterInstantiation'
252-
|| component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters.type === 'TypeParameterInstantiation'
253-
)
243+
!component.node.parent
244+
|| component.node.parent.type !== 'VariableDeclarator'
245+
|| !component.node.parent.id
246+
|| component.node.parent.id.type !== 'Identifier'
247+
|| !component.node.parent.id.typeAnnotation
248+
|| !component.node.parent.id.typeAnnotation.typeAnnotation
254249
) {
255-
return component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters.params.find(
250+
return;
251+
}
252+
253+
const annotationTypeParams = component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters;
254+
if (annotationTypeParams && (
255+
annotationTypeParams.type === 'TSTypeParameterInstantiation'
256+
|| annotationTypeParams.type === 'TypeParameterInstantiation'
257+
)) {
258+
return annotationTypeParams.params.find(
256259
(param) => param.type === 'TSTypeReference' || param.type === 'GenericTypeAnnotation'
257260
);
258261
}

0 commit comments

Comments
 (0)