pbakaus/impeccable · error · Error

requires a glob, got the flag

Error message

${flag} requires a glob, got the flag ${glob}

What it means

Thrown by requireGlob when the token following --file/--files is itself a flag (starts with `--`). Without the guard, `--file --reason "why"` consumed the string '--reason' as the glob, left 'why' to fold into the value, and reported success while storing files=["--reason"] — a silent no-op suppression. The guard rejects flag-as-value to close that hole.

Solutions

  1. Put an actual glob immediately after --file: `--file "src/widget.js" --reason "..."`.
  2. Or use the equals form `--file=src/widget.js` so the value is unambiguous.
  3. If you do not want a file scope, remove --file entirely.

Example fix

# before
impeccable hooks ignore-value design-system-font-size 16 --file --reason "tokens"

# after
impeccable hooks ignore-value design-system-font-size 16 --file "src/widget.js" --reason "tokens"
Defensive patterns

Strategy: validation

Validate before calling

function buildArgs(rule, value, scope, reason) {
  const args = ['hooks', 'ignore-value', rule, value];
  if (scope) {
    if (String(scope).startsWith('--')) throw new Error('scope must be a glob, not a flag');
    args.push('--file', scope);
  }
  if (reason) args.push('--reason', reason);
  return args;
}

Prevention

When it happens

Trigger: `hooks ignore-value design-system-font-size 16 --file --reason "design tokens"`; `--files --shared`; any invocation where the glob was omitted and the next flag took its place.

Common situations: Reordering flags in a command template so --file ends up adjacent to another flag; users assuming --file persists until a value appears later in the command.

Related errors


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

Appendix: source

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

  if (!glob) throw new Error(`Pass a glob, e.g. ${IMPECCABLE_COMMAND} hooks ignore-file "src/legacy/**"`);
  const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local: parsed.local }));
  if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);
  const target = writeDetectorConfig(cwd, config, { local: parsed.local });
  const scope = parsed.local ? 'local detector.ignoreFiles' : 'shared detector.ignoreFiles';
  return `Added "${glob}" to ${scope} (${path.relative(cwd, target) || target}). Current: ${config.ignoreFiles.join(', ')}`;
}

// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
// success and wrote an entry with no files: the user asked to scope a rule to one
// file and silently got the project-wide suppression instead. Refuse it.
function requireGlob(raw, flag) {
  const glob = String(raw ?? '').trim();
  if (!glob) throw new Error(`${flag} requires a non-empty glob`);
  // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
  // as the scope and left the reason text to fold into the value, storing
  // value="* why" files=["--reason"] and reporting success. Same silent-no-op
  // class as an unknown flag folding into the value; refuse it the same way.
  if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
  return glob;
}

function parseIgnoreValueArgs(args) {
  const positionals = [];
  const files = [];
  let shared = false;
  let local = false;
  let reason = '';

  for (let i = 0; i < args.length; i++) {
    const arg = String(args[i] || '');
    if (arg === '--shared') {
      shared = true;
    } else if (arg === '--local') {
      local = true;
    } else if (arg === '--reason') {
      const chunks = [];

View on GitHub (pinned to f88b2837a7)