|
|
|
|
@ -7,6 +7,8 @@ import { THEME_BASE_RECIPE_TOKENS } from './lib/recipes/base'
|
|
|
|
|
const COMPONENTS_DIR = 'src/uix/eidos/components'
|
|
|
|
|
const CSS_CUSTOM_PROPERTY = /--([a-z][a-z0-9]*-[a-z0-9-]+)/g
|
|
|
|
|
const COMPONENT_SOURCE_FILE = /\.(css|svelte|ts)$/
|
|
|
|
|
const RAW_COLOR_LITERAL = /#[0-9a-f]{3,8}\b|\b(?:rgb|rgba|hsl|hsla)\(/i
|
|
|
|
|
const RAW_FONT_SIZE_LITERAL = /font-size\s*:\s*[0-9.]+(?:px|rem)\b/i
|
|
|
|
|
const RECIPE_TOKENS = THEME_BASE_RECIPE_TOKENS as Readonly<
|
|
|
|
|
Record<string, Readonly<Record<string, string>>>
|
|
|
|
|
>
|
|
|
|
|
@ -95,6 +97,22 @@ describe('Eidos recipe CSS contract', () => {
|
|
|
|
|
expect(extra).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('keeps raw color values out of component CSS', () => {
|
|
|
|
|
const violations = readComponentCssFiles()
|
|
|
|
|
.filter(({ css }) => RAW_COLOR_LITERAL.test(css))
|
|
|
|
|
.map(({ component }) => component)
|
|
|
|
|
|
|
|
|
|
expect(violations).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('keeps raw font-size literals out of component CSS', () => {
|
|
|
|
|
const violations = readComponentCssFiles()
|
|
|
|
|
.filter(({ css }) => RAW_FONT_SIZE_LITERAL.test(css))
|
|
|
|
|
.map(({ component }) => component)
|
|
|
|
|
|
|
|
|
|
expect(violations).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does not leave declared public recipe variables orphaned', () => {
|
|
|
|
|
const recipeValueReferences = readRecipeValueReferences()
|
|
|
|
|
const orphaned: string[] = []
|
|
|
|
|
|