pbakaus/impeccable · error · TargetArgError
TARGET_VALUE_MISSING
TARGET_VALUE_MISSING
Error message
--target requires a path value.
What it means
Thrown by parseTargetPath() in strict mode when --target or -t is the last token, or its following token starts with '-' (i.e. looks like another flag). The parser refuses to consume a flag-shaped token as a path, so '--target --port 3000' is treated as a missing value rather than path='--port'. Only fires when options.strict is true; in non-strict the missing value is silently ignored and targetPath stays null.
Source
Thrown at plugin/skills/impeccable/scripts/lib/target-args.mjs:21
super(message);
this.name = 'TargetArgError';
this.code = code;
}
}
export function parseTargetPath(args = [], { strict = false } = {}) {
let targetPath = null;
for (let i = 0; i < args.length; i++) {
const arg = String(args[i]);
if (arg === '--target' || arg === '-t') {
const next = args[i + 1];
if (next && !String(next).startsWith('-')) {
targetPath = String(next);
i++;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
continue;
}
if (arg.startsWith('--target=')) {
const value = arg.slice('--target='.length);
if (value) {
targetPath = value;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
}
}
return targetPath;
}
export function parseTargetOptions(args = [], options = {}) {View on GitHub (pinned to d14711ae3d)
Solutions
- Supply a concrete path token after --target/-t that does not start with '-' (e.g. --target src/index.html).
- If the value legitimately could be flag-adjacent, use the '--target=PATH' equals form instead, which is parsed separately and allows any value.
- Catch TargetArgError and check err.code === 'TARGET_VALUE_MISSING' to print a usage hint and exit non-zero instead of crashing.
- If silent tolerance is desired, call without { strict: true } and check the returned targetPath for null afterwards.
Example fix
// before
const { targetPath } = parseTargetOptions(args, { strict: true });
// after
defaults to non-strict:
const { targetPath } = parseTargetOptions(args);
if (!targetPath) { console.error('--target requires a path'); process.exit(2); }
or keep strict and handle:
try { parseTargetOptions(args, { strict: true }); }
catch (err) { if (err.code === 'TARGET_VALUE_MISSING') { printUsage(); process.exit(2); } throw err; } Defensive patterns
Strategy: validation
Validate before calling
import { parseTargetPath } from './lib/target-args.mjs';
// Pre-check in non-strict mode to avoid the throw.
const targetPath = parseTargetPath(args); // strict defaults to false
if (!targetPath) {
console.error('--target requires a path value.');
process.exit(2);
} Try / catch
import { parseTargetOptions } from './lib/target-args.mjs';
try {
const { targetPath } = parseTargetOptions(args, { strict: true });
} catch (err) {
if (err.code === 'TARGET_VALUE_MISSING') {
printUsage();
process.exit(2);
}
throw err;
} Prevention
- Prefer the '--target=PATH' equals form when scripting — it sidesteps flag-adjacency ambiguity.
- Validate interpolated argv values before building the array so an empty variable doesn't emit a bare --target.
- Match on err.code (TARGET_VALUE_MISSING), not err.message, to stay stable across rewordings.
When it happens
Trigger: Calling parseTargetOptions(['--target'], { strict: true }); '--target -t' (next is a flag); '--target' as the final argv element; '-t' followed by nothing. Common in CLI wrappers that pass { strict: true } to fail fast on malformed invocations.
Common situations: User forgets the path after --target; shell quoting drops an empty argument; a script concatenates flags and accidentally orders --target before another flag; using '-t' shorthand with no value. The TargetArgError exposes .code = 'TARGET_VALUE_MISSING' for programmatic handling.
Related errors
- TARGET_VALUE_MISSING
- Unknown ignore-rule flag: ${arg}
- Pass a rule id, e.g. ${IMPECCABLE_COMMAND} hooks ignore-rule
- overused-font is value-specific by default. Use ${IMPECCABLE
- --reason is not supported for ignore-file because detector.i
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/ba7c9195e19a484e.
Report an issue: GitHub.