Skip to content

Commit 70c21f1

Browse files
committed
chore: define visitors if checkTypes is truthy
1 parent c984b4f commit 70c21f1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/rules/sort-prop-types.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ module.exports = {
225225
}
226226

227227
function handleFunctionComponent(node) {
228-
if (!checkTypes) {
229-
return;
230-
}
231228
const firstArg = node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation;
232229
if (firstArg && firstArg.type === 'TSTypeReference') {
233230
const propType = typeAnnotations.get(firstArg.typeName.name)
@@ -252,7 +249,7 @@ module.exports = {
252249
}
253250
}
254251

255-
return {
252+
return Object.assign({
256253
CallExpression(node) {
257254
if (!sortShapeProp || !isShapeProp(node) || !(node.arguments && node.arguments[0])) {
258255
return;
@@ -328,9 +325,9 @@ module.exports = {
328325
typeAnnotations.set(node.id.name, currentNode);
329326
}
330327
},
331-
328+
}, checkTypes ? {
332329
FunctionDeclaration: handleFunctionComponent,
333330
ArrowFunctionExpression: handleFunctionComponent,
334-
};
331+
} : null);
335332
},
336333
};

0 commit comments

Comments
 (0)