mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2025-12-31 08:53:33 +00:00
65 lines
1.6 KiB
TypeScript
65 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'
|
||
|
|
}
|
||
|
|
});
|
||
|
|
`,
|
||
|
|
},
|
||
|
|
],
|
||
|
|
});
|