#!/usr/bin/env node /** * CSS isolation audit — flags top-level class selectors in extension * CSS that aren't `.wp-*` or `.var-N` prefixed. * * Why this matters: unprefixed selectors can collide with ComfyUI's * own CSS, PrimeVue utility classes, or another custom node's styles. * The `.wp-*` namespace + `@layer wp-extension` wrap are our two * layers of defense; this script catches the convention violation * before it ships. * * Scope: * - src/components/**\/*.{vue,css} * - src/extension/**\/*.css * - src/widgets/**\/*.css * * NOT included: src/manager/** (separate bundle with its own scope — * Tailwind utilities + global tokens.css are intentional there). * * Run: pnpm check:css-isolation * Exits 0 if clean, 1 if violations found. */ import { readFile } from "node:fs/promises"; import { glob } from "node:fs/promises"; import { resolve } from "node:path"; const ROOT = resolve(import.meta.dirname, ".."); const ALLOWED_PREFIXES = [ /^\.wp-/, // primary namespace /^\.var-[1-8]\b/, // variable color helpers ]; /** Known legacy BEM-style class roots that pre-date the `wp-*` * convention. Each entry is paired with a TODO note — renaming these * to `wp-*` is a follow-up; meanwhile the audit silences them so * CI stays green. Add to this list ONLY for existing classes that * need a tracked rename; new code must use `wp-*` from the start. */ const LEGACY_ALLOWLIST = new Set([ // (empty — all previous entries have been properly prefixed) ]); const SCOPES = [ "src/components/**/*.vue", "src/components/**/*.css", "src/extension/**/*.css", "src/widgets/**/*.css", ]; /** Strip Vue `