mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2026-01-02 01:23:33 +00:00
feat 🥁: add no-empty-style-blocks rule
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.
This commit is contained in:
parent
f346002fb0
commit
175ce9aef8
45 changed files with 2674 additions and 566 deletions
33
src/css-rules/no-empty-blocks/rule-definition.ts
Normal file
33
src/css-rules/no-empty-blocks/rule-definition.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import type { Rule } from 'eslint';
|
||||
import { createEmptyStyleVisitors } from './empty-style-visitor-creator.js';
|
||||
|
||||
const noEmptyStyleBlocksRule: Rule.RuleModule = {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'disallow empty style blocks in vanilla-extract stylesheets',
|
||||
category: 'Best Practices',
|
||||
recommended: true,
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [],
|
||||
messages: {
|
||||
emptyConditionalStyle: 'Empty conditional style object should be removed.',
|
||||
emptyMedia: 'Empty @media object should be removed.',
|
||||
emptyNestedStyle: 'Empty nested style object should be removed.',
|
||||
emptyRecipeProperty: 'Empty {{propertyName}} object in recipe should be removed.',
|
||||
emptySelectors: 'Empty selectors object should be removed.',
|
||||
emptySpreadObject: 'Empty spread object should be removed.',
|
||||
emptyStyleDeclaration: 'Declarations with only empty style blocks should be removed.',
|
||||
emptySupports: 'Empty @supports object should be removed.',
|
||||
emptyVariantCategory: 'Empty variant category should be removed.',
|
||||
emptyVariantValue: 'Empty variant value should be removed.',
|
||||
invalidPropertyType: 'Variant values must be objects, found {{type}} instead.',
|
||||
},
|
||||
},
|
||||
create(ruleContext) {
|
||||
return createEmptyStyleVisitors(ruleContext);
|
||||
},
|
||||
};
|
||||
|
||||
export default noEmptyStyleBlocksRule;
|
||||
Loading…
Add table
Add a link
Reference in a new issue