{"record":{"id":"5de7361b392b877a","repo":"pbakaus/impeccable","slug":"flag-requires-a-glob-got-the-flag-glob-5de736","errorCode":null,"errorMessage":"${flag} requires a glob, got the flag ${glob}","messagePattern":"(.+?) requires a glob, got the flag (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/hook-admin.mjs","lineNumber":639,"sourceCode":"  if (!glob) throw new Error(`Pass a glob, e.g. ${IMPECCABLE_COMMAND} hooks ignore-file \"src/legacy/**\"`);\n  const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local: parsed.local }));\n  if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);\n  const target = writeDetectorConfig(cwd, config, { local: parsed.local });\n  const scope = parsed.local ? 'local detector.ignoreFiles' : 'shared detector.ignoreFiles';\n  return `Added \"${glob}\" to ${scope} (${path.relative(cwd, target) || target}). Current: ${config.ignoreFiles.join(', ')}`;\n}\n\n// An empty glob used to be dropped by filter(Boolean), so `--file=` reported\n// success and wrote an entry with no files: the user asked to scope a rule to one\n// file and silently got the project-wide suppression instead. Refuse it.\nfunction requireGlob(raw, flag) {\n  const glob = String(raw ?? '').trim();\n  if (!glob) throw new Error(`${flag} requires a non-empty glob`);\n  // A following flag is not a glob. `--file --reason \"why\"` consumed `--reason`\n  // as the scope and left the reason text to fold into the value, storing\n  // value=\"* why\" files=[\"--reason\"] and reporting success. Same silent-no-op\n  // class as an unknown flag folding into the value; refuse it the same way.\n  if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);\n  return glob;\n}\n\nfunction parseIgnoreValueArgs(args) {\n  const positionals = [];\n  const files = [];\n  let shared = false;\n  let local = false;\n  let reason = '';\n\n  for (let i = 0; i < args.length; i++) {\n    const arg = String(args[i] || '');\n    if (arg === '--shared') {\n      shared = true;\n    } else if (arg === '--local') {\n      local = true;\n    } else if (arg === '--reason') {\n      const chunks = [];","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/skill/scripts/hook-admin.mjs#L621-L657","documentation":"Thrown by requireGlob() when the value supplied to --file/--files starts with `--`, i.e. the next token is itself a flag rather than a glob. Impeccable rejects this because an older parser consumed the following flag as the file scope, stored a junk scope like [\"--reason\"], and reported success — a silent no-op.","triggerScenarios":"`impeccable hooks ignore-value <rule> <value> --file --reason \"why\"` (--reason eaten as the glob), or any `--file --<anything>` where the next token begins with `--`. Also `--file=--shared` style.","commonSituations":"Reordering flags and forgetting the glob value, or a script that appends `--file` conditionally but the value variable is itself a flag string.","solutions":["Put an actual glob between --file and the next flag: `--file \"src/widget.css\" --reason \"why\"`.","Quote the glob and place it immediately after --file so the parser cannot grab the following flag.","Use the `--file=<glob>` equals form, which cannot swallow the next token."],"exampleFix":"// before\nimpeccable hooks ignore-value overused-font Inter --file --reason \"brand lock\"\n// after\nimpeccable hooks ignore-value overused-font Inter --file \"src/widget.css\" --reason \"brand lock\"","handlingStrategy":"validation","validationCode":"// Reject a flag-like value before passing it as a glob.\nconst glob = nextToken;\nif (typeof glob !== 'string' || glob.startsWith('--')) {\n  throw new Error('Expected a file glob, got a flag: ' + glob);\n}","typeGuard":"function isGlobNotFlag(v) {\n  return typeof v === 'string' && v.trim() !== '' && !v.startsWith('--');\n}","tryCatchPattern":null,"preventionTips":["Always place the glob immediately after --file.","When scripting, never let a flag string flow into the glob position.","Use --file=<glob> to make the boundary explicit."],"tags":["cli","validation","ignore-config","impeccable-hooks"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}