Skip to content

Commit

Permalink
fixup: Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 24, 2022
1 parent a69233e commit c30e26f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/rules/jsx-sort-props.js
Expand Up @@ -151,12 +151,10 @@ function getGroupsOfSortableAttributes(attributes, context) {
const attribute = attributes[i];
const nextAttribute = attributes[i + 1];
const attributeline = attribute.loc.start.line;
let comment = []
let comment = [];
try {
comment = sourceCode.getCommentsAfter(attribute)
} catch (e) {
} finally {
}
comment = sourceCode.getCommentsAfter(attribute);
} catch (e) { /**/ }
const lastAttr = attributes[i - 1];
const attrIsSpread = attribute.type === 'JSXSpreadAttribute';

Expand All @@ -181,11 +179,11 @@ function getGroupsOfSortableAttributes(attributes, context) {
if (attributeline + 1 === commentline && nextAttribute) {
attributeMap.set(attribute, [nextAttribute.range[1], true]);
addtoSortableAttributeGroups(attribute);
i++;
i += 1;
} else if (attributeline === commentline) {
if (firstComment.type === 'Block') {
attributeMap.set(attribute, [nextAttribute.range[1], true]);
i++;
i += 1;
} else {
attributeMap.set(attribute, [firstComment.range[1], false]);
}
Expand All @@ -201,7 +199,7 @@ function getGroupsOfSortableAttributes(attributes, context) {
attributeMap.set(attribute, [commentNextAttribute[0].range[1], true]);
}
addtoSortableAttributeGroups(attribute);
i++;
i += 1;
}
}
}
Expand Down

0 comments on commit c30e26f

Please sign in to comment.