{"record":{"id":"4e9eb8ee42eb8bc4","repo":"pbakaus/impeccable","slug":"flag-requires-a-non-empty-glob","errorCode":null,"errorMessage":"${flag} requires a non-empty glob","messagePattern":"(.+?) requires a non-empty glob","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/scripts/hook-admin.mjs","lineNumber":634,"sourceCode":"}\n\nfunction addIgnoreFile(cwd, args) {\n  const parsed = parseIgnoreFileArgs(args);\n  const glob = parsed.glob;\n  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') {","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/plugin/skills/impeccable/scripts/hook-admin.mjs#L616-L652","documentation":"requireGlob() trims its input and rejects an empty result. It guards the `--file=` / `--files=` forms (and the space-separated `--file` form) against an empty value. Historically an empty glob was dropped by filter(Boolean), so `--file=` reported success while storing an entry scoped to no files — effectively a silent project-wide suppression. The guard makes that an explicit error.","triggerScenarios":"Passing `--file=` or `--files=` with nothing after the equals sign; passing `--file \"\"` (an explicitly empty quoted token).","commonSituations":"A shell variable that expanded to empty feeding `--file=\"$VAR\"`; templated commands where the glob is conditionally empty.","solutions":["Supply a real glob, e.g. `--file \"src/widget.js\"`.","If the glob comes from a variable, guard the whole call so the flag is omitted when the variable is empty rather than passed empty."],"exampleFix":"# before\nimpeccable hooks ignore-value r v --file=\n\n# after\nimpeccable hooks ignore-value r v --file \"src/widget.js\"","handlingStrategy":"validation","validationCode":"function requireGlob(raw, flag) {\n  const glob = String(raw ?? '').trim();\n  if (!glob) throw new Error(`${flag} requires a non-empty glob`);\n  return glob;\n}","typeGuard":"function isNonEmptyGlob(raw) {\n  return typeof raw === 'string' && raw.trim() !== '';\n}","tryCatchPattern":null,"preventionTips":["Never pass an empty --file=/--files= value; guard variables before substitution.","When templating, omit the --file flag entirely if its value is empty rather than passing --file=."],"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"}