Skip to content

Commit

Permalink
Revert "[WIP] First attempt" - commited by mistake
Browse files Browse the repository at this point in the history
This reverts commit 46a70cc.
  • Loading branch information
Szymon Małolepszy committed Oct 8, 2024
1 parent 46a70cc commit e574854
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions rules/checkAlphabeticalOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@ function isShorthand(a, b) {
return longhands.includes(b);
}

function hasPrefix(propName) {
return vendor.prefix(propName).length > 0;
}

export function checkAlphabeticalOrder(firstPropData, secondPropData) {
const firstUnprefixedNameLC = firstPropData.unprefixedName.toLowerCase();
const secondUnprefixedNameLC = secondPropData.unprefixedName.toLowerCase();

// OK if the first is shorthand for the second:
if (isShorthand(firstUnprefixedNameLC, secondUnprefixedNameLC)) {
if (isShorthand(firstPropData.unprefixedName, secondPropData.unprefixedName)) {
return true;
}

// Not OK if the second is shorthand for the first:
if (isShorthand(firstUnprefixedNameLC, secondUnprefixedNameLC)) {
if (isShorthand(secondPropData.unprefixedName, firstPropData.unprefixedName)) {
return false;
}

// If unprefixed prop names are the same, compare the prefixed versions
if (firstUnprefixedNameLC === secondUnprefixedNameLC) {
if (!hasPrefix(firstPropData.name) && hasPrefix(secondPropData.name)) {
if (firstPropData.unprefixedName === secondPropData.unprefixedName) {
// If first property has no prefix and second property has prefix
if (
!vendor.prefix(firstPropData.name).length &&
vendor.prefix(secondPropData.name).length
) {
return false;
}

return true;
}

return firstUnprefixedNameLC < secondUnprefixedNameLC;
return firstPropData.unprefixedName < secondPropData.unprefixedName;
}

0 comments on commit e574854

Please sign in to comment.