fix(config): validate null hover background

This commit is contained in:
2026-04-25 21:30:31 -07:00
parent 5bccb55afc
commit e51bb74e1b
2 changed files with 27 additions and 1 deletions

View File

@@ -453,6 +453,30 @@ test('parses subtitleStyle.hoverBackground as a hoverTokenBackgroundColor alias'
assert.equal(validService.getConfig().subtitleStyle.hoverTokenBackgroundColor, 'transparent');
});
test('parses subtitleStyle.hoverTokenBackgroundColor null as invalid instead of missing', () => {
const invalidDir = makeTempDir();
fs.writeFileSync(
path.join(invalidDir, 'config.jsonc'),
`{
"subtitleStyle": {
"hoverTokenBackgroundColor": null
}
}`,
'utf-8',
);
const invalidService = new ConfigService(invalidDir);
assert.equal(
invalidService.getConfig().subtitleStyle.hoverTokenBackgroundColor,
DEFAULT_CONFIG.subtitleStyle.hoverTokenBackgroundColor,
);
assert.ok(
invalidService
.getWarnings()
.some((warning) => warning.path === 'subtitleStyle.hoverTokenBackgroundColor'),
);
});
test('parses subtitleStyle.nameMatchEnabled and warns on invalid values', () => {
const validDir = makeTempDir();
fs.writeFileSync(

View File

@@ -265,7 +265,9 @@ export function applySubtitleDomainConfig(context: ResolveContext): void {
hoverTokenBackgroundColor?: unknown;
};
const rawHoverTokenBackgroundColor =
subtitleStyleSource.hoverTokenBackgroundColor ?? subtitleStyleSource.hoverBackground;
subtitleStyleSource.hoverTokenBackgroundColor !== undefined
? subtitleStyleSource.hoverTokenBackgroundColor
: subtitleStyleSource.hoverBackground;
const hoverTokenBackgroundColor = asString(rawHoverTokenBackgroundColor);
if (hoverTokenBackgroundColor !== undefined) {
resolved.subtitleStyle.hoverTokenBackgroundColor = hoverTokenBackgroundColor;