{"record":{"id":"5de7361b392b877a","repo":"pbakaus/impeccable","slug":"flag-requires-a-glob-got-the-flag-glob","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/f88b2837a7d7c3182e46307bbbb091a1ed547571/skill/scripts/hook-admin.mjs#L621-L657","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Put an actual glob immediately after --file: `--file \"src/widget.js\" --reason \"...\"`.","Or use the equals form `--file=src/widget.js` so the value is unambiguous.","If you do not want a file scope, remove --file entirely."],"exampleFix":"# before\nimpeccable hooks ignore-value design-system-font-size 16 --file --reason \"tokens\"\n\n# after\nimpeccable hooks ignore-value design-system-font-size 16 --file \"src/widget.js\" --reason \"tokens\"","handlingStrategy":"validation","validationCode":"function buildArgs(rule, value, scope, reason) {\n  const args = ['hooks', 'ignore-value', rule, value];\n  if (scope) {\n    if (String(scope).startsWith('--')) throw new Error('scope must be a glob, not a flag');\n    args.push('--file', scope);\n  }\n  if (reason) args.push('--reason', reason);\n  return args;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always emit a glob immediately after --file/--files; use the = form when in doubt.","Order flags so value-taking flags are never adjacent to another flag with the value missing."],"tags":["cli","flag-as-value","hook-admin","ignore-value","glob"],"backgroundTag":"missing-flag-value","analyzedSha":"f88b2837a7d7c3182e46307bbbb091a1ed547571","analyzedAt":"2026-08-18T04:58:36.608Z","contentChangedAt":"2026-08-18T04:58:36.608Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}