Skip to content

The design language that makes your AI harness better at design.

JavaScript

Fix: ignoreFiles waives a linked stylesheet's page-level findings (#1087) (#1092)

Abdul Wahabdad8dbb3aac2
diff --git a/crates/browser/tests/consent_hiding.rs b/crates/browser/tests/consent_hiding.rs
index 5e6b6001f..abd794124 100644
--- a/crates/browser/tests/consent_hiding.rs
+++ b/crates/browser/tests/consent_hiding.rs
@@ -111,6 +111,7 @@ const KEEP: ScanOptions = ScanOptions {
keep_consent_banners: true,
keep_overlays: false,
unreported_rules: Vec::new(),
+ ignored_linked_stylesheet: None,
};
#[test]
diff --git a/crates/browser/tests/overlay_hiding.rs b/crates/browser/tests/overlay_hiding.rs
index fefc76779..bc7f06606 100644
--- a/crates/browser/tests/overlay_hiding.rs
+++ b/crates/browser/tests/overlay_hiding.rs
@@ -102,6 +102,7 @@ const KEEP: ScanOptions = ScanOptions {
keep_consent_banners: false,
keep_overlays: true,
unreported_rules: Vec::new(),
+ ignored_linked_stylesheet: None,
};
#[test]
diff --git a/crates/detect/src/cli.rs b/crates/detect/src/cli.rs
index 4221ec891..543ebd74b 100644
--- a/crates/detect/src/cli.rs
+++ b/crates/detect/src/cli.rs
@@ -618,6 +618,10 @@ fn detect_cli(args_in: &[String], io: &mut Io, engines: &Engines) -> Result<i32,
keep_consent_banners: has(&args, "--no-consent-hiding"),
keep_overlays: has(&args, "--no-overlay-hiding"),
unreported_rules: unreported_rules(&detection_config.ignore_rules, &scopes),
+ ignored_linked_stylesheet: Some({
+ let (cwd, config) = (cwd.clone(), detection_config.clone());
+ std::rc::Rc::new(move |path: &str| should_ignore_detection_file(path, &cwd, &config))
+ }),
};
let targets: Vec<String> = expand_joined_url_targets(
args.iter()
diff --git a/crates/detect/src/engines.rs b/crates/detect/src/engines.rs
index f9b69f3ad..dc417818c 100644
--- a/crates/detect/src/engines.rs
+++ b/crates/detect/src/engines.rs
@@ -41,6 +41,10 @@ pub struct ScanOptions {
/// browser engine reports them as before; it only stops letting one of
/// them stand in for another rule's finding (vanishing ink).
pub unreported_rules: Vec<String>,
+ /// Whether `detector.ignoreFiles` waives a linked stylesheet (given its
+ /// absolute path). The static HTML engine still reads it for the cascade
+ /// but leaves it out of the page-level pattern scan.
+ pub ignored_linked_stylesheet: Option<Rc<dyn Fn(&str) -> bool>>,
}
/// A URL scan's findings plus the notes the CLI prints about how the page
diff --git a/crates/hook/src/hook.rs b/crates/hook/src/hook.rs
index a0e702e79..bb8acd8be 100644
--- a/crates/hook/src/hook.rs
+++ b/crates/hook/src/hook.rs
@@ -216,10 +216,7 @@ pub fn run_hook(rt: &Runtime, stdin: &str) -> RunResult {
last_skip = "extension";
continue;
}
- let rel_for_match = relativize(rt, file_path, &project_cwd);
- if matches_any_glob_list(&rel_for_match, &config.ignore_files)
- || matches_any_glob_list(file_path, &config.ignore_files)
- {
+ if is_ignored_file(&rt.proc_cwd, file_path, &project_cwd, &config.ignore_files) {
last_skip = "config-ignore-file";
continue;
}
@@ -768,10 +765,7 @@ pub fn run_stop_hook(rt: &Runtime, stdin: &str) -> RunResult {
if !ALLOWED_EXTS.contains(&ext.as_str()) && configured.is_none() {
continue;
}
- let rel = relativize(rt, file_path, &project_cwd);
- if matches_any_glob_list(&rel, &config.ignore_files)
- || matches_any_glob_list(file_path, &config.ignore_files)
- {
+ if is_ignored_file(&rt.proc_cwd, file_path, &project_cwd, &config.ignore_files) {
continue;
}
if !exists(file_path) || !is_scan_target_inside_project(rt, file_path, &project_cwd) {
diff --git a/crates/hook/src/hook_lib.rs b/crates/hook/src/hook_lib.rs
index b4b58f3c3..ae908aced 100644
--- a/crates/hook/src/hook_lib.rs
+++ b/crates/hook/src/hook_lib.rs
@@ -1060,7 +1060,20 @@ pub fn quote_command_arg(value: &str, win32: bool) -> String {
/// JS: relativize(filePath, cwd)
pub fn relativize(rt: &Runtime, file_path: &str, cwd: &str) -> String {
- let rel = rt.relative(cwd, file_path);
+ relativize_from(&rt.proc_cwd, file_path, cwd)
+}
+
+/// Whether `detector.ignoreFiles` waives `file_path`: its path relative to
+/// `cwd` (when inside it) or the path as given matches a glob.
+pub fn is_ignored_file(proc_cwd: &str, file_path: &str, cwd: &str, globs: &[String]) -> bool {
+ matches_any_glob_list(&relativize_from(proc_cwd, file_path, cwd), globs)
+ || matches_any_glob_list(file_path, globs)
+}
+
+/// [`relativize`] for a caller that holds the process cwd instead of a
+/// [`Runtime`].
+fn relativize_from(proc_cwd: &str, file_path: &str, cwd: &str) -> String {
+ let rel = jsp::relative(proc_cwd, cwd, file_path);
if rel.is_empty() || rel.starts_with("..") {
return file_path.to_string();
}
@@ -1561,6 +1574,9 @@ pub fn should_emit_ack_for_file(file_path: &str, config: &HookConfig) -> bool {
#[derive(Default, Clone)]
pub struct HookScanOptions {
pub design_system: Option<Rc<DesignSystem>>,
+ /// `ScanOptions::ignored_linked_stylesheet`, from the hook's
+ /// `detector.ignoreFiles`.
+ pub ignored_linked_stylesheet: Option<Rc<dyn Fn(&str) -> bool>>,
}
impl HookScanOptions {
@@ -1580,6 +1596,7 @@ impl HookScanOptions {
keep_consent_banners: false,
keep_overlays: false,
unreported_rules: Vec::new(),
+ ignored_linked_stylesheet: self.ignored_linked_stylesheet.clone(),
}
}
}
@@ -1591,18 +1608,26 @@ pub fn design_system_options(config: &HookConfig, project_cwd: &str) -> HookScan
}
HookScanOptions {
design_system: load_design_system_for_cwd(project_cwd).map(Rc::new),
+ ..HookScanOptions::default()
}
}
-/// Resolve design rules for the edited workspace without moving hook state.
+/// Resolve design rules for the edited workspace without moving hook state,
+/// and waive the linked stylesheets `detector.ignoreFiles` covers, matched
+/// like the edited file ([`is_ignored_file`]).
pub fn design_system_options_for_file(
rt: &Runtime,
config: &HookConfig,
project_cwd: &str,
file_path: &str,
) -> HookScanOptions {
+ let ignored_linked_stylesheet: Option<Rc<dyn Fn(&str) -> bool>> = {
+ let (proc_cwd, globs, cwd) =
+ (rt.proc_cwd.clone(), config.ignore_files.clone(), project_cwd.to_string());
+ Some(Rc::new(move |path: &str| is_ignored_file(&proc_cwd, path, &cwd, &globs)))
+ };
if !config.design_system_enabled {
- return HookScanOptions::default();
+ return HookScanOptions { ignored_linked_stylesheet, ..HookScanOptions::default() };
}
let project = impeccable_context::context::resolve_project(
project_cwd,
@@ -1618,7 +1643,7 @@ pub fn design_system_options_for_file(
} else {
&project.repo_root
};
- design_system_options(config, root)
+ HookScanOptions { ignored_linked_stylesheet, ..design_system_options(config, root) }
}
/// The detector the hook drives: the regex engine from `impeccable-detect`
diff --git a/crates/html/src/cascade/build.rs b/crates/html/src/cascade/build.rs
index a49c12e83..230e3f0bf 100644
--- a/crates/html/src/cascade/build.rs
+++ b/crates/html/src/cascade/build.rs
@@ -90,18 +90,26 @@ fn resolve_linked_css_path(file_dir: &str, href: &str) -> String {
/// resolved relative to `file_dir` (query/hash stripped), joined with `\n`.
/// `warn` receives the JS `process.stderr.write` notice for an unreadable
/// linked stylesheet (once per resolved path per scan).
+///
+/// Returns that text plus a second one for the page-level pattern scan: the
+/// same join minus the linked sheets `ignored` accepts (given the resolved
+/// path). The cascade keeps the full text.
pub fn collect_static_css_text(
doc: &StaticDocument,
file_dir: &Path,
profile: Option<&dyn ProfileSink>,
file_path: &str,
warn: Option<&dyn Fn(&str)>,
-) -> String {
+ ignored: Option<&dyn Fn(&str) -> bool>,
+) -> (String, String) {
let mut style_texts: Vec<String> = Vec::new();
+ let mut pattern_texts: Vec<String> = Vec::new();
let mut warned_missing_stylesheets: std::collections::HashSet<String> =
std::collections::HashSet::new();
for style_el in doc.query_selector_all("style") {
- style_texts.push(style_el.text_content());
+ let text = style_el.text_content();
+ pattern_texts.push(text.clone());
+ style_texts.push(text);
}
let file_dir_str = file_dir.to_string_lossy().into_owned();
for link in doc.query_selector_all("link") {
@@ -117,7 +125,13 @@ pub fn collect_static_css_text(
|| std::fs::read(&css_path),
);
match read {
- Ok(bytes) => style_texts.push(String::from_utf8_lossy(&bytes).into_owned()),
+ Ok(bytes) => {
+ let text = String::from_utf8_lossy(&bytes).into_owned();
+ if !ignored.is_some_and(|f| f(&css_path)) {
+ pattern_texts.push(text.clone());
+ }
+ style_texts.push(text);
+ }
Err(_) => {
if warned_missing_stylesheets.insert(css_path.clone()) {
if let Some(warn) = warn {
@@ -129,7 +143,7 @@ pub fn collect_static_css_text(
}
}
}
- style_texts.join("\n")
+ (style_texts.join("\n"), pattern_texts.join("\n"))
}
static PSEUDO_RULE_RE: Lazy<Regex> = Lazy::new(|| {
diff --git a/crates/html/src/engine.rs b/crates/html/src/engine.rs
index 0889598d8..a498356f6 100644
--- a/crates/html/src/engine.rs
+++ b/crates/html/src/engine.rs
@@ -89,6 +89,10 @@ pub struct DetectHtmlOptions<'a> {
/// Sink for the JS `process.stderr.write` notices (unreadable linked
/// stylesheets); `None` drops them.
pub warn: Option<&'a dyn Fn(&str)>,
+ /// Whether `detector.ignoreFiles` waives a linked stylesheet (given its
+ /// resolved path). It is still read for the cascade but leaves the
+ /// page-level pattern scan; `None` keeps every linked sheet in.
+ pub ignored_linked_stylesheet: Option<&'a dyn Fn(&str) -> bool>,
/// A rule pack's static-document hook: rules over the parsed page.
pub static_rule_pack: Option<&'static dyn StaticRulePack>,
/// The same pack's engine-wide text hook. An HTML file gets **one** pack
@@ -223,7 +227,14 @@ pub fn detect_html_source(
Meta::new("parse-html", "parse-document", fp),
|| StaticDocument::parse(html),
);
- let css_text = collect_static_css_text(&doc, &file_dir, profile, fp, options.warn);
+ let (css_text, pattern_css_text) = collect_static_css_text(
+ &doc,
+ &file_dir,
+ profile,
+ fp,
+ options.warn,
+ options.ignored_linked_stylesheet,
+ );
build_static_style_map(&mut doc, css_text.as_str(), profile, fp);
// A stylesheet the engine could not read may round any card it never saw
// a radius for; the side-accent gate keeps those findings.
@@ -354,7 +365,7 @@ pub fn detect_html_source(
class_attr_parts.push(c.to_string());
}
}
- let mut style_parts = vec![css_text.clone()];
+ let mut style_parts = vec![pattern_css_text];
style_parts.extend(style_attr_parts);
let corpora = HtmlPatternCorpora {
style_text: style_parts.join("\n"),
@@ -480,7 +491,7 @@ pub fn unsupported_selectors(html: &str, file_path: &Path) -> Vec<String> {
.map(|p| p.to_path_buf())
.unwrap_or_default();
let mut doc = StaticDocument::parse(html);
- let css_text = collect_static_css_text(&doc, &file_dir, None, &file_str, None);
+ let (css_text, _) = collect_static_css_text(&doc, &file_dir, None, &file_str, None, None);
build_static_style_map(&mut doc, &css_text, None, &file_str);
doc.unsupported_selectors()
}
diff --git a/crates/html/src/static_engine.rs b/crates/html/src/static_engine.rs
index 284e58739..a381819e5 100644
--- a/crates/html/src/static_engine.rs
+++ b/crates/html/src/static_engine.rs
@@ -78,6 +78,7 @@ impl HtmlEngine for StaticHtmlEngine {
text_content_analyzers: Some(&analyzers),
profile: profile_sink.as_ref().map(|s| s as &dyn ProfileSink),
warn: Some(&warn),
+ ignored_linked_stylesheet: options.ignored_linked_stylesheet.as_deref(),
static_rule_pack: self.static_rule_pack,
rule_pack: options.rule_pack,
};
diff --git a/crates/html/tests/ignored_linked_stylesheet.rs b/crates/html/tests/ignored_linked_stylesheet.rs
new file mode 100644
index 000000000..67584c2e2
--- /dev/null
+++ b/crates/html/tests/ignored_linked_stylesheet.rs
@@ -0,0 +1,42 @@
+use impeccable_html::{detect_html_source, DetectHtmlOptions};
+
+/// Rule ids the static engine reports for a page linking `vendor/lib.css`,
+/// with that sheet waived or not.
+fn ids(waive_sheet: bool) -> Vec<String> {
+ let dir = std::env::temp_dir().join(format!(
+ "impeccable-ignored-sheet-{}-{waive_sheet}",
+ std::process::id()
+ ));
+ std::fs::create_dir_all(dir.join("vendor")).unwrap();
+ std::fs::write(
+ dir.join("vendor/lib.css"),
+ ".unused-text { background-image: linear-gradient(90deg, #f00, #00f); background-clip: text; -webkit-background-clip: text; color: transparent; }\n\
+ .pale { color: #ccc; background: #fff; }\n",
+ )
+ .unwrap();
+ let html = r#"<!doctype html><html lang="en"><head><meta charset="utf-8"><title>mock</title>
+<link rel="stylesheet" href="vendor/lib.css"></head>
+<body><main><h1>Mock</h1><p class="pale">Pale body copy on white</p></main></body></html>"#;
+ let ignored = |path: &str| path.replace('\\', "/").ends_with("vendor/lib.css");
+ let options = DetectHtmlOptions {
+ ignored_linked_stylesheet: waive_sheet.then_some(&ignored as &dyn Fn(&str) -> bool),
+ ..Default::default()
+ };
+ let ids = detect_html_source(html, &dir.join("index.html"), &options)
+ .into_iter()
+ .map(|f| f.antipattern)
+ .collect();
+ let _ = std::fs::remove_dir_all(&dir);
+ ids
+}
+
+#[test]
+fn a_waived_sheet_leaves_the_pattern_scan_but_still_styles_the_page() {
+ let kept = ids(false);
+ assert!(kept.iter().any(|id| id == "gradient-text"), "{kept:?}");
+ assert!(kept.iter().any(|id| id == "low-contrast"), "{kept:?}");
+
+ let waived = ids(true);
+ assert!(!waived.iter().any(|id| id == "gradient-text"), "{waived:?}");
+ assert!(waived.iter().any(|id| id == "low-contrast"), "{waived:?}");
+}
diff --git a/crates/wasm/src/exports_detect.rs b/crates/wasm/src/exports_detect.rs
index c618d9497..9f275a349 100644
--- a/crates/wasm/src/exports_detect.rs
+++ b/crates/wasm/src/exports_detect.rs
@@ -140,6 +140,7 @@ pub fn detect_html_source_json(html: &str, file_path: &str, options_json: &str)
text_content_analyzers: Some(&analyzers),
profile: None,
warn: None,
+ ignored_linked_stylesheet: None,
static_rule_pack: installed_static_rule_pack(),
rule_pack: crate::installed_rule_pack(),
},
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index ae35dc1a3..c4c3c873f 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -206,6 +206,7 @@ Examples:
Then `files = walkDir(resolved, config.extensions).filter(f => !shouldIgnoreDetectionFile(f, cwd, config))`. The walk collects built-in scannable extensions plus any `detector.extensions` from cwd config (empty under `--no-config`). If `files.length > 50 && stdin.isTTY && !json && !quiet`: `stderr> \nFound ${n} files (${htmlCount} HTML) in ${target}.\nScanning may take a while${htmlCount > 10 ? ' (static HTML/CSS processes each HTML file individually)' : ''}.\nTarget a specific subdirectory to narrow scope.\n` then readline prompt `Continue? [Y/n] ` on stderr; empty or `/^y(es)?$/i` continues; otherwise `stderr> Aborted.\n`, `exit 0`. Then `buildImportGraph(files)` → reverse map; each file scanned with its own options; findings from a file that is imported get `f.importedBy = [basename(importer), ...]` (Set iteration order).
- **File**: skipped if `shouldIgnoreDetectionFile`; else `detectLocalFile`.
- `detectLocalFile(fp, opts)`: a configured `detector.extensions` entry matching the file (longest suffix) picks the engine (`html` → `detectHtml(fp, opts)`, `text` → `detectText`); otherwise extension (lowercased) in `HTML_EXTENSIONS = {'.html','.htm'}` → `detectHtml(fp, opts)`; else `detectText(readFileSync(fp,'utf-8'), fp, opts)`. The design hook uses the same rule.
+ - **Linked stylesheets (#1087)**: the static HTML engine reads every local `<link rel=stylesheet>` for the cascade, but a linked sheet that `detector.ignoreFiles` waives is left out of the page-level pattern scan, so a pattern found only in that sheet is no longer reported under the page at line 0. Element rules still apply its styles through the cascade, and sheets that are not waived join the pattern scan as before. The design hook waives linked sheets the same way, matching each one the way it matches the edited file.
- **Regex-only note (#884)**: after every target is scanned (never in stdin mode), unless `--json`/`--quiet`, if `n > 0` local files went to `detectText` (by the `detectLocalFile` routing above, so a configured `html`-engine extension is not counted): `stderr> \n${n} file${n === 1 ? '' : 's'} scanned with regex matching only${exts.length ? ` (${exts.join(', ')})` : ''}.\nRules that need a parsed page (tiny-text, low-contrast and other element rules) did not run on them; findings are an undercount, not a clean bill of health.\n` where `exts` is the sorted set of those files' lowercased extensions (`extFromFilePath`, empty ones dropped). Then the full scan: `ports` = the sorted, deduplicated `port` of every scanned directory that matched `FRAMEWORK_CONFIGS` (whether or not the dev-server nudge found it listening); when non-empty, `For the full check, scan ${ports.length === 1 ? 'the running app' : 'each running app'}:\n` followed by ` npx impeccable detect http://localhost:${port}\n` per port, else `For the full check, scan the running dev server (npx impeccable detect http://localhost:PORT) or a static site's built .html.\n`. Then, only when `exts` intersects `HTML_LIKE_TEMPLATE_EXTS = ['.astro', '.svelte', '.vue']` (in that order, `t` = the intersection): `${t.join('/')} files can take the HTML engine instead: add { "ext": "${t[0]}", "engine": "html" } under detector.extensions in .impeccable/config.json (trades the regex rules and line numbers for the element rules).\n`. JSX/TSX get no opt-in line because the HTML parser reads nothing useful from them. The note precedes the findings output and changes neither stdout nor the exit code.
4. Post-filter: `filterDetectionFindings(all, config)` (ignoreRules/ignoreValues), then `filterByScopes(all, scopes)` (keeps findings whose rule declares any requested scope; empty scopes = no filter), then `--no-advisory` drop.
5. Partition `{primary, advisory}` by `f.advisory === true || f.severity === 'advisory'`.
diff --git a/tests/oracle/cases/detect.mjs b/tests/oracle/cases/detect.mjs
index 01790a551..7038f18b1 100644
--- a/tests/oracle/cases/detect.mjs
+++ b/tests/oracle/cases/detect.mjs
@@ -225,6 +225,37 @@ function Thumb({ url }: { url?: string }) {
args: ['--json', 'index.html'],
},
+ // #1087: a linked stylesheet that detector.ignoreFiles waives is not
+ // reported again under the page that links it; the page's own <style>
+ // still is.
+ ...[
+ ['detect-linked-sheet-dir-json', null, '.'],
+ ['detect-linked-sheet-dir-ignored-json', ['vendor/**'], '.'],
+ ['detect-linked-sheet-file-ignored-json', ['vendor/**'], 'index.html'],
+ ].map(([id, ignoreFiles, target]) => ({
+ id, verb: 'detect',
+ setup: (ws) => {
+ fs.writeFileSync(path.join(ws, 'package.json'), '{"name":"linked-sheet"}\n');
+ fs.mkdirSync(path.join(ws, 'vendor'));
+ fs.writeFileSync(
+ path.join(ws, 'index.html'),
+ '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>mock</title>\n<style>.band { background: repeating-linear-gradient(45deg, #111 0 10px, #eee 10px 20px); }</style>\n<link rel="stylesheet" href="vendor/lib.css"></head><body><main><h1>Mock</h1></main></body></html>\n',
+ );
+ fs.writeFileSync(
+ path.join(ws, 'vendor', 'lib.css'),
+ '.unused-text { background-image: linear-gradient(90deg, #f00, #00f); background-clip: text; -webkit-background-clip: text; color: transparent; }\n',
+ );
+ if (ignoreFiles) {
+ fs.mkdirSync(path.join(ws, '.impeccable'));
+ fs.writeFileSync(
+ path.join(ws, '.impeccable', 'config.json'),
+ JSON.stringify({ detector: { ignoreFiles } }) + '\n',
+ );
+ }
+ },
+ args: ['--json', target],
+ })),
+
// A DESIGN.md that declares a purple switches ai-color-palette's
// purple/violet forms off for its project, in the static and the regex
// engines alike, and text mode says so; a DESIGN.md without one changes
diff --git a/tests/oracle/cases/hooks.mjs b/tests/oracle/cases/hooks.mjs
index 3c660c9b6..63da30aa5 100644
--- a/tests/oracle/cases/hooks.mjs
+++ b/tests/oracle/cases/hooks.mjs
@@ -120,6 +120,21 @@ export default [
setup: (ws) => { fs.mkdirSync(`${ws}/.impeccable`, { recursive: true }); fs.writeFileSync(`${ws}/.impeccable/config.json`, JSON.stringify({ detector: { ignoreFiles: ['src/components/**'] } }, null, 2) + '\n'); },
stdin: claudeEdit('src/components/Card.module.css'), files: CACHE_FILES,
},
+ // #1087: a linked stylesheet detector.ignoreFiles waives is not reported
+ // again under the page that links it.
+ ...[['hook-linked-sheet', null], ['hook-linked-sheet-ignored', ['src/vendor/**']]].map(([id, ignoreFiles]) => ({
+ id, verb: 'hook', workspace: 'hook-project',
+ setup: (ws) => {
+ fs.mkdirSync(`${ws}/src/vendor`, { recursive: true });
+ fs.writeFileSync(`${ws}/src/vendor/lib.css`, '.unused-text { background-image: linear-gradient(90deg, #f00, #00f); background-clip: text; -webkit-background-clip: text; color: transparent; }\n');
+ fs.writeFileSync(`${ws}/src/linked.html`, '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>mock</title>\n<link rel="stylesheet" href="vendor/lib.css"></head><body><main><h1>Mock</h1></main></body></html>\n');
+ if (ignoreFiles) {
+ fs.mkdirSync(`${ws}/.impeccable`, { recursive: true });
+ fs.writeFileSync(`${ws}/.impeccable/config.json`, JSON.stringify({ detector: { ignoreFiles } }, null, 2) + '\n');
+ }
+ },
+ stdin: claudeEdit('src/linked.html'), files: CACHE_FILES,
+ })),
{
id: 'hook-config-per-edit-all', verb: 'hook', workspace: 'hook-project',
setup: (ws) => { fs.mkdirSync(`${ws}/.impeccable`, { recursive: true }); fs.writeFileSync(`${ws}/.impeccable/config.json`, JSON.stringify({ hook: { perEditRules: 'all' } }, null, 2) + '\n'); },
diff --git a/tests/oracle/golden/detect-linked-sheet-dir-ignored-json.json b/tests/oracle/golden/detect-linked-sheet-dir-ignored-json.json
new file mode 100644
index 000000000..2a6784357
--- /dev/null
+++ b/tests/oracle/golden/detect-linked-sheet-dir-ignored-json.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "[\n {\n \"antipattern\": \"repeating-stripes-gradient\",\n \"name\": \"Repeating-gradient stripes\",\n \"description\": \"Repeating-gradient stripes used as surface decoration are a recurring generated-UI signature. Reach for a deliberate texture or leave the surface plain.\",\n \"severity\": \"advisory\",\n \"category\": \"slop\",\n \"file\": \"<WS>/index.html\",\n \"line\": 0,\n \"snippet\": \"repeating-gradient decorative stripes\",\n \"advisory\": true\n }\n]\n",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {}
+}
diff --git a/tests/oracle/golden/detect-linked-sheet-dir-json.json b/tests/oracle/golden/detect-linked-sheet-dir-json.json
new file mode 100644
index 000000000..82e4a92a8
--- /dev/null
+++ b/tests/oracle/golden/detect-linked-sheet-dir-json.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "[\n {\n \"antipattern\": \"gradient-text\",\n \"name\": \"Gradient text\",\n \"description\": \"Gradient text is decorative rather than meaningful — a common AI tell, especially on headings and metrics. Use solid colors for text.\",\n \"severity\": \"warning\",\n \"category\": \"slop\",\n \"file\": \"<WS>/index.html\",\n \"line\": 0,\n \"snippet\": \"background-clip: text + gradient\"\n },\n {\n \"antipattern\": \"repeating-stripes-gradient\",\n \"name\": \"Repeating-gradient stripes\",\n \"description\": \"Repeating-gradient stripes used as surface decoration are a recurring generated-UI signature. Reach for a deliberate texture or leave the surface plain.\",\n \"severity\": \"advisory\",\n \"category\": \"slop\",\n \"file\": \"<WS>/index.html\",\n \"line\": 0,\n \"snippet\": \"repeating-gradient decorative stripes\",\n \"advisory\": true\n },\n {\n \"antipattern\": \"gradient-text\",\n \"name\": \"Gradient text\",\n \"description\": \"Gradient text is decorative rather than meaningful — a common AI tell, especially on headings and metrics. Use solid colors for text.\",\n \"severity\": \"warning\",\n \"category\": \"slop\",\n \"file\": \"<WS>/vendor/lib.css\",\n \"line\": 1,\n \"snippet\": \"background-clip: text + gradient\"\n }\n]\n",
+ "stderr": "",
+ "exit": 2,
+ "signal": null,
+ "files": {}
+}
diff --git a/tests/oracle/golden/detect-linked-sheet-file-ignored-json.json b/tests/oracle/golden/detect-linked-sheet-file-ignored-json.json
new file mode 100644
index 000000000..2a6784357
--- /dev/null
+++ b/tests/oracle/golden/detect-linked-sheet-file-ignored-json.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "[\n {\n \"antipattern\": \"repeating-stripes-gradient\",\n \"name\": \"Repeating-gradient stripes\",\n \"description\": \"Repeating-gradient stripes used as surface decoration are a recurring generated-UI signature. Reach for a deliberate texture or leave the surface plain.\",\n \"severity\": \"advisory\",\n \"category\": \"slop\",\n \"file\": \"<WS>/index.html\",\n \"line\": 0,\n \"snippet\": \"repeating-gradient decorative stripes\",\n \"advisory\": true\n }\n]\n",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {}
+}
diff --git a/tests/oracle/golden/hook-linked-sheet-ignored.json b/tests/oracle/golden/hook-linked-sheet-ignored.json
new file mode 100644
index 000000000..70d307440
--- /dev/null
+++ b/tests/oracle/golden/hook-linked-sheet-ignored.json
@@ -0,0 +1,10 @@
+{
+ "stdout": "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":\"[impeccable@1] Design hook scanned src/linked.html. No deterministic design-quality issues found. That does not mean the design is good: keep following the project design system and the impeccable skill guidance.\"}}",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {
+ ".impeccable/config.json": "{\n \"detector\": {\n \"ignoreFiles\": [\n \"src/vendor/**\"\n ]\n }\n}\n",
+ ".impeccable/hook.cache.json": "{\"version\":1,\"sessions\":{\"s1\":{\"updatedAt\": <EPOCH>,\"files\":{\"<WS>/src/linked.html\":{\"editCount\":1,\"findings\":[],\"cleanAcked\":true}}}}}"
+ }
+}
diff --git a/tests/oracle/golden/hook-linked-sheet.json b/tests/oracle/golden/hook-linked-sheet.json
new file mode 100644
index 000000000..c4fb0586f
--- /dev/null
+++ b/tests/oracle/golden/hook-linked-sheet.json
@@ -0,0 +1,9 @@
+{
+ "stdout": "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":\"[impeccable@1] Design hook findings requiring review in src/linked.html (1 issue(s)):\\n- [gradient-text] Gradient text. Gradient text is decorative rather than meaningful — a common AI tell, especially on headings and metrics. Use solid colors for text.\\n\\nTriage each finding, then state in your reply what you fixed, what you suppressed, and what you left standing:\\n- Real design problem: fix it. Keep intentional design as designed.\\n- Confident false positive or sanctioned exception (an intentional demo or fixture, documentation of bad design, literal or domain-appropriate motion, a choice the user confirmed): persist the narrowest ignore yourself and disclose it. Run `<HOOK_ADMIN_CMD> ignore-value <rule> \\\"<value>\\\" --reason \\\"<who decided: evidence>\\\"` with the pair shown on the finding line, or value \\\"*\\\" plus `--file <path>` when the line shows none. Write \\\"user confirmed\\\" in a reason only when the user did.\\n- Unsure: leave it as is and ask the user in one line.\\nSelf-serve ends at ignore-value: `ignore-file` and `ignore-rule` need the user's explicit approval, and never add an ignore to push a blocked write through. Full suppression ladder: /impeccable hooks.\"}}",
+ "stderr": "",
+ "exit": 0,
+ "signal": null,
+ "files": {
+ ".impeccable/hook.cache.json": "{\"version\":1,\"sessions\":{\"s1\":{\"updatedAt\": <EPOCH>,\"files\":{\"<WS>/src/linked.html\":{\"editCount\":1,\"findings\":[\"gradient-text:0:background-clip: text + gradient\"]}},\"footerShown\":true}}}"
+ }
+}