Skip to content

Commit

Permalink
fix: fix up code uncovered by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akulsr0 committed Aug 14, 2023
1 parent 7006acf commit dd7cfda
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/rules/sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ module.exports = {
function handleFunctionComponent(node) {
const firstArg = node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation;
if (firstArg && firstArg.type === 'TSTypeReference') {
const propType = variableUtil.findVariableByName(context, firstArg.typeName.name)
|| (typeAnnotations.get(firstArg.typeName.name)
&& typeAnnotations.get(firstArg.typeName.name)[0]);
const propType = typeAnnotations.get(firstArg.typeName.name)
&& typeAnnotations.get(firstArg.typeName.name)[0];
if (propType && propType.members) {
checkSorted(propType.members);
}
Expand Down Expand Up @@ -280,6 +279,16 @@ module.exports = {
});
},

TSTypeLiteral(node) {
if (node && node.parent.id) {
const currentNode = [].concat(
typeAnnotations.get(node.parent.id.name) || [],
node
);
typeAnnotations.set(node.parent.id.name, currentNode);
}
},

TSTypeAliasDeclaration(node) {
if (node.typeAnnotation.type === 'TSTypeLiteral' || node.typeAnnotation.type === 'ObjectTypeAnnotation') {
const currentNode = [].concat(
Expand Down

0 comments on commit dd7cfda

Please sign in to comment.