pbakaus/impeccable · error · Error
config.exclude, if present, must be a string array
Error message
config.exclude, if present, must be a string array
What it means
validateConfig() treats cfg.exclude as optional, but when present it must be an Array (the next check then requires its items to be non-empty strings). Passing exclude as a single string — the most tempting shorthand — fails this check. exclude filters the files list during injection.
Solutions
- Make exclude an array of strings: "exclude": ["node_modules", "dist/**"]
- Or remove the exclude key entirely when no exclusions are needed — it is optional
- Confirm with `--check` that exclude parses as an array
Example fix
// before "exclude": "node_modules" // after "exclude": ["node_modules"]
Defensive patterns
Strategy: validation
Validate before calling
if (cfg.exclude !== undefined && !Array.isArray(cfg.exclude)) {
throw new TypeError('config.exclude must be an array of strings');
} Type guard
const hasValidExcludeShape = (cfg) => cfg.exclude === undefined || Array.isArray(cfg.exclude);
Prevention
- Remember exclude mirrors files' shape: array of strings, never a bare glob string
- Omit exclude when there is nothing to exclude — it is optional
- Automate config linting so a string-typed exclude fails in CI, not mid live session
When it happens
Trigger: Config contains "exclude": "node_modules" or "exclude": "dist/**" (string) instead of an array; exclude set to an object or number.
Common situations: Authors expecting glob-string semantics like files sometimes has; converting between config formats and losing the brackets; exclude copied from a CLI flag example.
Related errors
- config.exclude must contain only non-empty strings
- config.commentSyntax must be 'html' or 'jsx'
- config.cspChecked, if present, must be a boolean
- config.files must contain only non-empty strings
- config.files (non-empty string array) required
AI-assisted analysis of pbakaus/impeccable@f88b2837a7 (2026-08-18).
Data as JSON: /api/errors/9efc780988d6b9b9.
Report an issue: GitHub.
Appendix: source
Thrown at skill/scripts/live-inject.mjs:459
}
return new RegExp('^' + re + '$');
}
// ---------------------------------------------------------------------------
// Core operations
// ---------------------------------------------------------------------------
function validateConfig(cfg) {
if (!cfg || typeof cfg !== 'object') throw new Error('config.json must be an object');
if (!Array.isArray(cfg.files) || cfg.files.length === 0) {
throw new Error('config.files (non-empty string array) required');
}
if (!cfg.files.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.files must contain only non-empty strings');
}
if (cfg.exclude !== undefined) {
if (!Array.isArray(cfg.exclude)) {
throw new Error('config.exclude, if present, must be a string array');
}
if (!cfg.exclude.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.exclude must contain only non-empty strings');
}
}
if (typeof cfg.insertBefore !== 'string' && typeof cfg.insertAfter !== 'string') {
throw new Error('config.insertBefore or config.insertAfter (string) required');
}
if (cfg.commentSyntax !== 'html' && cfg.commentSyntax !== 'jsx') {
throw new Error("config.commentSyntax must be 'html' or 'jsx'");
}
if (cfg.cspChecked !== undefined && typeof cfg.cspChecked !== 'boolean') {
throw new Error("config.cspChecked, if present, must be a boolean");
}
}
// ---------------------------------------------------------------------------
// Auto-executeView on GitHub (pinned to f88b2837a7)