Skip to content

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

JavaScript

Fix: detect honors a configured extension's engine (#795) (#1013)

Abdul Wahabf288af4781fc
diff --git a/crates/detect/src/cli.rs b/crates/detect/src/cli.rs
index 69a921658..edef81598 100644
--- a/crates/detect/src/cli.rs
+++ b/crates/detect/src/cli.rs
@@ -15,7 +15,7 @@ use crate::design_system::{load_design_system_for_target, DesignSystemCache};
use crate::detect_text::{detect_text, TextOptions};
use crate::engines::{EngineError, Engines, ScanOptions};
use crate::file_system::{
- build_import_graph_reporting, detect_framework_config, is_html_path, is_port_listening,
+ build_import_graph_reporting, detect_framework_config, is_port_listening, uses_html_engine,
walk_dir_reporting,
};
use crate::jsp;
@@ -296,7 +296,7 @@ impl<'a> Ctx<'a> {
file_path: &str,
options: &ScanOptions,
) -> Result<Vec<Finding>, EngineError> {
- if is_html_path(file_path) {
+ if uses_html_engine(file_path, &self.config.extensions) {
return self
.engines
.html
@@ -793,7 +793,10 @@ fn scan_targets(
for (dir, message) in walk_failures {
ctx.report_local_scan_failure(&dir, &message);
}
- let html_count = files.iter().filter(|f| is_html_path(f)).count();
+ let html_count = files
+ .iter()
+ .filter(|f| uses_html_engine(f, &ctx.config.extensions))
+ .count();
if files.len() > 50 && ctx.stdin_tty && !ctx.json_mode && !ctx.quiet_mode {
ctx.io.err(&format!(
"\nFound {} files ({} HTML) in {}.\nScanning may take a while{}.\nTarget a specific subdirectory to narrow scope.\n",
diff --git a/crates/detect/src/config.rs b/crates/detect/src/config.rs
index 8b0be6fd6..a4ab306e1 100644
--- a/crates/detect/src/config.rs
+++ b/crates/detect/src/config.rs
@@ -5,6 +5,7 @@
use impeccable_core::findings::Finding;
use impeccable_core::js::{self, math_round, number_to_string, parse_float, parse_int};
+use impeccable_core::js_ext_b::utf16_len;
use once_cell::sync::Lazy;
use regex::Regex;
use serde_json::{Map, Value};
@@ -88,7 +89,7 @@ pub struct DetectionConfig {
pub ignore_values: Vec<IgnoreValueEntry>,
pub design_system_enabled: Option<bool>,
pub advisory_rules: Option<String>,
- pub extensions: Vec<String>,
+ pub extensions: Vec<ExtensionEntry>,
}
impl DetectionConfig {
@@ -133,27 +134,31 @@ fn apply_detection_config_source(config: &mut DetectionConfig, raw: Option<&Map<
config.ignore_values = merge_ignore_values(&config.ignore_values, values);
}
if let Some(Value::Array(list)) = raw.get("extensions") {
- config.extensions = unique_strings(
- config
- .extensions
- .iter()
- .cloned()
- .chain(normalize_detection_extensions(list))
- .collect(),
- );
+ config.extensions = merge_extensions(&config.extensions, list);
}
}
-fn normalize_detection_extensions(entries: &[Value]) -> Vec<String> {
+#[derive(Debug, Clone, PartialEq)]
+pub struct ExtensionEntry {
+ pub ext: String,
+ pub engine: String,
+}
+
+/// JS: template-extensions.mjs#normalizeExtensionEntries
+pub fn normalize_extension_entries(entries: &[Value]) -> Vec<ExtensionEntry> {
let mut out = Vec::new();
for entry in entries {
- let raw = match entry {
- Value::String(s) => Some(s.as_str()),
- Value::Object(o) => match o.get("ext") {
- Some(Value::String(s)) => Some(s.as_str()),
- _ => None,
- },
- _ => None,
+ let (raw, is_string, engine_text) = match entry {
+ Value::String(s) => (Some(s.as_str()), true, false),
+ Value::Object(o) => (
+ match o.get("ext") {
+ Some(Value::String(s)) => Some(s.as_str()),
+ _ => None,
+ },
+ false,
+ o.get("engine") == Some(&Value::String("text".to_string())),
+ ),
+ _ => (None, false, false),
};
let Some(raw) = raw else { continue };
let mut ext = js::to_lower_case(js::trim(raw));
@@ -163,11 +168,58 @@ fn normalize_detection_extensions(entries: &[Value]) -> Vec<String> {
if !ext.starts_with('.') {
ext = format!(".{ext}");
}
- out.push(ext);
+ let engine = if !is_string && engine_text {
+ "text"
+ } else {
+ "html"
+ };
+ out.push(ExtensionEntry {
+ ext,
+ engine: engine.to_string(),
+ });
}
out
}
+/// JS: template-extensions.mjs#mergeExtensions
+pub fn merge_extensions(existing: &[ExtensionEntry], incoming: &[Value]) -> Vec<ExtensionEntry> {
+ // JS Map semantics: insertion order, later set replaces the value in place.
+ let mut map: Vec<ExtensionEntry> = Vec::new();
+ for e in existing.iter().cloned().chain(normalize_extension_entries(incoming)) {
+ match map.iter_mut().find(|slot| slot.ext == e.ext) {
+ Some(slot) => *slot = e,
+ None => map.push(e),
+ }
+ }
+ map
+}
+
+/// JS: template-extensions.mjs#matchConfiguredExtension
+pub fn match_configured_extension<'a>(
+ file_path: &str,
+ extensions: &'a [ExtensionEntry],
+) -> Option<&'a ExtensionEntry> {
+ if extensions.is_empty() {
+ return None;
+ }
+ let name = js::to_lower_case(&jsp::basename(file_path));
+ if name.is_empty() {
+ return None;
+ }
+ let mut best: Option<&ExtensionEntry> = None;
+ for entry in extensions {
+ if utf16_len(&name) > utf16_len(&entry.ext)
+ && name.ends_with(entry.ext.as_str())
+ && best
+ .map(|b| utf16_len(&entry.ext) > utf16_len(&b.ext))
+ .unwrap_or(true)
+ {
+ best = Some(entry);
+ }
+ }
+ best
+}
+
fn unique_strings(values: Vec<String>) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
for v in values {
@@ -1170,10 +1222,24 @@ mod tests {
r#"{"detector":{"extensions":[{"ext":".html.erb","engine":"html"},"blade.php"]}}"#,
)
.unwrap();
+ let entry = |ext: &str, engine: &str| ExtensionEntry {
+ ext: ext.to_string(),
+ engine: engine.to_string(),
+ };
+ let config = read_detection_config(dir.to_str().unwrap());
+ assert_eq!(
+ config.extensions,
+ vec![entry(".html.erb", "html"), entry(".blade.php", "html")]
+ );
+ std::fs::write(
+ impeccable.join("config.local.json"),
+ r#"{"detector":{"extensions":[{"ext":".html.erb","engine":"text"}]}}"#,
+ )
+ .unwrap();
let config = read_detection_config(dir.to_str().unwrap());
assert_eq!(
config.extensions,
- vec![".html.erb".to_string(), ".blade.php".to_string()]
+ vec![entry(".html.erb", "text"), entry(".blade.php", "html")]
);
let _ = std::fs::remove_dir_all(&dir);
}
diff --git a/crates/detect/src/file_system.rs b/crates/detect/src/file_system.rs
index 97f9bf0e8..193b8a90c 100644
--- a/crates/detect/src/file_system.rs
+++ b/crates/detect/src/file_system.rs
@@ -8,6 +8,7 @@ use std::time::{Duration, Instant};
use once_cell::sync::Lazy;
use regex::Regex;
+use crate::config::{match_configured_extension, ExtensionEntry};
use crate::jsp;
use crate::util::{re, read_text, ANY, D, WS};
@@ -41,7 +42,7 @@ pub fn has_scannable_extension(filename: &str) -> bool {
}
/// Built-in scannable extensions plus configured suffix matches (#822).
-fn has_scannable_extension_with(filename: &str, extra_exts: &[String]) -> bool {
+fn has_scannable_extension_with(filename: &str, extra_exts: &[ExtensionEntry]) -> bool {
let lower = impeccable_core::js::to_lower_case(filename);
if SCANNABLE_EXTENSIONS.contains(&jsp::extname(&lower).as_str()) {
return true;
@@ -51,14 +52,7 @@ fn has_scannable_extension_with(filename: &str, extra_exts: &[String]) -> bool {
return true;
}
}
- let name_len = lower.encode_utf16().count();
- for ext in extra_exts {
- let ext_len = ext.encode_utf16().count();
- if name_len > ext_len && lower.ends_with(ext.as_str()) {
- return true;
- }
- }
- false
+ match_configured_extension(filename, extra_exts).is_some()
}
/// `HTML_EXTENSIONS.has(path.extname(filePath).toLowerCase())`.
@@ -66,6 +60,15 @@ pub fn is_html_path(file_path: &str) -> bool {
HTML_EXTENSIONS.contains(&impeccable_core::js::to_lower_case(&jsp::extname(file_path)).as_str())
}
+/// Engine routing shared by `detect` and the hook: a configured
+/// `detector.extensions` entry picks its engine, else `.html`/`.htm` (#795).
+pub fn uses_html_engine(file_path: &str, extensions: &[ExtensionEntry]) -> bool {
+ match match_configured_extension(file_path, extensions) {
+ Some(c) => c.engine == "html",
+ None => is_html_path(file_path),
+ }
+}
+
/// JS: file-system.mjs#walkDir. Files in `readdirSync` order (the OS order,
/// which Node does not sort either), recursive; an unreadable dir yields [].
pub fn walk_dir(dir: &str) -> Vec<String> {
@@ -76,7 +79,7 @@ pub fn walk_dir(dir: &str) -> Vec<String> {
/// reported and skipped rather than silently yielding nothing (#711).
pub fn walk_dir_reporting(
dir: &str,
- extra_exts: &[String],
+ extra_exts: &[ExtensionEntry],
on_read_error: &mut dyn FnMut(&str, &std::io::Error),
) -> Vec<String> {
let mut files = Vec::new();
@@ -556,11 +559,19 @@ mod tests {
assert!(has_scannable_extension("A.HTML"));
assert!(!has_scannable_extension("a.php"));
assert!(is_html_path("/x/y.HTM"));
- let erb = vec![".html.erb".to_string()];
+ let entry = |ext: &str, engine: &str| ExtensionEntry {
+ ext: ext.to_string(),
+ engine: engine.to_string(),
+ };
+ let erb = vec![entry(".html.erb", "html")];
assert!(!has_scannable_extension("first.html.erb"));
assert!(has_scannable_extension_with("first.html.erb", &erb));
assert!(has_scannable_extension_with("A.HTML.ERB", &erb));
assert!(!has_scannable_extension_with("notes.txt", &erb));
+ assert!(uses_html_engine("/x/first.html.erb", &erb));
+ assert!(!uses_html_engine("/x/first.html", &[entry(".html", "text")]));
+ assert!(!uses_html_engine("/x/a.vue", &erb));
+ assert!(uses_html_engine("/x/a.HTM", &[]));
}
#[test]
diff --git a/crates/hook/src/before_edit.rs b/crates/hook/src/before_edit.rs
index 30d5ea360..efcb73aae 100644
--- a/crates/hook/src/before_edit.rs
+++ b/crates/hook/src/before_edit.rs
@@ -4,6 +4,7 @@
use impeccable_core::findings::Finding;
use impeccable_core::js;
+use impeccable_detect::file_system::uses_html_engine;
use once_cell::sync::Lazy;
use regex::Regex;
use serde_json::{Map, Value};
@@ -812,10 +813,7 @@ fn main_flow(rt: &Runtime, stdin: &str) -> Out {
return skip(&audit, "config-ignore-file");
}
let scan = design_system_options_for_file(rt, &config, &cwd, &file_path);
- let use_html_engine = match configured {
- Some(c) => c.engine == "html",
- None => ext_name == ".html" || ext_name == ".htm",
- };
+ let use_html_engine = uses_html_engine(&file_path, &config.extensions);
let findings = if use_html_engine {
match detect_proposed_html(rt, &content, &file_path, &scan) {
Ok(f) => f,
diff --git a/crates/hook/src/hook.rs b/crates/hook/src/hook.rs
index 224035a27..251831976 100644
--- a/crates/hook/src/hook.rs
+++ b/crates/hook/src/hook.rs
@@ -4,6 +4,7 @@
use impeccable_core::findings::Finding;
use impeccable_core::js;
+use impeccable_detect::file_system::uses_html_engine;
use serde_json::{Map, Value};
use std::collections::HashMap;
@@ -254,10 +255,7 @@ pub fn run_hook(rt: &Runtime, stdin: &str) -> RunResult {
}
}
}
- let use_html_engine = match configured {
- Some(c) => c.engine == "html",
- None => ext == ".html" || ext == ".htm",
- };
+ let use_html_engine = uses_html_engine(file_path, &config.extensions);
if primary_files.contains(file_path) {
if harness == "claude" {
stop_baseline::capture(rt, &event, &mut cache, &session_id, file_path, use_html_engine);
@@ -762,10 +760,7 @@ pub fn run_stop_hook(rt: &Runtime, stdin: &str) -> RunResult {
if crate::hook_lib::has_live_preview_markers(&content) {
continue;
}
- let use_html_engine = match configured {
- Some(c) => c.engine == "html",
- None => ext == ".html" || ext == ".htm",
- };
+ let use_html_engine = uses_html_engine(file_path, &config.extensions);
let scan = scans.entry(file_path.clone()).or_insert_with(|| {
design_system_options_for_file(rt, &config, &project_cwd, file_path)
});
diff --git a/crates/hook/src/hook_lib.rs b/crates/hook/src/hook_lib.rs
index 529a9bb0a..d43fbf402 100644
--- a/crates/hook/src/hook_lib.rs
+++ b/crates/hook/src/hook_lib.rs
@@ -16,6 +16,9 @@ use impeccable_detect::config::{
normalize_ignore_rule, normalize_ignore_value, normalize_ignore_value_entries, DetectionConfig,
IgnoreValueEntry,
};
+pub use impeccable_detect::config::{
+ match_configured_extension, merge_extensions, normalize_extension_entries, ExtensionEntry,
+};
use impeccable_detect::design_system::{load_design_system_for_cwd, resolve_design_md_path, DesignSystem};
use impeccable_detect::detect_text::{detect_text, TextOptions};
use impeccable_detect::engines::{HtmlEngine, ScanOptions};
@@ -353,12 +356,6 @@ pub fn is_native_platform(platform: Option<&str>) -> bool {
// ── config ────────────────────────────────────────────────────────────────
-#[derive(Debug, Clone, PartialEq)]
-pub struct ExtensionEntry {
- pub ext: String,
- pub engine: String,
-}
-
#[derive(Debug, Clone, PartialEq)]
pub struct Limits {
pub max_findings: f64,
@@ -566,81 +563,6 @@ pub fn merge_ignore_values(
map.into_iter().map(|(_, e)| e).collect()
}
-/// JS: template-extensions.mjs#normalizeExtensionEntries
-pub fn normalize_extension_entries(entries: &[Value]) -> Vec<ExtensionEntry> {
- let mut out = Vec::new();
- for entry in entries {
- let (raw, is_string, engine_text) = match entry {
- Value::String(s) => (Some(s.as_str()), true, false),
- Value::Object(o) => (
- match o.get("ext") {
- Some(Value::String(s)) => Some(s.as_str()),
- _ => None,
- },
- false,
- o.get("engine") == Some(&Value::String("text".to_string())),
- ),
- _ => (None, false, false),
- };
- let Some(raw) = raw else { continue };
- let mut ext = js::to_lower_case(js::trim(raw));
- if ext.is_empty() {
- continue;
- }
- if !ext.starts_with('.') {
- ext = format!(".{ext}");
- }
- let engine = if !is_string && engine_text {
- "text"
- } else {
- "html"
- };
- out.push(ExtensionEntry {
- ext,
- engine: engine.to_string(),
- });
- }
- out
-}
-
-/// JS: template-extensions.mjs#mergeExtensions
-pub fn merge_extensions(existing: &[ExtensionEntry], incoming: &[Value]) -> Vec<ExtensionEntry> {
- let mut map: Vec<(String, ExtensionEntry)> = Vec::new();
- for e in existing {
- map_set(&mut map, e.ext.clone(), e.clone());
- }
- for e in normalize_extension_entries(incoming) {
- map_set(&mut map, e.ext.clone(), e);
- }
- map.into_iter().map(|(_, e)| e).collect()
-}
-
-/// JS: template-extensions.mjs#matchConfiguredExtension
-pub fn match_configured_extension<'a>(
- file_path: &str,
- extensions: &'a [ExtensionEntry],
-) -> Option<&'a ExtensionEntry> {
- if extensions.is_empty() {
- return None;
- }
- let name = js::to_lower_case(&jsp::basename(file_path));
- if name.is_empty() {
- return None;
- }
- let mut best: Option<&ExtensionEntry> = None;
- for entry in extensions {
- if utf16_len(&name) > utf16_len(&entry.ext)
- && name.ends_with(entry.ext.as_str())
- && best
- .map(|b| utf16_len(&entry.ext) > utf16_len(&b.ext))
- .unwrap_or(true)
- {
- best = Some(entry);
- }
- }
- best
-}
-
// ── cache ─────────────────────────────────────────────────────────────────
/// The `.impeccable/hook.cache.json` document, kept as ordered JSON so
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index 35d810ce1..eed9a060f 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -193,7 +193,7 @@ Examples:
- not listening: `\n${name} project detected (${basename(configPath)}).\nStart the dev server and scan via URL for best results:\n npx impeccable detect http://localhost:${port}\n\n`
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)`: extension (lowercased) in `HTML_EXTENSIONS = {'.html','.htm'}` → `detectHtml(fp, opts)`; else `detectText(readFileSync(fp,'utf-8'), fp, opts)`.
+ - `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.
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'`.
@@ -294,7 +294,7 @@ Optional keys added later by engines (appended after the above): `ignoreValue` (
"designSystem": { "enabled": true }, "advisoryRules": "include"|"exclude" },
"hook": { "consent": "accepted"|"declined", ... }, "updateCheck": true }
```
-- `readDetectionConfig(root)`: start `{ignoreRules:[],ignoreFiles:[],ignoreValues:[],designSystem:{enabled:true},extensions:[]}`; for shared then local: apply legacy `raw.hook.*` section then `raw.detector.*`. Arrays are unioned (`uniqueStrings`, String-coerced); ignoreValues merged by key `rule\0value\0sortedFiles.join('\x1f')` (later wins); `designSystem.enabled` false only when literally `false`; `advisoryRules` copied only if `'include'|'exclude'`; `extensions` unions normalized `detector.extensions` entries (string or `{ext, engine}` → leading-dot lowercase; engine ignored by detect). Invalid/non-array `extensions` skipped. Invalid JSON / non-object files are ignored silently. **No validation errors are ever raised by the CLI**; the only validation of ignore lists lives in `skill/scripts/lib/staleness-deep.mjs checkDetectorIgnores` (doctor): unknown `ignoreRules` ids vs live `ANTIPATTERNS` → finding `detector-ignore-rules-unknown` (severity `mention`); non-glob `ignoreFiles` entries that don't exist → `detector-ignore-files-missing`.
+- `readDetectionConfig(root)`: start `{ignoreRules:[],ignoreFiles:[],ignoreValues:[],designSystem:{enabled:true},extensions:[]}`; for shared then local: apply legacy `raw.hook.*` section then `raw.detector.*`. Arrays are unioned (`uniqueStrings`, String-coerced); ignoreValues merged by key `rule\0value\0sortedFiles.join('\x1f')` (later wins); `designSystem.enabled` false only when literally `false`; `advisoryRules` copied only if `'include'|'exclude'`; `extensions` merges normalized `detector.extensions` entries by ext, later source wins (string → engine `html`; `{ext, engine}` → `text` only when engine is literally `"text"`). Invalid/non-array `extensions` skipped. Invalid JSON / non-object files are ignored silently. **No validation errors are ever raised by the CLI**; the only validation of ignore lists lives in `skill/scripts/lib/staleness-deep.mjs checkDetectorIgnores` (doctor): unknown `ignoreRules` ids vs live `ANTIPATTERNS` → finding `detector-ignore-rules-unknown` (severity `mention`); non-glob `ignoreFiles` entries that don't exist → `detector-ignore-files-missing`.
- `normalizeIgnoreValue(v)`: trim, strip one leading/trailing quote, `+`→space, collapse whitespace, lowercase. Rules lowercased/trimmed.
- `normalizeIgnoreValueEntries`: keeps `{rule, value, [files], [createdAt], [reason]}` in **that key order**; `file` (string) and `files` merged, trimmed, deduped.
- Glob → regex: `**` → `.*` (swallowing a following `/`), `*` → `[^/]*`, `?` → `[^/]`, `{a,b}` → `(?:a|b)`, regex specials escaped; anchored `^...$`. `matchesAnyGlob` tests the `/`-normalized path and its basename.
diff --git a/tests/oracle/DELTAS.md b/tests/oracle/DELTAS.md
index 1f8309d6a..1cb7da78f 100644
--- a/tests/oracle/DELTAS.md
+++ b/tests/oracle/DELTAS.md
@@ -7038,3 +7038,7 @@ Product decision (maintainer, 2026-10-11). Decision-page cards on direction and
Re-recorded from the binary and reviewed by hand, 38 goldens plus one new. Every change is one of the lines named above.
Review round, 2026-10-12 (PR review). Seed references are now salted per user (`IMPECCABLE_SEED_SALT` pins it in the oracle), so every `seed-*` golden's `SEED REFERENCE` line carries a new value. The roll record names its seed by reference and drops `at` (its age is the file's mtime), so the `seed-*` goldens that snapshot `roll.json` show `"seed":"seed:<hex>"` where they showed the key and the time. `grounded` joins the card kinds, which adds it to the `question-schema` note and the `question-update-card-identity-missing` refusal. `question-update-comps-next` declares kinds on its cards, so it reaches NEXT again; the history lines that named it as an accepted delta no longer start with its id, so the case is checked, and its golden changes only by the payload digest. Re-recorded from the binary and reviewed by hand, 29 goldens.
+
+## Recorded 2026-10-12: detect honors a configured extension's engine (#795)
+
+`detect` dropped the `engine` of a `detector.extensions` entry and routed by `.html`/`.htm` alone, so a template declared `{"ext": ".html.erb", "engine": "html"}` went to the text engine in `detect` and to the static HTML engine in the hook. Both now route through one predicate: a configured entry picks the engine (a bare string means `html`), otherwise `.html`/`.htm`. Built-in `.vue`, `.svelte`, `.astro` and `.blade.php` are unchanged. Re-recorded from the binary and reviewed by hand: in `detect-config-extensions-dir-json` the configured `first.html.erb` now reports exactly what `plain.html` (the same bytes) reports, one `broken-image` at line 0; it loses the text engine's `overused-font` and line-1 `broken-image`. New case `detect-config-extensions-file-json` scans that file directly and reports the same finding. `detect-config-extensions-dir-no-config` did not move.
diff --git a/tests/oracle/cases/detect.mjs b/tests/oracle/cases/detect.mjs
index 4b56443c6..0643d6a1f 100644
--- a/tests/oracle/cases/detect.mjs
+++ b/tests/oracle/cases/detect.mjs
@@ -174,6 +174,7 @@ function Thumb({ url }: { url?: string }) {
{ id: 'detect-config-from-subdir', verb: 'detect', workspace: 'detect-config', cwd: 'src', args: ['--json', 'page.html'] },
// detector.extensions in directory walks (#822)
{ id: 'detect-config-extensions-dir-json', verb: 'detect', workspace: 'detect-extensions', args: ['--json', '--no-design-system', 'app/views'] },
+ { id: 'detect-config-extensions-file-json', verb: 'detect', workspace: 'detect-extensions', args: ['--json', '--no-design-system', 'app/views/first.html.erb'] },
{ id: 'detect-config-extensions-dir-no-config', verb: 'detect', workspace: 'detect-extensions', args: ['--no-config', '--json', 'app/views'] },
// A file in one project must not pick up another project's DESIGN.md
{ id: 'detect-config-cross-project', verb: 'detect', workspace: 'detect-config', args: ['--json', `<REPO>/tests/fixtures/antipatterns/blinking-cursor.html`], isolateHome: false },
diff --git a/tests/oracle/golden/detect-config-extensions-dir-json.json b/tests/oracle/golden/detect-config-extensions-dir-json.json
index 11ca9ae10..2cca13068 100644
--- a/tests/oracle/golden/detect-config-extensions-dir-json.json
+++ b/tests/oracle/golden/detect-config-extensions-dir-json.json
@@ -1,5 +1,5 @@
{
- "stdout": "[\n {\n \"antipattern\": \"overused-font\",\n \"name\": \"Overused font\",\n \"description\": \"Inter, Roboto, Fraunces, Geist, Plus Jakarta Sans, and Space Grotesk are used on so many sites they no longer feel distinctive. Each new wave of AI-generated UIs converges on the same handful of faces. Choose a face that gives your interface personality.\",\n \"severity\": \"warning\",\n \"category\": \"slop\",\n \"file\": \"<WS>/app/views/first.html.erb\",\n \"line\": 1,\n \"snippet\": \"font-family: Inter\"\n },\n {\n \"antipattern\": \"broken-image\",\n \"name\": \"Broken or placeholder image\",\n \"description\": \"<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.\",\n \"severity\": \"warning\",\n \"category\": \"quality\",\n \"file\": \"<WS>/app/views/first.html.erb\",\n \"line\": 1,\n \"snippet\": \"<img alt=\\\"probe\\\">\"\n },\n {\n \"antipattern\": \"broken-image\",\n \"name\": \"Broken or placeholder image\",\n \"description\": \"<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.\",\n \"severity\": \"warning\",\n \"category\": \"quality\",\n \"file\": \"<WS>/app/views/plain.html\",\n \"line\": 0,\n \"snippet\": \"<img> with no src attribute\"\n }\n]\n",
+ "stdout": "[\n {\n \"antipattern\": \"broken-image\",\n \"name\": \"Broken or placeholder image\",\n \"description\": \"<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.\",\n \"severity\": \"warning\",\n \"category\": \"quality\",\n \"file\": \"<WS>/app/views/first.html.erb\",\n \"line\": 0,\n \"snippet\": \"<img> with no src attribute\"\n },\n {\n \"antipattern\": \"broken-image\",\n \"name\": \"Broken or placeholder image\",\n \"description\": \"<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.\",\n \"severity\": \"warning\",\n \"category\": \"quality\",\n \"file\": \"<WS>/app/views/plain.html\",\n \"line\": 0,\n \"snippet\": \"<img> with no src attribute\"\n }\n]\n",
"stderr": "",
"exit": 2,
"signal": null,
diff --git a/tests/oracle/golden/detect-config-extensions-file-json.json b/tests/oracle/golden/detect-config-extensions-file-json.json
new file mode 100644
index 000000000..36019595b
--- /dev/null
+++ b/tests/oracle/golden/detect-config-extensions-file-json.json
@@ -0,0 +1,7 @@
+{
+ "stdout": "[\n {\n \"antipattern\": \"broken-image\",\n \"name\": \"Broken or placeholder image\",\n \"description\": \"<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.\",\n \"severity\": \"warning\",\n \"category\": \"quality\",\n \"file\": \"<WS>/app/views/first.html.erb\",\n \"line\": 0,\n \"snippet\": \"<img> with no src attribute\"\n }\n]\n",
+ "stderr": "",
+ "exit": 2,
+ "signal": null,
+ "files": {}
+}