1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-16 01:10:30 +02:00

Ensure that icons data object fields are sorted (#12243)

This commit is contained in:
Álvaro Mondéjar Rubio 2024-11-28 23:13:48 +01:00 committed by GitHub
parent 54b6c4772e
commit 6a1ab6cc86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 120 additions and 81 deletions

View File

@ -370,13 +370,13 @@
}, },
{ {
"title": "AEW", "title": "AEW",
"hex": "000000",
"source": "https://commons.wikimedia.org/wiki/File:AEW_Logo_(simplified).svg",
"aliases": { "aliases": {
"aka": [ "aka": [
"All Elite Wrestling" "All Elite Wrestling"
] ]
}, }
"hex": "000000",
"source": "https://commons.wikimedia.org/wiki/File:AEW_Logo_(simplified).svg"
}, },
{ {
"title": "AFFiNE", "title": "AFFiNE",
@ -1040,10 +1040,10 @@
"title": "Anki", "title": "Anki",
"hex": "80C2EE", "hex": "80C2EE",
"source": "https://commons.wikimedia.org/wiki/File:Anki-icon.svg", "source": "https://commons.wikimedia.org/wiki/File:Anki-icon.svg",
"guidelines": "https://github.com/ankitects/anki/blob/4ab0db3127af8508317f84174aff9d20faedc41a/LICENSE",
"license": { "license": {
"type": "AGPL-3.0-only" "type": "AGPL-3.0-only"
}, }
"guidelines": "https://github.com/ankitects/anki/blob/4ab0db3127af8508317f84174aff9d20faedc41a/LICENSE"
}, },
{ {
"title": "Ansible", "title": "Ansible",
@ -4652,14 +4652,14 @@
}, },
{ {
"title": "DVC", "title": "DVC",
"hex": "13ADC7",
"source": "https://iterative.ai/brand/",
"guidelines": "https://iterative.ai/brand/",
"aliases": { "aliases": {
"aka": [ "aka": [
"Data Version Control" "Data Version Control"
] ]
}, }
"hex": "13ADC7",
"source": "https://iterative.ai/brand/",
"guidelines": "https://iterative.ai/brand/"
}, },
{ {
"title": "dwm", "title": "dwm",
@ -5190,8 +5190,8 @@
}, },
{ {
"title": "F#", "title": "F#",
"hex": "378BBA",
"slug": "fsharp", "slug": "fsharp",
"hex": "378BBA",
"source": "https://foundation.fsharp.org/logo", "source": "https://foundation.fsharp.org/logo",
"guidelines": "https://foundation.fsharp.org/logo", "guidelines": "https://foundation.fsharp.org/logo",
"aliases": { "aliases": {
@ -6372,14 +6372,14 @@
}, },
{ {
"title": "Google", "title": "Google",
"hex": "4285F4",
"source": "https://partnermarketinghub.withgoogle.com",
"guidelines": "https://about.google/brand-resource-center/brand-elements/",
"aliases": { "aliases": {
"loc": { "loc": {
"ko-KR": "구글" "ko-KR": "구글"
} }
}, }
"hex": "4285F4",
"source": "https://partnermarketinghub.withgoogle.com",
"guidelines": "https://about.google/brand-resource-center/brand-elements/"
}, },
{ {
"title": "Google AdMob", "title": "Google AdMob",
@ -8286,23 +8286,23 @@
}, },
{ {
"title": "Kakao", "title": "Kakao",
"hex": "FFCD00",
"source": "https://www.kakaocorp.com/kakao/introduce/ci",
"aliases": { "aliases": {
"loc": { "loc": {
"ko-KR": "카카오" "ko-KR": "카카오"
} }
}, }
"hex": "FFCD00",
"source": "https://www.kakaocorp.com/kakao/introduce/ci"
}, },
{ {
"title": "KakaoTalk", "title": "KakaoTalk",
"hex": "FFCD00",
"source": "https://commons.wikimedia.org/wiki/File:KakaoTalk_logo.svg",
"aliases": { "aliases": {
"loc": { "loc": {
"ko-KR": "카카오톡" "ko-KR": "카카오톡"
} }
}, }
"hex": "FFCD00",
"source": "https://commons.wikimedia.org/wiki/File:KakaoTalk_logo.svg"
}, },
{ {
"title": "Kali Linux", "title": "Kali Linux",
@ -8494,13 +8494,13 @@
}, },
{ {
"title": "Kingston Technology", "title": "Kingston Technology",
"hex": "000000",
"source": "https://www.kingston.com",
"aliases": { "aliases": {
"aka": [ "aka": [
"Kingston" "Kingston"
] ]
}, }
"hex": "000000",
"source": "https://www.kingston.com"
}, },
{ {
"title": "Kinopoisk", "title": "Kinopoisk",
@ -8646,14 +8646,14 @@
}, },
{ {
"title": "Kotlin", "title": "Kotlin",
"hex": "7F52FF",
"source": "https://www.jetbrains.com/company/brand/logos/",
"guidelines": "https://www.jetbrains.com/company/brand/",
"aliases": { "aliases": {
"loc": { "loc": {
"ko-KR": "코틀린" "ko-KR": "코틀린"
} }
}, }
"hex": "7F52FF",
"source": "https://www.jetbrains.com/company/brand/logos/",
"guidelines": "https://www.jetbrains.com/company/brand/"
}, },
{ {
"title": "Koyeb", "title": "Koyeb",
@ -9094,15 +9094,15 @@
}, },
{ {
"title": "LINE", "title": "LINE",
"hex": "00C300",
"source": "https://line.me/en/logo",
"guidelines": "https://line.me/en/logo",
"aliases": { "aliases": {
"loc": { "loc": {
"ko-KR": "라인", "ko-KR": "라인",
"ja-JP": "ライン" "ja-JP": "ライン"
} }
}, }
"hex": "00C300",
"source": "https://line.me/en/logo",
"guidelines": "https://line.me/en/logo"
}, },
{ {
"title": "LineageOS", "title": "LineageOS",
@ -9915,14 +9915,14 @@
}, },
{ {
"title": "MG", "title": "MG",
"hex": "FF0000",
"source": "https://www.mg.co.uk/themes/custom/mg/assets/images/svg/mg-logo-desktop.svg",
"guidelines": "https://www.mg.co.uk/terms-and-conditions",
"aliases": { "aliases": {
"aka": [ "aka": [
"Morris Garages" "Morris Garages"
] ]
}, }
"hex": "FF0000",
"source": "https://www.mg.co.uk/themes/custom/mg/assets/images/svg/mg-logo-desktop.svg",
"guidelines": "https://www.mg.co.uk/terms-and-conditions"
}, },
{ {
"title": "Micro Editor", "title": "Micro Editor",
@ -10159,8 +10159,8 @@
}, },
{ {
"title": "Mongoose", "title": "Mongoose",
"hex": "F04D35",
"slug": "mongoosedotws", "slug": "mongoosedotws",
"hex": "F04D35",
"source": "https://mongoose.ws" "source": "https://mongoose.ws"
}, },
{ {
@ -10260,13 +10260,13 @@
}, },
{ {
"title": "MSI", "title": "MSI",
"hex": "FF0000",
"source": "https://www.msi.com/page/brochure",
"aliases": { "aliases": {
"aka": [ "aka": [
"Micro-Star International" "Micro-Star International"
] ]
}, }
"hex": "FF0000",
"source": "https://www.msi.com/page/brochure"
}, },
{ {
"title": "MSI Business", "title": "MSI Business",
@ -10290,13 +10290,13 @@
}, },
{ {
"title": "MUI", "title": "MUI",
"hex": "007FFF",
"source": "https://github.com/mui-org/material-ui/blob/353cecb5391571163eb6bd8cbf36d2dd299aaf56/docs/src/icons/SvgMuiLogo.tsx",
"aliases": { "aliases": {
"aka": [ "aka": [
"Material-UI" "Material-UI"
] ]
}, }
"hex": "007FFF",
"source": "https://github.com/mui-org/material-ui/blob/353cecb5391571163eb6bd8cbf36d2dd299aaf56/docs/src/icons/SvgMuiLogo.tsx"
}, },
{ {
"title": "Mulesoft", "title": "Mulesoft",
@ -12155,13 +12155,13 @@
}, },
{ {
"title": "PlayStation Portable", "title": "PlayStation Portable",
"hex": "003791",
"source": "https://commons.wikimedia.org/wiki/File:PSP_Logo.svg",
"aliases": { "aliases": {
"aka": [ "aka": [
"PSP" "PSP"
] ]
}, }
"hex": "003791",
"source": "https://commons.wikimedia.org/wiki/File:PSP_Logo.svg"
}, },
{ {
"title": "PlayStation Vita", "title": "PlayStation Vita",
@ -13388,14 +13388,14 @@
}, },
{ {
"title": "Republic of Gamers", "title": "Republic of Gamers",
"hex": "FF0029",
"source": "https://rog.asus.com",
"aliases": { "aliases": {
"aka": [ "aka": [
"ASUS ROG", "ASUS ROG",
"ROG" "ROG"
] ]
}, }
"hex": "FF0029",
"source": "https://rog.asus.com"
}, },
{ {
"title": "ReScript", "title": "ReScript",
@ -14873,13 +14873,13 @@
{ {
"title": "Sphere Online Judge", "title": "Sphere Online Judge",
"slug": "spoj", "slug": "spoj",
"hex": "337AB7",
"source": "https://www.spoj.com",
"aliases": { "aliases": {
"aka": [ "aka": [
"SPOJ" "SPOJ"
] ]
}, }
"hex": "337AB7",
"source": "https://www.spoj.com"
}, },
{ {
"title": "Sphinx", "title": "Sphinx",
@ -15849,13 +15849,13 @@
{ {
"title": "Tether", "title": "Tether",
"hex": "50AF95", "hex": "50AF95",
"source": "https://tether.to/branding/",
"guidelines": "https://tether.to/branding/",
"aliases": { "aliases": {
"aka": [ "aka": [
"USDt" "USDt"
] ]
}, }
"source": "https://tether.to/branding/",
"guidelines": "https://tether.to/branding/"
}, },
{ {
"title": "Textpattern", "title": "Textpattern",
@ -15924,13 +15924,13 @@
}, },
{ {
"title": "The Movie Database", "title": "The Movie Database",
"hex": "01B4E4",
"source": "https://www.themoviedb.org/about/logos-attribution",
"aliases": { "aliases": {
"aka": [ "aka": [
"TMDB" "TMDB"
] ]
}, }
"hex": "01B4E4",
"source": "https://www.themoviedb.org/about/logos-attribution"
}, },
{ {
"title": "The North Face", "title": "The North Face",
@ -17022,6 +17022,9 @@
}, },
{ {
"title": "VictoriaMetrics", "title": "VictoriaMetrics",
"hex": "621773",
"source": "https://github.com/VictoriaMetrics/VictoriaMetrics/blob/24d61bf19374b42ef9839c13c7d35ce8888170e0/docs/assets/images/vm_logo.svg",
"guidelines": "https://docs.victoriametrics.com/#victoriametrics-logo",
"aliases": { "aliases": {
"aka": [ "aka": [
"VM" "VM"
@ -17029,10 +17032,7 @@
"loc": { "loc": {
"ko-KR": "빅토리아메트릭스" "ko-KR": "빅토리아메트릭스"
} }
}, }
"hex": "621773",
"source": "https://github.com/VictoriaMetrics/VictoriaMetrics/blob/24d61bf19374b42ef9839c13c7d35ce8888170e0/docs/assets/images/vm_logo.svg",
"guidelines": "https://docs.victoriametrics.com/#victoriametrics-logo"
}, },
{ {
"title": "Victron Energy", "title": "Victron Energy",
@ -17058,13 +17058,13 @@
}, },
{ {
"title": "Virgin", "title": "Virgin",
"hex": "E10A0A",
"source": "https://www.virgin.com/img/virgin-logo-square.svg",
"aliases": { "aliases": {
"aka": [ "aka": [
"Virgin Group" "Virgin Group"
] ]
}, }
"hex": "E10A0A",
"source": "https://www.virgin.com/img/virgin-logo-square.svg"
}, },
{ {
"title": "Virgin Atlantic", "title": "Virgin Atlantic",
@ -17529,13 +17529,13 @@
}, },
{ {
"title": "Welcome to the Jungle", "title": "Welcome to the Jungle",
"hex": "FFCD00",
"source": "https://www.welcometothejungle.com",
"aliases": { "aliases": {
"aka": [ "aka": [
"WTTJ" "WTTJ"
] ]
}, }
"hex": "FFCD00",
"source": "https://www.welcometothejungle.com"
}, },
{ {
"title": "Wellfound", "title": "Wellfound",
@ -17554,13 +17554,13 @@
}, },
{ {
"title": "Western Digital", "title": "Western Digital",
"hex": "995DFF",
"source": "https://www.westerndigital.com",
"aliases": { "aliases": {
"aka": [ "aka": [
"WD" "WD"
] ]
}, }
"hex": "995DFF",
"source": "https://www.westerndigital.com"
}, },
{ {
"title": "Western Union", "title": "Western Union",
@ -18074,14 +18074,14 @@
}, },
{ {
"title": "Zcash", "title": "Zcash",
"hex": "F3B724",
"source": "https://z.cash",
"guidelines": "https://zfnd.org/trademark-policy",
"aliases": { "aliases": {
"aka": [ "aka": [
"ZEC" "ZEC"
] ]
}, }
"hex": "F3B724",
"source": "https://z.cash",
"guidelines": "https://zfnd.org/trademark-policy"
}, },
{ {
"title": "ZCOOL", "title": "ZCOOL",

View File

@ -23,7 +23,7 @@ import {getSpdxLicenseIds} from '../utils.js';
/** /**
* Contains our tests so they can be isolated from each other. * Contains our tests so they can be isolated from each other.
* @type {{[k: string]: (arg0: {icons: IconsData}, arg1: string) => Promise<string | undefined> | string | undefined}} * @type {{[k: string]: (data: {icons: IconsData}, dataString: string) => Promise<string | undefined> | string | undefined}}
*/ */
const TESTS = { const TESTS = {
/** /**
@ -31,7 +31,7 @@ const TESTS = {
* @param {{icons: IconsData}} data Icons data. * @param {{icons: IconsData}} data Icons data.
* @returns {string|undefined} Error message or undefined. * @returns {string|undefined} Error message or undefined.
*/ */
alphabetical(data) { alphabetical({icons}) {
/** /**
* Collects invalid alphabet ordered icons. * Collects invalid alphabet ordered icons.
* @param {IconData[]} invalidEntries Invalid icons reference. * @param {IconData[]} invalidEntries Invalid icons reference.
@ -72,7 +72,7 @@ const TESTS = {
}; };
// eslint-disable-next-line unicorn/no-array-reduce, unicorn/no-array-callback-reference // eslint-disable-next-line unicorn/no-array-reduce, unicorn/no-array-callback-reference
const invalids = data.icons.reduce(collector, []); const invalids = icons.reduce(collector, []);
if (invalids.length > 0) { if (invalids.length > 0) {
return `Some icons aren't in alphabetical order: return `Some icons aren't in alphabetical order:
${invalids.map((icon) => format(icon)).join(', ')}`; ${invalids.map((icon) => format(icon)).join(', ')}`;
@ -91,7 +91,7 @@ const TESTS = {
}, },
/* Check redundant trailing slash in URL */ /* Check redundant trailing slash in URL */
checkUrl(data) { checkUrl({icons}) {
/** /**
* Check if an URL has a redundant trailing slash. * Check if an URL has a redundant trailing slash.
* @param {URL} $url URL instance. * @param {URL} $url URL instance.
@ -150,7 +150,7 @@ const TESTS = {
* @type {[boolean, string][]} * @type {[boolean, string][]}
*/ */
const allUrlFields = []; const allUrlFields = [];
for (const icon of data.icons) { for (const icon of icons) {
allUrlFields.push([true, icon.source]); allUrlFields.push([true, icon.source]);
if (icon.guidelines) { if (icon.guidelines) {
allUrlFields.push([false, icon.guidelines]); allUrlFields.push([false, icon.guidelines]);
@ -206,10 +206,10 @@ const TESTS = {
}, },
/* Check if all licenses are valid SPDX identifiers */ /* Check if all licenses are valid SPDX identifiers */
async checkLicense(data) { async checkLicense({icons}) {
const spdxLicenseIds = new Set(await getSpdxLicenseIds()); const spdxLicenseIds = new Set(await getSpdxLicenseIds());
const badLicenses = []; const badLicenses = [];
for (const {title, slug, license} of data.icons) { for (const {title, slug, license} of icons) {
if ( if (
license && license &&
license.type !== 'custom' && license.type !== 'custom' &&
@ -225,6 +225,45 @@ const TESTS = {
return `Bad licenses:\n\n${badLicenses.join('\n')}\n\nSee the valid license indentifiers at https://spdx.org/licenses`; return `Bad licenses:\n\n${badLicenses.join('\n')}\n\nSee the valid license indentifiers at https://spdx.org/licenses`;
} }
}, },
/* Ensure that fields are sorted in the same way for all icons */
fieldsSorted({icons}) {
const expectedOrder = [
'title',
'slug',
'hex',
'source',
'guidelines',
'license',
'aliases',
];
const errors = [];
for (const icon of icons) {
const fields = Object.keys(icon);
const previousFields = [...fields];
fields.sort(
(a, b) => expectedOrder.indexOf(a) - expectedOrder.indexOf(b),
);
const previousFieldsString = JSON.stringify(previousFields);
const fieldsString = JSON.stringify(fields);
if (previousFieldsString !== fieldsString) {
const subject = icon.slug ? `${icon.title} (${icon.slug})` : icon.title;
errors.push(
`${subject} fields are not sorted.` +
` Found ${previousFieldsString.replaceAll(',', ', ')},` +
` but expected ${fieldsString.replaceAll(',', ', ')}`,
);
}
}
if (errors.length > 0) {
return (
'Wrong order of fields in _data/simple-icons.json icons:\n' +
`- ${errors.join('\n- ')}`
);
}
},
}; };
const iconsDataString = await getIconsDataString(); const iconsDataString = await getIconsDataString();