Files
Juan DenisandClaude Fable 5 5d875d8a09 refactor(scss): status-variant mixin — 174 re-rolled color pairs converge (plan 77 D4)
@mixin status-variant($color, $bg, $border) in _mixins.scss is the one
shape for coloring status-bearing elements; every mechanical
background/color token pair across 40+ page/component partials now
includes it (pass-through args -> identical compiled CSS values, build
green). check-status-scss.mjs holds the raw-pair count at zero and runs
inside npm run lint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-19 05:35:28 -04:00

43 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
// Plan 77 D4 ratchet — status colors go through @mixin status-variant.
//
// The mechanical `background: <tone-bg>; color: <tone>;` pairs (174 of them)
// were converted to `@include status-variant(...)`; this check keeps the
// count of raw convertible pairs at ZERO so the shape cannot re-roll.
// Run via: npm run lint (or node scripts/check-status-scss.mjs)
import { readFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
const ROOTS = ['src/styles/pages', 'src/styles/components'];
const TOK = String.raw`(?:var\(--[\w-]+\)|\$[\w-]+)`;
const TOKBG = String.raw`(?:var\(--[\w-]+-bg\)|\$[\w-]+-bg)`;
const PATTERNS = [
new RegExp(String.raw`^(\s*)background: ${TOKBG};\n\1color: ${TOK};`, 'm'),
new RegExp(String.raw`^(\s*)color: ${TOK};\n\1background: ${TOKBG};`, 'm'),
new RegExp(String.raw`\{ background: ${TOKBG}; color: ${TOK}; \}`),
];
const offenders = [];
for (const root of ROOTS) {
for (const name of readdirSync(root)) {
if (!name.endsWith('.scss')) continue;
const text = readFileSync(join(root, name), 'utf8');
for (const pattern of PATTERNS) {
if (pattern.test(text)) {
offenders.push(`${root}/${name}`);
break;
}
}
}
}
if (offenders.length) {
console.error('Raw status color pairs (use @include status-variant($color, $bg, $border) from _mixins.scss):');
for (const f of offenders) console.error(' ' + f);
process.exit(1);
}
console.log('status scss one-door: OK');