test ✅: add comprehensive test suite for CSS ordering rules
Add tests for all three CSS property ordering rules:
alphabetical-order,
concentric-order,
custom-order,
Tests cover all implemented vanilla-extract APIs, fontFace, globalFontFace, globalKeyframes, globalStyle, keyframes, style, and styleVariants.. Each test verifies both valid and invalid cases, along with proper auto-fixing functionality.
2025-03-09 18:12:00 +02:00
|
|
|
import tsParser from '@typescript-eslint/parser';
|
|
|
|
|
import { run } from 'eslint-vitest-rule-tester';
|
|
|
|
|
import alphabeticalOrderRule from '../rule-definition.js';
|
|
|
|
|
|
|
|
|
|
run({
|
|
|
|
|
name: 'vanilla-extract/alphabetical-order/recipe',
|
|
|
|
|
rule: alphabeticalOrderRule,
|
|
|
|
|
languageOptions: {
|
|
|
|
|
parser: tsParser,
|
|
|
|
|
parserOptions: {
|
|
|
|
|
ecmaVersion: 2022,
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
valid: [
|
|
|
|
|
// Recipe with alphabetical ordering
|
|
|
|
|
`
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: {
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
display: 'flex'
|
|
|
|
|
},
|
|
|
|
|
variants: {
|
|
|
|
|
color: {
|
|
|
|
|
blue: {
|
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
|
color: 'white'
|
|
|
|
|
},
|
|
|
|
|
red: {
|
|
|
|
|
backgroundColor: 'red',
|
|
|
|
|
color: 'black'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
`,
|
2026-04-28 13:16:21 +09:00
|
|
|
|
|
|
|
|
// Recipe with base as array (ComplexStyleRule)
|
|
|
|
|
`
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: [{
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
display: 'flex'
|
|
|
|
|
}],
|
|
|
|
|
});
|
|
|
|
|
`,
|
test ✅: add comprehensive test suite for CSS ordering rules
Add tests for all three CSS property ordering rules:
alphabetical-order,
concentric-order,
custom-order,
Tests cover all implemented vanilla-extract APIs, fontFace, globalFontFace, globalKeyframes, globalStyle, keyframes, style, and styleVariants.. Each test verifies both valid and invalid cases, along with proper auto-fixing functionality.
2025-03-09 18:12:00 +02:00
|
|
|
],
|
|
|
|
|
invalid: [
|
|
|
|
|
// Recipe with incorrect ordering
|
|
|
|
|
{
|
|
|
|
|
code: `
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: {
|
|
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center'
|
|
|
|
|
},
|
|
|
|
|
variants: {
|
|
|
|
|
color: {
|
|
|
|
|
blue: {
|
|
|
|
|
color: 'white',
|
|
|
|
|
backgroundColor: 'blue'
|
|
|
|
|
},
|
|
|
|
|
red: {
|
|
|
|
|
color: 'black',
|
|
|
|
|
backgroundColor: 'red'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
`,
|
|
|
|
|
errors: [
|
|
|
|
|
{ messageId: 'alphabeticalOrder' },
|
|
|
|
|
{ messageId: 'alphabeticalOrder' },
|
|
|
|
|
{ messageId: 'alphabeticalOrder' },
|
|
|
|
|
],
|
|
|
|
|
output: `
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: {
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
display: 'flex'
|
|
|
|
|
},
|
|
|
|
|
variants: {
|
|
|
|
|
color: {
|
|
|
|
|
blue: {
|
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
|
color: 'white'
|
|
|
|
|
},
|
|
|
|
|
red: {
|
|
|
|
|
backgroundColor: 'red',
|
|
|
|
|
color: 'black'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
`,
|
|
|
|
|
},
|
2026-04-28 13:16:21 +09:00
|
|
|
|
|
|
|
|
// Recipe with base array in incorrect order
|
|
|
|
|
{
|
|
|
|
|
code: `
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: [{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center'
|
|
|
|
|
}],
|
|
|
|
|
});
|
|
|
|
|
`,
|
|
|
|
|
errors: [{ messageId: 'alphabeticalOrder' }],
|
|
|
|
|
output: `
|
|
|
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
|
|
|
const myRecipe = recipe({
|
|
|
|
|
base: [{
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
display: 'flex'
|
|
|
|
|
}],
|
|
|
|
|
});
|
|
|
|
|
`,
|
2026-04-30 00:22:26 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Imported local recipe wrapper with global settings recipe
|
|
|
|
|
{
|
|
|
|
|
code: `
|
|
|
|
|
import { componentRecipe } from './component-recipe.css.js';
|
|
|
|
|
|
|
|
|
|
const myRecipe = componentRecipe({
|
|
|
|
|
base: {
|
|
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
`,
|
|
|
|
|
settings: {
|
|
|
|
|
'vanilla-extract': {
|
|
|
|
|
recipe: ['componentRecipe'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
errors: [{ messageId: 'alphabeticalOrder' }],
|
|
|
|
|
output: `
|
|
|
|
|
import { componentRecipe } from './component-recipe.css.js';
|
|
|
|
|
|
|
|
|
|
const myRecipe = componentRecipe({
|
|
|
|
|
base: {
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
display: 'flex'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
`,
|
2026-04-28 13:16:21 +09:00
|
|
|
},
|
test ✅: add comprehensive test suite for CSS ordering rules
Add tests for all three CSS property ordering rules:
alphabetical-order,
concentric-order,
custom-order,
Tests cover all implemented vanilla-extract APIs, fontFace, globalFontFace, globalKeyframes, globalStyle, keyframes, style, and styleVariants.. Each test verifies both valid and invalid cases, along with proper auto-fixing functionality.
2025-03-09 18:12:00 +02:00
|
|
|
],
|
2026-04-30 00:22:26 +09:00
|
|
|
});
|