UNPKG

@antebudimir/eslint-plugin-vanilla-extract

Version:

ESLint plugin for enforcing best practices in vanilla-extract CSS styles, including CSS property ordering and additional linting rules.

20 lines (19 loc) 803 B
import { getPropertyNameForSorting } from './property-separator.js'; /** * Compares two CSS properties alphabetically. * @param firstProperty The first property to compare. * @param secondProperty The second property to compare. * @returns A number indicating the relative order of the properties (-1, 0, or 1). */ export const comparePropertiesAlphabetically = (firstProperty, secondProperty) => { const firstName = getPropertyNameForSorting(firstProperty); const secondName = getPropertyNameForSorting(secondProperty); // Special handling for 'src' property - it should always come first (relates to font face APIs only) if (firstName === 'src') { return -1; } if (secondName === 'src') { return 1; } return firstName.localeCompare(secondName); };