mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-06-16 05:57:33 +03:00
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:
parent
cbe05f9bbe
commit
6c435fe741
@ -3651,14 +3651,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Handshake",
|
"title": "Handshake",
|
||||||
"slug": "handshake_protocol",
|
"hex": "FF2F1C",
|
||||||
"hex": "000000",
|
"source": "https://learn.joinhandshake.com/marketing-toolkit/"
|
||||||
"source": "https://handshake.org/"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Handshake",
|
"title": "Handshake",
|
||||||
"hex": "FF2F1C",
|
"slug": "handshake_protocol",
|
||||||
"source": "https://learn.joinhandshake.com/marketing-toolkit/"
|
"hex": "000000",
|
||||||
|
"source": "https://handshake.org/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "HappyCow",
|
"title": "HappyCow",
|
||||||
|
@ -25,17 +25,30 @@ const TESTS = {
|
|||||||
const collector = (invalidEntries, icon, index, array) => {
|
const collector = (invalidEntries, icon, index, array) => {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
const prev = array[index - 1];
|
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);
|
invalidEntries.push(icon);
|
||||||
|
} else if (compare === 0) {
|
||||||
|
if (prev.slug) {
|
||||||
|
if (!icon.slug || icon.slug.localeCompare(prev.slug) < 0) {
|
||||||
|
invalidEntries.push(icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return invalidEntries;
|
return invalidEntries;
|
||||||
};
|
};
|
||||||
|
const format = icon => {
|
||||||
|
if (icon.slug) {
|
||||||
|
return `${icon.title} (${icon.slug})`;
|
||||||
|
}
|
||||||
|
return icon.title;
|
||||||
|
};
|
||||||
|
|
||||||
const invalids = data.icons.reduce(collector, []);
|
const invalids = data.icons.reduce(collector, []);
|
||||||
if (invalids.length) {
|
if (invalids.length) {
|
||||||
return `Some icons aren't in alphabetical order:
|
return `Some icons aren't in alphabetical order:
|
||||||
${invalids.map(icon => icon.title).join(", ")}`;
|
${invalids.map(icon => format(icon)).join(", ")}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user