Require Sorting by Slug (#5115)

#   Fix indentation of format function.
 #   Co-authored-by: Eric Cornelissen <ericornelissen@gmail.com>

 #   Update formatting in scripts/lint.js
 #   Co-authored-by: Eric Cornelissen <ericornelissen@gmail.com>
 #   Fix Handshake order
 #   Require Sorting by Slug
This commit is contained in:
Eric Cornelissen 2021-04-16 18:05:44 +02:00
parent cbe05f9bbe
commit 6c435fe741
3 changed files with 21 additions and 8 deletions

View File

@ -3651,14 +3651,14 @@
},
{
"title": "Handshake",
"slug": "handshake_protocol",
"hex": "000000",
"source": "https://handshake.org/"
"hex": "FF2F1C",
"source": "https://learn.joinhandshake.com/marketing-toolkit/"
},
{
"title": "Handshake",
"hex": "FF2F1C",
"source": "https://learn.joinhandshake.com/marketing-toolkit/"
"slug": "handshake_protocol",
"hex": "000000",
"source": "https://handshake.org/"
},
{
"title": "HappyCow",

View File

@ -25,17 +25,30 @@ const TESTS = {
const collector = (invalidEntries, icon, index, array) => {
if (index > 0) {
const prev = array[index - 1];
if (icon.title.localeCompare(prev.title) < 0) {
const compare = icon.title.localeCompare(prev.title);
if (compare < 0) {
invalidEntries.push(icon);
} else if (compare === 0) {
if (prev.slug) {
if (!icon.slug || icon.slug.localeCompare(prev.slug) < 0) {
invalidEntries.push(icon);
}
}
}
}
return invalidEntries;
};
const format = icon => {
if (icon.slug) {
return `${icon.title} (${icon.slug})`;
}
return icon.title;
};
const invalids = data.icons.reduce(collector, []);
if (invalids.length) {
return `Some icons aren't in alphabetical order:
${invalids.map(icon => icon.title).join(", ")}`;
${invalids.map(icon => format(icon)).join(", ")}`;
}
},