pbakaus/impeccable · error

--reason is not supported for ignore-file because…

Error message

--reason is not supported for ignore-file because detector.ignoreFiles stores globs only; use ignore-value when a documented rule-specific exception fits

What it means

Thrown by parseIgnoreFileArgs when --reason (space or equals form) is passed to `hooks ignore-file`. The detector.ignoreFiles config stores plain glob strings with no metadata, so a reason has nowhere to live and would otherwise be silently dropped. The error steers users to ignore-value, whose entries do carry a reason field.

Solutions

  1. Drop --reason from the ignore-file invocation; document the rationale elsewhere (commit message, PR description).
  2. If the suppression is actually a rule-specific exception for a value, use `hooks ignore-value <rule> <value> --file <glob> --reason "..."`, which stores the reason.

Example fix

# before
impeccable hooks ignore-file "src/legacy/**" --reason "frozen legacy area"

# after
impeccable hooks ignore-file "src/legacy/**"
impeccable hooks ignore-value overused-font Roboto --file "src/legacy/**" --reason "legacy brand font"
Defensive patterns

Strategy: validation

Validate before calling

const args = ['src/legacy/**'];
if (reason) {
  // ignore-file cannot store reasons; route rule-specific exceptions to ignore-value
  if (ruleId && value) args.push('--file', 'src/legacy/**'); // ignore-value path instead
}
// simplest: never append --reason to ignore-file invocations

Prevention

When it happens

Trigger: `hooks ignore-file "src/legacy/**" --reason "legacy code"`; `hooks ignore-file --shared build/** --reason=generated`; scripts that uniformly append --reason to every ignore subcommand.

Common situations: Users applying the same flag set across ignore-rule (which accepts --reason for symmetry) and ignore-file; audit trails that want to document why a glob is suppressed.

Related errors


AI-assisted analysis of pbakaus/impeccable@f88b2837a7 (2026-08-18). Data as JSON: /api/errors/c4d641629c6db813. Report an issue: GitHub.

Appendix: source

Thrown at skill/scripts/hook-admin.mjs:601

  const config = mergeDetectorConfig(readRawDetectorConfig(cwd));
  if (!config.ignoreRules.includes(rule)) config.ignoreRules.push(rule);
  writeDetectorConfig(cwd, config);
  return `Added "${rule}" to detector.ignoreRules. Current: ${config.ignoreRules.join(', ')}`;
}

function parseIgnoreFileArgs(args) {
  const positionals = [];
  let shared = false;
  let local = false;

  for (const raw of args) {
    const arg = String(raw || '');
    if (arg === '--shared') {
      shared = true;
    } else if (arg === '--local') {
      local = true;
    } else if (arg === '--reason' || arg.startsWith('--reason=')) {
      throw new Error('--reason is not supported for ignore-file because detector.ignoreFiles stores globs only; use ignore-value when a documented rule-specific exception fits');
    } else if (arg.startsWith('--')) {
      throw new Error(`Unknown ignore-file flag: ${arg}`);
    } else {
      positionals.push(arg);
    }
  }

  if (shared && local) throw new Error('Pass only one scope flag: --shared or --local');
  if (positionals.length > 1) throw new Error('Pass exactly one glob to ignore-file');

  return {
    glob: positionals[0],
    local,
  };
}

function addIgnoreFile(cwd, args) {
  const parsed = parseIgnoreFileArgs(args);

View on GitHub (pinned to f88b2837a7)