feat 🥁: add no-empty-style-blocks rule to detect and prevent empty CSS blocks

This commit is contained in:
Ante Budimir 2025-04-06 11:37:34 +03:00
parent f346002fb0
commit 47d3deb2f1
45 changed files with 2639 additions and 546 deletions

View file

@ -10,7 +10,7 @@ import { TSESTree } from '@typescript-eslint/utils';
* - Literal (string): Returns the string value.
* For any other type of key, it returns an empty string.
*/
export const getPropertyName = (property: TSESTree.Property): string => {
export const getPropertyNameForSorting = (property: TSESTree.Property): string => {
if (property.key.type === 'Identifier') {
return property.key.name;
} else if (property.key.type === 'Literal' && typeof property.key.value === 'string') {
@ -43,7 +43,7 @@ export const separateProperties = (
// Separate regular CSS properties from special ones (pseudo selectors, etc.)
properties.forEach((property) => {
if (property.type === 'Property') {
const propName = getPropertyName(property);
const propName = getPropertyNameForSorting(property);
if (propName.startsWith(':') || propName.startsWith('@') || propName === 'selectors') {
specialProperties.push(property);