An essential ESLint plugin designed for vanilla-extract CSS styles, enforcing best practices through property ordering and additional linting rules. Choose from alphabetical or concentric CSS ordering and benefit from a customizable option for tailored group orders. Simplify your CSS management with automatic sorting and improve code quality with enhanced linting features.
The @antebudimir/eslint-plugin-vanilla-extract is an ESLint plugin specifically designed to enhance code quality by enforcing strict best practices for vanilla-extract CSS styles. This plugin focuses on optimizing CSS property ordering and introduces essential linting rules that aid in maintaining consistency across style definitions.
style, styleVariants, recipe, and globalStyle, while effectively handling complex scenarios such as nested objects and pseudo selectors.To enforce alphabetical order among CSS properties, utilize the following rule:
// ❌ Incorrect
import { style } from '@vanilla-extract/css';
export const myStyle = style({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: 19,
marginBottom: 1,
marginLeft: 2,
});
// ✅ Correct
import { style } from '@vanilla-extract/css';
export const myStyle = style({
alignItems: 'center',
display: 'flex',
height: 19,
justifyContent: 'center',
marginBottom: 1,
marginLeft: 2,
});
For concentric ordering, the rule ensures properties are arranged logically:
// ❌ Incorrect
import { style } from '@vanilla-extract/css';
export const myStyle = style({
color: 'red',
display: 'flex',
position: 'relative',
padding: '10px',
margin: '20px',
});
// ✅ Correct
import { style } from '@vanilla-extract/css';
export const myStyle = style({
position: 'relative',
display: 'flex',
margin: '20px',
padding: '10px',
color: 'red',
});
This plugin utilizes a concentric CSS model that categorizes CSS properties into groups such as boxSizing, position, display, and text, organizing them from outer to inner. This structured approach not only improves readability but also streamlines the styling process.
Future enhancements planned for the plugin include additional linting rules like no-empty-blocks, no-unknown-units, and prefer-theme-tokens, ensuring it continues to evolve according to user needs and feedback.
The eslint-plugin-vanilla-extract serves as a valuable tool for developers working with vanilla-extract CSS, promoting best practices and helping to maintain high code quality through effective property ordering and linting capabilities.
No comments yet.
Sign in to be the first to comment.