更新 verify-theme.mjs

This commit is contained in:
QQ 2026-11-12 09:24:14 +08:00
parent e1e9cb94cd
commit 4dcdeca5f1
1 changed files with 3 additions and 3 deletions

View File

@ -14,14 +14,14 @@ function check(name, ok, detail) {
const source = readFileSync('./client/index.js', 'utf8') const source = readFileSync('./client/index.js', 'utf8')
const hardcoded = source.match(/(?:background|color|borderColor)\s*:\s*['"]#(?:fff(?:fff)?|000(?:000)?)['"]/gi) const hardcoded = source.match(/(?:background|borderColor)\s*:\s*['"]#(?:fff(?:fff)?|000(?:000)?)['"]/gi)
check('no hard-coded pure white/black colours', hardcoded === null, hardcoded === null ? '' : hardcoded.join(',')) check('no hard-coded pure white/black colours', hardcoded === null, hardcoded === null ? '' : hardcoded.join(','))
const neutralTokens = (source.match(/rgba\(127,127,127/gi) ?? []).length const neutralTokens = (source.match(/rgba\(127,127,127/gi) ?? []).length
check('theme-neutral colour tokens are used throughout', neutralTokens >= 5, `${neutralTokens} uses`) check('theme-neutral colour tokens are used throughout', neutralTokens >= 5, `${neutralTokens} uses`)
const accentTokens = (source.match(/rgba\(37,99,235/gi) ?? []).length const accentTokens = (source.match(/#3f3f46/g) ?? []).length
check('accent colour is the shared blue token', accentTokens >= 2, `${accentTokens} uses`) check('accent colour is the shared charcoal token', accentTokens >= 2, `${accentTokens} uses`)
const wrapCount = (source.match(/flexWrap\s*:\s*['"]wrap['"]/g) ?? []).length const wrapCount = (source.match(/flexWrap\s*:\s*['"]wrap['"]/g) ?? []).length
check('long rows wrap instead of scrolling sideways', wrapCount >= 4, `${wrapCount} wrapping rows`) check('long rows wrap instead of scrolling sideways', wrapCount >= 4, `${wrapCount} wrapping rows`)