Skip to content

Commit d77caa5

Browse files
HenryBrown0ljharb
authored andcommitted
refactor: exit early if no type params
1 parent fe9e09f commit d77caa5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/rules/function-component-definition.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ const UNNAMED_FUNCTION_TEMPLATES = {
3333
};
3434

3535
function hasOneUnconstrainedTypeParam(node) {
36-
if (node.typeParameters) {
37-
return (
38-
node.typeParameters.params.length === 1
39-
&& !node.typeParameters.params[0].constraint
40-
);
36+
const nodeTypeParams = node.typeParameters;
37+
if (!nodeTypeParams) {
38+
return false;
4139
}
4240

43-
return false;
41+
return nodeTypeParams.params.length === 1 && !nodeTypeParams.params[0].constraint;
4442
}
4543

4644
function hasName(node) {

0 commit comments

Comments
 (0)