Skip to content
Closed
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
12 changes: 12 additions & 0 deletions packages/cli/src/linter/model/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,18 @@ describe('ModelHandler', () => {
expect(result.findings[0]!.severity).toBe('error');
});

it('keeps unquoted YAML numeric lineHeight as a unitless multiplier', () => {
const result = handler.execute(makeParsed({
typography: {
'body-md': { fontFamily: 'Inter', fontSize: '16px', fontWeight: 400, lineHeight: 1.6 },
},
}));
const body = result.designSystem.typography.get('body-md');
expect(body?.lineHeight?.value).toBe(1.6);
expect(body?.lineHeight?.unit).toBe('');
expect(result.findings.filter((f) => f.path?.includes('lineHeight') === true)).toHaveLength(0);
});

it('accepts string representations of numbers for fontWeight', () => {
const result = handler.execute(makeParsed({
typography: {
Expand Down
19 changes: 19 additions & 0 deletions packages/cli/src/linter/model/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,25 @@ function parseTypography(props: Record<string, string | number>, path: string, f
const dimensionProps = ['fontSize', 'lineHeight', 'letterSpacing'] as const;
for (const prop of dimensionProps) {
const raw = props[prop];
if (typeof raw === 'number' && Number.isFinite(raw)) {
// YAML parses unquoted unitless values as numbers. lineHeight is a
// unitless multiplier in both DESIGN.md and DTCG; other dimension
// properties still require an explicit unit.
if (prop === 'lineHeight') {
result[prop] = {
type: 'dimension',
value: raw,
unit: '',
};
} else {
findings.push({
severity: 'error',
path: `${path}.${prop}`,
message: `'${raw}' is not a valid dimension. Include a unit (px, rem, or em).`,
});
}
continue;
}
if (typeof raw === 'string') {
if (isParseableDimension(raw)) {
const parsed = parseDimension(raw);
Expand Down