diff --git a/.svglintrc.js b/.svglintrc.js index fd80cab0..2f4aa93f 100644 --- a/.svglintrc.js +++ b/.svglintrc.js @@ -1,3 +1,8 @@ +const data = require("./_data/simple-icons.json"); +const { htmlFriendlyToTitle } = require("./scripts/utils.js"); + +const titleRegexp = /(.+) icon$/; + module.exports = { rules: { elm: { @@ -24,6 +29,23 @@ module.exports = { "rule::selector": "svg > path", "rule::whitelist": true, } + ], + custom: [ + function(reporter, $, ast) { + const iconTitleText = $.find("title").text(); + if (!titleRegexp.test(iconTitleText)) { + reporter.error(" should follow the format \"[ICON_NAME] icon\""); + } else { + const titleMatch = iconTitleText.match(titleRegexp); + // titleMatch = [ "[ICON_NAME] icon", "[ICON_NAME]" ] + const rawIconName = titleMatch[1]; + const iconName = htmlFriendlyToTitle(rawIconName); + const icon = data.icons.find(icon => icon.title === iconName); + if (icon === undefined) { + reporter.error(`No icon with title "${iconName}" found in simple-icons.json`); + } + } + }, ] } }; diff --git a/icons/adobecreativecloud.svg b/icons/adobecreativecloud.svg index 5c5e55ec..a980f301 100644 --- a/icons/adobecreativecloud.svg +++ b/icons/adobecreativecloud.svg @@ -1 +1 @@ -<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Adobe Creative Cloud \ No newline at end of file +Adobe Creative Cloud icon \ No newline at end of file diff --git a/icons/adobexd.svg b/icons/adobexd.svg index 57b9d932..13e70257 100644 --- a/icons/adobexd.svg +++ b/icons/adobexd.svg @@ -1 +1 @@ -Adobe Xd icon \ No newline at end of file +Adobe XD icon \ No newline at end of file diff --git a/icons/allocine.svg b/icons/allocine.svg index 76ba9d42..30ad1a78 100644 --- a/icons/allocine.svg +++ b/icons/allocine.svg @@ -1 +1 @@ -Allocine icon \ No newline at end of file +AlloCiné icon \ No newline at end of file diff --git a/icons/applepay.svg b/icons/applepay.svg index b473ad3d..a9586044 100644 --- a/icons/applepay.svg +++ b/icons/applepay.svg @@ -1 +1 @@ -Apple pay icon \ No newline at end of file +Apple Pay icon \ No newline at end of file diff --git a/icons/cirrusci.svg b/icons/cirrusci.svg index e7d920fc..a17e8a13 100644 --- a/icons/cirrusci.svg +++ b/icons/cirrusci.svg @@ -1 +1 @@ -Cirrus CI \ No newline at end of file +Cirrus CI icon \ No newline at end of file diff --git a/icons/codesandbox.svg b/icons/codesandbox.svg index a4e677a9..e99071d7 100644 --- a/icons/codesandbox.svg +++ b/icons/codesandbox.svg @@ -1 +1 @@ -CodeSandbox Icon \ No newline at end of file +CodeSandbox icon \ No newline at end of file diff --git a/icons/elasticsearch.svg b/icons/elasticsearch.svg index ea26d1cb..ebab5bec 100644 --- a/icons/elasticsearch.svg +++ b/icons/elasticsearch.svg @@ -1 +1 @@ -Elastic Search icon \ No newline at end of file +Elasticsearch icon \ No newline at end of file diff --git a/icons/googleallo.svg b/icons/googleallo.svg index 99a2597f..6809a7d5 100644 --- a/icons/googleallo.svg +++ b/icons/googleallo.svg @@ -1 +1 @@ -Allo icon \ No newline at end of file +Google Allo icon \ No newline at end of file diff --git a/icons/groupon.svg b/icons/groupon.svg index 8cfe63f0..10621966 100644 --- a/icons/groupon.svg +++ b/icons/groupon.svg @@ -1 +1 @@ -groupon icon \ No newline at end of file +Groupon icon \ No newline at end of file diff --git a/icons/hockeyapp.svg b/icons/hockeyapp.svg index 95ae93d7..c7dd0072 100644 --- a/icons/hockeyapp.svg +++ b/icons/hockeyapp.svg @@ -1 +1 @@ -hockeyapp icon \ No newline at end of file +HockeyApp icon \ No newline at end of file diff --git a/icons/iconjar.svg b/icons/iconjar.svg index ec722311..bf7c9900 100644 --- a/icons/iconjar.svg +++ b/icons/iconjar.svg @@ -1 +1 @@ -iconjar icon \ No newline at end of file +IconJar icon \ No newline at end of file diff --git a/icons/ionic.svg b/icons/ionic.svg index 3727b745..b5855ec4 100644 --- a/icons/ionic.svg +++ b/icons/ionic.svg @@ -1 +1 @@ -Ionic Icon \ No newline at end of file +Ionic icon \ No newline at end of file diff --git a/icons/itch-dot-io.svg b/icons/itch-dot-io.svg index edea81e8..0892fccb 100644 --- a/icons/itch-dot-io.svg +++ b/icons/itch-dot-io.svg @@ -1 +1 @@ -Itch.io Icon \ No newline at end of file +Itch.io icon \ No newline at end of file diff --git a/icons/microsoftonedrive.svg b/icons/microsoftonedrive.svg index f00e682d..161a9e39 100644 --- a/icons/microsoftonedrive.svg +++ b/icons/microsoftonedrive.svg @@ -1 +1 @@ -OneDrive icon \ No newline at end of file +Microsoft OneDrive icon \ No newline at end of file diff --git a/icons/mix.svg b/icons/mix.svg index 7f275c6a..74c39b01 100644 --- a/icons/mix.svg +++ b/icons/mix.svg @@ -1 +1 @@ -mix icon \ No newline at end of file +Mix icon \ No newline at end of file diff --git a/icons/node-dot-js.svg b/icons/node-dot-js.svg index 8f50da48..e4f97700 100644 --- a/icons/node-dot-js.svg +++ b/icons/node-dot-js.svg @@ -1 +1 @@ -Node.JS icon \ No newline at end of file +Node.js icon \ No newline at end of file diff --git a/icons/nuget.svg b/icons/nuget.svg index b6fed9c1..b9872791 100644 --- a/icons/nuget.svg +++ b/icons/nuget.svg @@ -1 +1 @@ -Nuget icon \ No newline at end of file +NuGet icon \ No newline at end of file diff --git a/icons/playstation3.svg b/icons/playstation3.svg index 4928d3e0..1b47124d 100644 --- a/icons/playstation3.svg +++ b/icons/playstation3.svg @@ -1 +1 @@ -Playstation 3 icon \ No newline at end of file +PlayStation 3 icon \ No newline at end of file diff --git a/icons/playstation4.svg b/icons/playstation4.svg index a1d9bd82..0656dafe 100644 --- a/icons/playstation4.svg +++ b/icons/playstation4.svg @@ -1 +1 @@ -Playstation 4 icon \ No newline at end of file +PlayStation 4 icon \ No newline at end of file diff --git a/icons/safari.svg b/icons/safari.svg index 429fe25d..a1ea2317 100644 --- a/icons/safari.svg +++ b/icons/safari.svg @@ -1 +1 @@ -safari icon \ No newline at end of file +Safari icon \ No newline at end of file diff --git a/icons/scaleway.svg b/icons/scaleway.svg index aeebfe12..aa0005db 100644 --- a/icons/scaleway.svg +++ b/icons/scaleway.svg @@ -1 +1 @@ -Scaleway Icon \ No newline at end of file +Scaleway icon \ No newline at end of file diff --git a/icons/scrutinizerci.svg b/icons/scrutinizerci.svg index 0f51ceb2..367cfb50 100644 --- a/icons/scrutinizerci.svg +++ b/icons/scrutinizerci.svg @@ -1 +1 @@ -Scrutinizer icon \ No newline at end of file +Scrutinizer CI icon \ No newline at end of file diff --git a/icons/stylus.svg b/icons/stylus.svg index 765cbcd3..30c8b54f 100644 --- a/icons/stylus.svg +++ b/icons/stylus.svg @@ -1 +1 @@ -Stylus \ No newline at end of file +Stylus icon \ No newline at end of file diff --git a/icons/wolframmathematica.svg b/icons/wolframmathematica.svg index 29448a78..2be76cf4 100644 --- a/icons/wolframmathematica.svg +++ b/icons/wolframmathematica.svg @@ -1 +1 @@ -Mathematica icon \ No newline at end of file +Wolfram Mathematica icon \ No newline at end of file diff --git a/scripts/utils.js b/scripts/utils.js index ae7b38f8..6b2d0a15 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -21,5 +21,16 @@ module.exports = { .replace(/ò|ó|ô|õ|ö/, "o") .replace(/ù|ú|û|ü/, "u") .replace(/ý|ÿ/, "y") + ), + + /** + * Converts a brand title in HTML friendly format into a brand title (as it + * is seen in simple-icons.json) + * @param {String} htmlFriendlyTitle The title to convert + */ + htmlFriendlyToTitle: htmlFriendlyTitle => ( + htmlFriendlyTitle + .replace(/&/g, "&") + .replace(/'/g, "’") ) }