Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/cli/src/linter/model/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ describe('ModelHandler', () => {
const headline = result.designSystem.typography.get('headline');
expect(headline?.fontWeight).toBe(700);
});

it('warns about unrecognized typography sub-properties that are silently dropped', () => {
const result = handler.execute(makeParsed({
typography: {
'headline': { fontFamily: 'Inter', textTransform: 'uppercase' },
},
}));
const warning = result.findings.find(f => f.path === 'typography.headline.textTransform');
expect(warning).toBeDefined();
expect(warning?.severity).toBe('warning');
// The recognized property is still resolved, and known props never warn.
expect(result.designSystem.typography.get('headline')?.fontFamily).toBe('Inter');
expect(result.findings.some(f => f.path === 'typography.headline.fontFamily')).toBe(false);
});
});

describe('rounded validation', () => {
Expand Down
16 changes: 15 additions & 1 deletion packages/cli/src/linter/model/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
Finding,
} from './spec.js';

import { isValidColor, isParseableDimension, isTokenReference, parseDimensionParts } from './spec.js';
import { isValidColor, isParseableDimension, isTokenReference, parseDimensionParts, VALID_TYPOGRAPHY_PROPS } from './spec.js';
import { parseCssColor } from './color-parser.js';

import {
Expand All @@ -34,6 +34,7 @@ import {
} from '../spec-config.js';

const SCHEMA_KEY_SET: ReadonlySet<string> = new Set(SCHEMA_KEYS);
const TYPOGRAPHY_PROP_SET: ReadonlySet<string> = new Set(VALID_TYPOGRAPHY_PROPS);

/**
* Builds a resolved DesignSystemState from parsed YAML tokens.
Expand Down Expand Up @@ -367,6 +368,19 @@ function parseTypography(props: Record<string, string | number>, path: string, f
}
}

// Surface typography sub-properties that aren't part of the schema: they are
// silently dropped (never resolved or emitted), so warn rather than ignore —
// mirroring how unknown component sub-tokens are reported.
for (const key of Object.keys(props)) {
if (!TYPOGRAPHY_PROP_SET.has(key)) {
findings.push({
severity: 'warning',
path: `${path}.${key}`,
message: `'${key}' is not a recognized typography property. Valid properties: ${VALID_TYPOGRAPHY_PROPS.join(', ')}.`,
});
}
}

return result;
}

Expand Down