Skip to content

Commit

Permalink
Apply fisker suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dcyriller committed May 27, 2021
1 parent f3837eb commit 1129270
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/language-handlebars/printer-glimmer.js
Expand Up @@ -419,25 +419,10 @@ function print(path, options, print) {
/* ElementNode print helpers */

function sortByLoc(a, b) {
if (a.loc.start.line < b.loc.start.line) {
return -1;
}

if (
a.loc.start.line === b.loc.start.line &&
a.loc.start.column < b.loc.start.column
) {
return -1;
}

if (
a.loc.start.line === b.loc.start.line &&
a.loc.start.column === b.loc.start.column
) {
return 0;
}

return 1;
return (
a.loc.start.line - b.loc.start.line ||
a.loc.start.column - b.loc.start.column
);
}

function printStartingTag(path, print) {
Expand All @@ -446,9 +431,7 @@ function printStartingTag(path, print) {
const types = ["attributes", "modifiers", "comments"].filter((property) =>
isNonEmptyArray(node[property])
);
const attributes = types
.reduce((acc, type) => [...acc, ...node[type]], [])
.sort(sortByLoc);
const attributes = types.flatMap((type) => node[type]).sort(sortByLoc);

for (const attributeType of types) {
path.each((attributePath) => {
Expand Down

0 comments on commit 1129270

Please sign in to comment.