pbakaus/impeccable · error · Error
config.commentSyntax must be 'html' or 'jsx'
Error message
config.commentSyntax must be 'html' or 'jsx'
What it means
Seventh validateConfig() check: cfg.commentSyntax must be exactly 'html' or 'jsx'. This selects how insertTag/removeTag wrap the live script (<!-- ... --> vs {/* ... */}). No default is applied — the field is mandatory. Any other value (including 'HTML', 'js', '') throws.
Source
Thrown at plugin/skills/impeccable/scripts/live-inject.mjs:469
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-execute
// ---------------------------------------------------------------------------
const _running = process.argv[1];
if (_running?.endsWith('live-inject.mjs') || _running?.endsWith('live-inject.mjs/')) {
enterLiveRoot();
injectCli();
}
// Re-exported so long-standing importers (live.mjs, the adapter modules, the
// test suites) keep their entry points while the implementations live inView on GitHub (pinned to d14711ae3d)
Solutions
- Set commentSyntax to 'html' for .html/.astro static files, or 'jsx' for JSX/TSX where {/* */} comments are valid.
- Re-run setup to auto-detect the correct value for your entry points.
- If your project mixes both, pick the syntax valid in the tagged files; the injector applies the same commentSyntax to all files in config.files.
- Run `node live-inject.mjs --check` to confirm.
Example fix
// before
{ "commentSyntax": "js", ... }
// after
{ "commentSyntax": "jsx", ... } Defensive patterns
Strategy: validation
Validate before calling
function isValidCommentSyntax(cfg) {
return cfg?.commentSyntax === 'html' || cfg?.commentSyntax === 'jsx';
}
if (!isValidCommentSyntax(cfg)) {
cfg.commentSyntax = entryPointsLookLikeJsx ? 'jsx' : 'html';
} Type guard
/** Narrow to the two valid comment-syntax literals. */
function isCommentSyntax(value) {
return value === 'html' || value === 'jsx';
} Try / catch
try {
validateConfig(cfg);
} catch (err) {
if (/commentSyntax must be/.test(err.message)) {
cfg.commentSyntax = 'html';
validateConfig(cfg);
}
throw err;
} Prevention
- Use 'html' for .html/.astro, 'jsx' for files where {/* */} is the only valid comment.
- The field is case-sensitive lowercase — no 'HTML' or 'JSX'.
- Pick the syntax that's valid across all files in config.files; the value is shared.
When it happens
Trigger: "commentSyntax": "js"; "HTML" (wrong case); "ts"; ""; missing key (undefined !== 'html' && !== 'jsx' -> throws). The match is strict equality, no normalisation.
Common situations: User typed uppercase or abbreviated; setup wizard wrote the wrong value; config ported from a project that used a different convention; key omitted entirely because docs didn't stress it's required.
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, if present, must be a string array
- config.exclude must contain only non-empty strings
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/d671937824c64e01.
Report an issue: GitHub.