mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2025-12-31 08:53:33 +00:00
Add comprehensive rule to detect and prevent empty CSS style blocks: - Identify style objects with no properties - Flag empty style blocks as potential code quality issues - Provide auto-fix capability to remove empty blocks - Handle edge cases like comments-only blocks This rule helps maintain cleaner codebases by eliminating empty style definitions that often result from incomplete refactoring or forgotten implementations, reducing confusion and unnecessary code.
26 lines
973 B
TypeScript
26 lines
973 B
TypeScript
import type { Rule } from 'eslint';
|
|
import { createNodeVisitors } from '../shared-utils/order-strategy-visitor-creator.js';
|
|
import type { OrderingStrategy } from '../types.js';
|
|
|
|
const alphabeticalOrderRule: Rule.RuleModule = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
description: 'enforce alphabetical CSS property ordering in vanilla-extract styles',
|
|
category: 'Stylistic Issues',
|
|
recommended: true,
|
|
},
|
|
fixable: 'code',
|
|
schema: [],
|
|
messages: {
|
|
alphabeticalOrder: "Property '{{nextProperty}}' should come before '{{currentProperty}}' in alphabetical order.",
|
|
fontFaceOrder:
|
|
"Properties in fontFace should be ordered with 'src' first, followed by other properties in alphabetical order. Property '{{nextProperty}}' should come before '{{currentProperty}}'.",
|
|
},
|
|
},
|
|
create(context) {
|
|
return createNodeVisitors(context, 'alphabetical' as OrderingStrategy);
|
|
},
|
|
};
|
|
|
|
export default alphabeticalOrderRule;
|