pbakaus/impeccable · warning · Error
config.exclude, if present, must be a string array
Error message
config.exclude, if present, must be a string array
What it means
Fourth validateConfig() check: cfg.exclude is optional, but if present it must be an array. Fires when exclude is set to a string, number, object, or null (null is typeof 'object' but not Array.isArray, so it triggers). The exclude list feeds globToRegex filters in resolveFiles(), which iterates with .map(), so a non-array would throw later anyway — this validates early with a clear message.
Source
Thrown at plugin/skills/impeccable/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 d14711ae3d)
Solutions
- Provide exclude as an array of glob strings, e.g. ["node_modules\/**", "dist\/**"].
- Remove the exclude key entirely if you have no exclusions (HARD_EXCLUDES already filters common build dirs).
- If migrating, normalise: exclude = exclude == null ? undefined : (Array.isArray(exclude) ? exclude : [exclude]).
- Validate with `node live-inject.mjs --check`.
Example fix
// before
{ "exclude": "node_modules", ... }
// after
{ "exclude": ["node_modules\/**"], ... } Defensive patterns
Strategy: validation
Validate before calling
function isValidExclude(cfg) {
return cfg?.exclude === undefined || Array.isArray(cfg.exclude);
}
if (!isValidExclude(cfg)) {
// normalise a single string to an array, or drop it
cfg.exclude = typeof cfg.exclude === 'string' ? [cfg.exclude] : undefined;
} Type guard
/** True when exclude is absent or a string array. */
function isOptionalStringArray(value) {
return value === undefined || Array.isArray(value);
} Try / catch
try {
validateConfig(cfg);
} catch (err) {
if (/config\.exclude, if present, must be a string array/.test(err.message)) {
cfg.exclude = Array.isArray(cfg.exclude) ? cfg.exclude : undefined;
validateConfig(cfg);
}
throw err;
} Prevention
- Omit the exclude key entirely when you have no exclusions — HARD_EXCLUDES already filters build dirs.
- Always write exclude as an array of globs, never a single string.
- Normalise null to undefined before validation.
When it happens
Trigger: "exclude": "node_modules" (string), "exclude": null, "exclude": {"node_modules": true}. A correctly absent exclude key (undefined) skips the whole block.
Common situations: User assumed exclude takes a single glob string like gitignore; hand-edit replaced an array with a scalar; a config migration left null where an array used to be.
Related errors
- config.json must be an object
- config.files (non-empty string array) required
- config.files must contain only non-empty strings
- config.exclude must contain only non-empty strings
- config.insertBefore or config.insertAfter (string) required
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/5a959d3cdd2f60fa.
Report an issue: GitHub.