{"record":{"id":"9efc780988d6b9b9","repo":"pbakaus/impeccable","slug":"config-exclude-if-present-must-be-a-string-array","errorCode":null,"errorMessage":"config.exclude, if present, must be a string array","messagePattern":"config\\.exclude, if present, must be a string array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/live-inject.mjs","lineNumber":459,"sourceCode":"  }\n  return new RegExp('^' + re + '$');\n}\n\n// ---------------------------------------------------------------------------\n// Core operations\n// ---------------------------------------------------------------------------\n\nfunction validateConfig(cfg) {\n  if (!cfg || typeof cfg !== 'object') throw new Error('config.json must be an object');\n  if (!Array.isArray(cfg.files) || cfg.files.length === 0) {\n    throw new Error('config.files (non-empty string array) required');\n  }\n  if (!cfg.files.every((f) => typeof f === 'string' && f.length > 0)) {\n    throw new Error('config.files must contain only non-empty strings');\n  }\n  if (cfg.exclude !== undefined) {\n    if (!Array.isArray(cfg.exclude)) {\n      throw new Error('config.exclude, if present, must be a string array');\n    }\n    if (!cfg.exclude.every((f) => typeof f === 'string' && f.length > 0)) {\n      throw new Error('config.exclude must contain only non-empty strings');\n    }\n  }\n  if (typeof cfg.insertBefore !== 'string' && typeof cfg.insertAfter !== 'string') {\n    throw new Error('config.insertBefore or config.insertAfter (string) required');\n  }\n  if (cfg.commentSyntax !== 'html' && cfg.commentSyntax !== 'jsx') {\n    throw new Error(\"config.commentSyntax must be 'html' or 'jsx'\");\n  }\n  if (cfg.cspChecked !== undefined && typeof cfg.cspChecked !== 'boolean') {\n    throw new Error(\"config.cspChecked, if present, must be a boolean\");\n  }\n}\n\n// ---------------------------------------------------------------------------\n// Auto-execute","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/pbakaus/impeccable/blob/f88b2837a7d7c3182e46307bbbb091a1ed547571/skill/scripts/live-inject.mjs#L441-L477","documentation":"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.","triggerScenarios":"Config contains \"exclude\": \"node_modules\" or \"exclude\": \"dist/**\" (string) instead of an array; exclude set to an object or number.","commonSituations":"Authors expecting glob-string semantics like files sometimes has; converting between config formats and losing the brackets; exclude copied from a CLI flag example.","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"],"exampleFix":"// before\n\"exclude\": \"node_modules\"\n\n// after\n\"exclude\": [\"node_modules\"]","handlingStrategy":"validation","validationCode":"if (cfg.exclude !== undefined && !Array.isArray(cfg.exclude)) {\n  throw new TypeError('config.exclude must be an array of strings');\n}","typeGuard":"const hasValidExcludeShape = (cfg) =>\n  cfg.exclude === undefined || Array.isArray(cfg.exclude);","tryCatchPattern":null,"preventionTips":["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"],"tags":["config","schema","exclude","live-inject"],"backgroundTag":"config-schema-validation","analyzedSha":"f88b2837a7d7c3182e46307bbbb091a1ed547571","analyzedAt":"2026-08-18T04:58:36.608Z","contentChangedAt":"2026-08-18T04:58:36.608Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}