Files
olivv-cs-ComfyUI-FunPack/tools/kit_lint/rules.js
T
digital-garbage 835fab7864 core+shell: the bridge, and the first module through it
One declaration does three jobs: renders the panel, carries the defaults, names
the values that come back. A module writes no DOM and reads no DOM.

Validation refuses rather than repairs -- unknown type, a renderer its type does
not have, a label that is not text, a default outside its own bounds, a when
naming a key the module never declared. A module that is wrong does not get a
best-effort panel; it does not load, and says why once.

Ordering is by declared relation and stage, never priority numbers, and a cycle
drops only the modules in it. Compatibility is by trait, never model name.

The shell hands a module { composer, values, on, shell } and nothing else: no
node, no document, no kit internals. It cannot style anything because it is
never given anything that could.

catalogue/hide.html puts one good module and five broken ones through the real
shell and shows the result: one panel, five absent, no placeholders. The lint
fixtures make the scanner prove it catches each rule, so a clean scan means
something.

First slice: modules/system/appearance. Two settings, an optional ui.js, and
clicking Light actually turns the app light.
2026-08-28 19:58:06 +03:00

37 lines
2.0 KiB
JavaScript

// What a module may not do, and what the kit may not do.
//
// These are the static half of rules 1 and 4. The runtime half is stronger --
// a module is never handed anything that could style or parse -- but a scanner
// catches the attempt in the file rather than at the moment it would have run,
// which is the difference between a failing test and a support ticket.
export const MODULE_RULES = [
{ name: "inline-style", why: "presentation belongs to the kit",
test: /\.style\s*[.[]|setAttribute\s*\(\s*['"`]style/ },
{ name: "style-attribute", why: "presentation belongs to the kit",
test: /\bstyle\s*=\s*['"`]/ },
{ name: "class-manipulation", why: "kit classes are the kit's; a module names elements, not classes",
test: /\bclassList\b|setAttribute\s*\(\s*['"`]class/ },
{ name: "raw-element", why: "every element comes from composer.<group>.<variant>()",
test: /document\s*\.\s*createElement|createElementNS/ },
{ name: "markup", why: "content is data; the kit renders it as text",
test: /\binnerHTML\b|\bouterHTML\b|insertAdjacentHTML|document\s*\.\s*write/ },
{ name: "stylesheet", why: "a module cannot ship styling, and cannot inject it either",
test: /adoptedStyleSheets|document\s*\.\s*head|<\s*(link|style)\b/ },
{ name: "hardcoded-colour", why: "colour comes from the theme tokens",
test: /#[0-9a-fA-F]{3,8}\b/ },
{ name: "hardcoded-size", why: "sizes come from the spacing and control scales",
test: /\b\d+(\.\d+)?px\b/ },
{ name: "eval", why: "nothing in a module is compiled at runtime",
test: /\beval\s*\(|new\s+Function\s*\(/ },
];
// The kit itself may style and may build elements -- that is its job -- but it
// must never interpret content.
export const KIT_RULES = [
{ name: "markup", why: "the kit renders content as text and never parses it",
test: /\binnerHTML\b|\bouterHTML\b|insertAdjacentHTML|document\s*\.\s*write/ },
{ name: "eval", why: "nothing in the kit is compiled at runtime",
test: /\beval\s*\(|new\s+Function\s*\(/ },
];