mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-05-03 01:26:43 +03:00
Add linting step for extraneous elements in SVGs (#3239)
* Add linting step for extraneous elements in SVGs ... such as a trailing "s" in the Quasar SVG (#3221) * Remove trailing space from BMC Software icon * Improve error message for violations Co-authored-by: Peter Noble <PeterShaggyNoble@users.noreply.github.com> Co-authored-by: Lucas Becker <runxel@users.noreply.github.com>
This commit is contained in:
parent
af4024cc4c
commit
01221c047d
@ -3,6 +3,8 @@ const { htmlFriendlyToTitle } = require("./scripts/utils.js");
|
|||||||
const getBounds = require("svg-path-bounding-box");
|
const getBounds = require("svg-path-bounding-box");
|
||||||
|
|
||||||
const titleRegexp = /(.+) icon$/;
|
const titleRegexp = /(.+) icon$/;
|
||||||
|
const svgRegexp = /^<svg.*<\/svg>\r?\n?$/;
|
||||||
|
|
||||||
const iconSize = 24;
|
const iconSize = 24;
|
||||||
const iconFloatPrecision = 3;
|
const iconFloatPrecision = 3;
|
||||||
const iconIgnored = require("./.svglint-ignored.json");
|
const iconIgnored = require("./.svglint-ignored.json");
|
||||||
@ -70,6 +72,14 @@ module.exports = {
|
|||||||
reporter.error(`Size of <path> must be exactly ${iconSize} in one dimension; the size is currently ${width} x ${height}`);
|
reporter.error(`Size of <path> must be exactly ${iconSize} in one dimension; the size is currently ${width} x ${height}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
function(reporter, $, ast) {
|
||||||
|
reporter.name = "extraneous";
|
||||||
|
|
||||||
|
const rawSVG = $.html();
|
||||||
|
if (!svgRegexp.test(rawSVG)) {
|
||||||
|
reporter.error("Unexpected character(s) detected outside the opening and/or closing <svg> tags");
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user