fix(web): token linter ignores comments

This commit is contained in:
Miguel Palhas
2026-08-23 19:54:42 +01:00
parent 353608ae63
commit 4efc7b1833
+7 -1
View File
@@ -99,7 +99,13 @@ function checkCss(source, rel) {
}
function checkPlain(source, rel) {
source.split("\n").forEach((rawLine, index) => {
// Comments are prose, not styling — `checkCss` already ignores them, and
// without the same treatment here an issue reference like `#140` reads as a
// three-digit hex colour and fails the gate.
const stripped = source
.replace(/\/\*[\s\S]*?\*\//g, (comment) => comment.replace(/[^\n]/g, " "))
.replace(/\/\/.*$/gm, "");
stripped.split("\n").forEach((rawLine, index) => {
const neutral = rawLine.replace(RELATIVE_FROM_TOKEN, "from-token(");
if (COLOR_LITERAL.test(neutral)) {
errors.push(`${rel}:${index + 1}: literal colour outside the token block`);