Skip to content

Commit

Permalink
chore: define visitors if checkTypes is truthy
Browse files Browse the repository at this point in the history
  • Loading branch information
akulsr0 committed Aug 15, 2023
1 parent c984b4f commit 70c21f1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/rules/sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ module.exports = {
}

function handleFunctionComponent(node) {
if (!checkTypes) {
return;
}
const firstArg = node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation;
if (firstArg && firstArg.type === 'TSTypeReference') {
const propType = typeAnnotations.get(firstArg.typeName.name)
Expand All @@ -252,7 +249,7 @@ module.exports = {
}
}

return {
return Object.assign({
CallExpression(node) {
if (!sortShapeProp || !isShapeProp(node) || !(node.arguments && node.arguments[0])) {
return;
Expand Down Expand Up @@ -328,9 +325,9 @@ module.exports = {
typeAnnotations.set(node.id.name, currentNode);
}
},

}, checkTypes ? {
FunctionDeclaration: handleFunctionComponent,
ArrowFunctionExpression: handleFunctionComponent,
};
} : null);
},
};

0 comments on commit 70c21f1

Please sign in to comment.