mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2025-12-31 08:53:33 +00:00
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.
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
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/variants',
|
|
rule: alphabeticalOrderRule,
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
parserOptions: {
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
},
|
|
},
|
|
valid: [
|
|
// styleVariants with alphabetical ordering
|
|
`
|
|
import { styleVariants } from '@vanilla-extract/css';
|
|
|
|
const variants = styleVariants({
|
|
primary: {
|
|
backgroundColor: 'blue',
|
|
color: 'white'
|
|
},
|
|
secondary: {
|
|
backgroundColor: 'gray',
|
|
color: 'black'
|
|
}
|
|
});
|
|
`,
|
|
],
|
|
invalid: [
|
|
// styleVariants with incorrect ordering
|
|
{
|
|
code: `
|
|
import { styleVariants } from '@vanilla-extract/css';
|
|
const variants = styleVariants({
|
|
primary: {
|
|
color: 'white',
|
|
backgroundColor: 'blue'
|
|
},
|
|
secondary: {
|
|
color: 'black',
|
|
backgroundColor: 'gray'
|
|
}
|
|
});
|
|
`,
|
|
errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
|
|
output: `
|
|
import { styleVariants } from '@vanilla-extract/css';
|
|
const variants = styleVariants({
|
|
primary: {
|
|
backgroundColor: 'blue',
|
|
color: 'white'
|
|
},
|
|
secondary: {
|
|
backgroundColor: 'gray',
|
|
color: 'black'
|
|
}
|
|
});
|
|
`,
|
|
},
|
|
],
|
|
});
|