{"record":{"id":"9b4e97ba8c88b842","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":null,"httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/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/plugin/skills/impeccable/scripts/hook-admin.mjs#L621-L657","documentation":"requireGlob() rejects a value that is itself a flag (begins with `--`). This stops `--file --reason \"why\"` from consuming `--reason` as the glob, which previously stored value=\"* why\", files=[\"--reason\"] and reported success while matching nothing. Same silent-no-op class as an unknown flag folding into the value.","triggerScenarios":"`--file` (or `--files`) immediately followed by another flag token such as `--reason`, `--shared`, or any `--foo`, because the next token is taken as the glob value.","commonSituations":"Ordering flags so a flag lands where a glob is expected; a wrapper that concatenates flags in the wrong order.","solutions":["Place a real glob immediately after --file, then other flags after it: `--file \"src/widget.js\" --reason \"why\"`."],"exampleFix":"# before\nimpeccable hooks ignore-value r v --file --reason \"why\"\n\n# after\nimpeccable hooks ignore-value r v --file \"src/widget.js\" --reason \"why\"","handlingStrategy":"validation","validationCode":"function requireGlob(raw, flag) {\n  const glob = String(raw ?? '').trim();\n  if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);\n  return glob;\n}","typeGuard":"function looksLikeFlag(v) {\n  return typeof v === 'string' && v.startsWith('--');\n}","tryCatchPattern":null,"preventionTips":["Always place a real glob token immediately after --file/--files.","Order flags so a glob never has to follow --file directly after another flag."],"tags":["cli","argument-parsing","detector-config"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}