feat(design): switch to IMS Admin tokens, Geist and the 1px-rule gate
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs'
|
||||
import { findViolations } from '../../scripts/check-design-gates.mjs'
|
||||
|
||||
const rules = (src: string, file = 'components/x.tsx'): string[] =>
|
||||
(findViolations(src, file) as Array<{ rule: string }>).map(v => v.rule)
|
||||
|
||||
describe('design gates', () => {
|
||||
it('flags rounded corner classes', () => {
|
||||
expect(rules('<div className="rounded-lg p-2" />')).toContain('no-rounded')
|
||||
expect(rules('<div className="p-2 hover:rounded-md" />')).toContain('no-rounded')
|
||||
describe('design gates (IMS Admin refresh)', () => {
|
||||
it('allows the radius scale, including rounded-full', () => {
|
||||
expect(rules('<div className="rounded-md rounded-xl rounded-[5px] rounded-full" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags rounded-full outside the allowlist and accepts it inside', () => {
|
||||
expect(rules('<div className="rounded-full" />')).toContain('no-rounded-full')
|
||||
expect(rules('<div className="rounded-full" />', ROUND_ALLOWED[0])).not.toContain('no-rounded-full')
|
||||
it.each(['border-2', 'border-b-2', 'border-t-2', 'border-l-2', 'border-r-2'])('flags %s', cls => {
|
||||
expect(rules(`<div className="${cls}" />`)).toContain('no-2px-border')
|
||||
})
|
||||
|
||||
it('accepts 1px rules', () => {
|
||||
expect(rules('<div className="border border-b border-rule" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags the retired Archivo font', () => {
|
||||
expect(rules("import { Archivo } from 'next/font/google'")).toContain('no-archivo')
|
||||
})
|
||||
|
||||
it('flags off-palette colors but accepts remapped gray, blue and red', () => {
|
||||
@@ -21,7 +27,11 @@ describe('design gates', () => {
|
||||
expect(rules('<p className="text-gray-500 text-blue-700 bg-red-50" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags hard-coded hex colors', () => {
|
||||
it('accepts the status token classes', () => {
|
||||
expect(rules('<span className="bg-st-green-bg text-st-green-fg" />')).toEqual([])
|
||||
})
|
||||
|
||||
it('flags hard-coded hex colors, including the retired Modernist red', () => {
|
||||
expect(rules('<div style={{ color: "#ec3013" }} />')).toContain('no-hex')
|
||||
expect(rules('<p>'quoted'</p>')).not.toContain('no-hex')
|
||||
})
|
||||
@@ -35,11 +45,11 @@ describe('design gates', () => {
|
||||
})
|
||||
|
||||
it('reports file and 1-based line numbers', () => {
|
||||
const v = findViolations('a\n<div className="rounded-md" />', 'components/y.tsx')
|
||||
expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-rounded' })
|
||||
const v = findViolations('a\n<div className="border-2" />', 'components/y.tsx')
|
||||
expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-2px-border' })
|
||||
})
|
||||
|
||||
it('accepts clean on-system markup', () => {
|
||||
expect(rules('<div className="bg-surface border border-divider p-4 text-ink shadow-sm" />')).toEqual([])
|
||||
expect(rules('<div className="bg-surface border border-rule p-4 text-ink shadow-card rounded-xl" />')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user