From ad9633152e99f97072a46344d988b7e1159d3a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Mon, 7 Oct 2024 22:27:07 +0200 Subject: [PATCH 1/6] tests for #78 --- .../tests/index.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rules/properties-alphabetical-order/tests/index.js b/rules/properties-alphabetical-order/tests/index.js index 4f5260c..05aa6c5 100644 --- a/rules/properties-alphabetical-order/tests/index.js +++ b/rules/properties-alphabetical-order/tests/index.js @@ -68,6 +68,21 @@ testRule({ { code: 'a { font-size: 1px; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialised; font-weight: bold; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { display: block; margin: 0 auto 5px 0; Margin: 0 auto 5px 0; width: auto; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { display: block; Margin: 0 auto 5px 0; margin: 0 auto 5px 0; width: auto; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; Border-width: 1px; Border-top-width: 2px; color: red; }', + }, ], reject: [ @@ -131,6 +146,13 @@ testRule({ fixed: '@media print { color: red; top: 0; }', message: messages.expected('color', 'top'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; Border-top-width: 2px; Border-width: 1px; color: red; }', + fixed: 'a { align: center; Border-width: 1px; Border-top-width: 2px; color: red; }', + message: messages.expected('Border-width', 'Border-top-width'), + }, ], }); From 46a70cc159a1ea5f84b052fe6de75fd8fd29afa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Tue, 8 Oct 2024 09:15:13 +0200 Subject: [PATCH 2/6] [WIP] First attempt --- rules/checkAlphabeticalOrder.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/rules/checkAlphabeticalOrder.js b/rules/checkAlphabeticalOrder.js index 9c5bdab..a315ac4 100644 --- a/rules/checkAlphabeticalOrder.js +++ b/rules/checkAlphabeticalOrder.js @@ -7,29 +7,32 @@ 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(firstPropData.unprefixedName, secondPropData.unprefixedName)) { + if (isShorthand(firstUnprefixedNameLC, secondUnprefixedNameLC)) { return true; } // Not OK if the second is shorthand for the first: - if (isShorthand(secondPropData.unprefixedName, firstPropData.unprefixedName)) { + if (isShorthand(firstUnprefixedNameLC, secondUnprefixedNameLC)) { return false; } // If unprefixed prop names are the same, compare the prefixed versions - 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 - ) { + if (firstUnprefixedNameLC === secondUnprefixedNameLC) { + if (!hasPrefix(firstPropData.name) && hasPrefix(secondPropData.name)) { return false; } return true; } - return firstPropData.unprefixedName < secondPropData.unprefixedName; + return firstUnprefixedNameLC < secondUnprefixedNameLC; } From e57485483cff773842bc5a18a974044570ef7272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Tue, 8 Oct 2024 09:18:29 +0200 Subject: [PATCH 3/6] Revert "[WIP] First attempt" - commited by mistake This reverts commit 46a70cc159a1ea5f84b052fe6de75fd8fd29afa3. --- rules/checkAlphabeticalOrder.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/rules/checkAlphabeticalOrder.js b/rules/checkAlphabeticalOrder.js index a315ac4..9c5bdab 100644 --- a/rules/checkAlphabeticalOrder.js +++ b/rules/checkAlphabeticalOrder.js @@ -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; } From 9639ef33c0002340cb352dbf29a9e94ad597ce86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Tue, 8 Oct 2024 22:26:34 +0200 Subject: [PATCH 4/6] First tests Tests for properties-alphabetical-order and flat, grouped-flexible, validate-options in properties-order --- .../tests/index.js | 38 +++++ rules/properties-order/tests/flat.js | 157 ++++++++++++++++++ .../tests/grouped-flexible.js | 150 +++++++++++++++++ .../tests/validate-options.js | 30 ++++ 4 files changed, 375 insertions(+) diff --git a/rules/properties-alphabetical-order/tests/index.js b/rules/properties-alphabetical-order/tests/index.js index 05aa6c5..2adf808 100644 --- a/rules/properties-alphabetical-order/tests/index.js +++ b/rules/properties-alphabetical-order/tests/index.js @@ -83,6 +83,16 @@ testRule({ skip: true, code: 'a { align: center; Border-width: 1px; Border-top-width: 2px; color: red; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; border-width: 1px; Border-top-width: 2px; color: red; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; Border-width: 1px; border-top-width: 2px; color: red; }', + }, ], reject: [ @@ -153,6 +163,34 @@ testRule({ fixed: 'a { align: center; Border-width: 1px; Border-top-width: 2px; color: red; }', message: messages.expected('Border-width', 'Border-top-width'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; Border-top-width: 2px; border-width: 1px; color: red; }', + fixed: 'a { align: center; border-width: 1px; Border-top-width: 2px; color: red; }', + message: messages.expected('border-width', 'Border-top-width'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align: center; border-top-width: 2px; Border-width: 1px; color: red; }', + fixed: 'a { align: center; Border-width: 1px; border-top-width: 2px; color: red; }', + message: messages.expected('Border-width', 'border-top-width'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { color: red; align: center; margin: 1px; Margin: 1px; }', + fixed: 'a { align: center; color: red; margin: 1px; Margin: 1px; }', + message: messages.expected('align', 'color'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { color: red; Color: red; margin-top: 1px; margin: 1px; }', + fixed: 'a { color: red; Color: red; margin: 1px; margin-top: 1px; }', + message: messages.expected('margin', 'margin-top'), + }, ], }); diff --git a/rules/properties-order/tests/flat.js b/rules/properties-order/tests/flat.js index 884c0f1..f8e9b6b 100644 --- a/rules/properties-order/tests/flat.js +++ b/rules/properties-order/tests/flat.js @@ -48,6 +48,16 @@ testRule({ { code: 'a { top: 0; color: pink; display: none; width: 0; height: 0; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { top: 0; Top: 0; color: pink; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Top: 0; top: 0; color: pink; }', + }, ], reject: [ @@ -56,6 +66,34 @@ testRule({ fixed: 'a { top: 0; color: pink; }', message: messages.expected('top', 'color'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Color: pink; top: 0; }', + fixed: 'a { top: 0; Color: pink; }', + message: messages.expected('top', 'Color'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { color: pink; Top: 0; }', + fixed: 'a { Top: 0; color: pink; }', + message: messages.expected('Top', 'color'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Top: 0; color: pink; top: 0; }', + fixed: 'a { Top: 0; top: 0; color: pink; }', + message: messages.expected('top', 'color'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { top: 0; color: pink; Top: 0; }', + fixed: 'a { top: 0; Top: 0; color: pink; }', + message: messages.expected('Top', 'color'), + }, { code: 'a { top: 0; transform: scale(1); color: pink; }', fixed: 'a { transform: scale(1); top: 0; color: pink; }', @@ -199,9 +237,19 @@ testRule({ { code: 'a { top: 0; height: 1px; color: pink; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { top: 0; height: 1px; Color: pink; }', + }, { code: 'a { bottom: 0; top: 0; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Bottom: 0; top: 0; }', + }, ], reject: [ @@ -210,6 +258,27 @@ testRule({ fixed: 'a { top: 0; height: 1px; }', message: messages.expected('top', 'height'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; top: 0; }', + fixed: 'a { top: 0; Height: 1px; }', + message: messages.expected('top', 'Height'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Top: 0; }', + fixed: 'a { Top: 0; height: 1px; }', + message: messages.expected('Top', 'height'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; Top: 0; }', + fixed: 'a { Top: 0; Height: 1px; }', + message: messages.expected('Top', 'Height'), + }, { code: 'a { color: 1px; top: 0; }', fixed: 'a { top: 0; color: 1px; }', @@ -232,9 +301,19 @@ testRule({ { code: 'a { height: 1px; color: pink; bottom: 0; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; color: pink; bottom: 0; }', + }, { code: 'a { bottom: 0; top: 0; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { bottom: 0; Top: 0; }', + }, ], reject: [ @@ -243,6 +322,27 @@ testRule({ fixed: 'a { height: 1px; bottom: 0; }', message: messages.expected('height', 'bottom'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Bottom: 0; height: 1px; }', + fixed: 'a { height: 1px; Bottom: 0; }', + message: messages.expected('height', 'Bottom'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { bottom: 0; Height: 1px; }', + fixed: 'a { Height: 1px; bottom: 0; }', + message: messages.expected('Height', 'bottom'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Bottom: 0; Height: 1px; }', + fixed: 'a { Height: 1px; Bottom: 0; }', + message: messages.expected('Height', 'Bottom'), + }, { code: 'a { bottom: 0; color: 1px; }', fixed: 'a { color: 1px; bottom: 0; }', @@ -271,6 +371,21 @@ testRule({ { code: 'a { all: initial; compose: b; bottom: 0; top: 0; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { all: initial; Compose: b; bottom: 0; top: 0; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { all: initial; compose: b; Bottom: 0; top: 0; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { all: initial; Compose: b; Bottom: 0; top: 0; }', + }, ], reject: [ @@ -279,6 +394,27 @@ testRule({ fixed: 'a { all: initial; align-items: flex-end; }', message: messages.expected('all', 'align-items'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Align-items: flex-end; all: initial; }', + fixed: 'a { all: initial; Align-items: flex-end; }', + message: messages.expected('all', 'Align-items'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { align-items: flex-end; All: initial; }', + fixed: 'a { All: initial; align-items: flex-end; }', + message: messages.expected('All', 'align-items'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Align-items: flex-end; All: initial; }', + fixed: 'a { All: initial; Align-items: flex-end; }', + message: messages.expected('All', 'Align-items'), + }, { code: 'a { compose: b; top: 0; bottom: 0; }', fixed: 'a { compose: b; bottom: 0; top: 0; }', @@ -305,6 +441,27 @@ testRule({ fixed: '.foo { left: 0; margin: 0; color: pink; }', message: messages.expected('left', 'margin'), }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: '.foo { margin: 0; color: pink; Left: 0; }', + fixed: '.foo { Left: 0; margin: 0; color: pink; }', + message: messages.expected('Left', 'margin'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: '.foo { Margin: 0; color: pink; left: 0; }', + fixed: '.foo { left: 0; Margin: 0; color: pink; }', + message: messages.expected('left', 'Margin'), + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: '.foo { Margin: 0; color: pink; Left: 0; }', + fixed: '.foo { Left: 0; Margin: 0; color: pink; }', + message: messages.expected('Left', 'Margin'), + }, ], }); diff --git a/rules/properties-order/tests/grouped-flexible.js b/rules/properties-order/tests/grouped-flexible.js index c4cb9ef..3c77a67 100644 --- a/rules/properties-order/tests/grouped-flexible.js +++ b/rules/properties-order/tests/grouped-flexible.js @@ -20,6 +20,11 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', + }, { code: 'a { height: 1px; width: 2px; font-size: 2px; color: pink; font-weight: bold; }', }, @@ -52,10 +57,20 @@ testRule({ code: 'a { height: 10px; background: orange; }', description: 'unspecified after groupless specified', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 10px; background: orange; }', + }, { code: 'a { font-weight: bold; background: orange; }', description: 'unspecified after grouped specified', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Font-weight: bold; background: orange; }', + }, ], reject: [ @@ -66,6 +81,33 @@ testRule({ line: 1, column: 37, }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', + fixed: 'a { height: 1px; Width: 2px; Font-weight: bold; }', + message: messages.expected('Width', 'Font-weight'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; width: 2px; }', + fixed: 'a { height: 1px; width: 2px; Font-weight: bold; }', + message: messages.expected('width', 'Font-weight'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; font-weight: bold; Width: 2px; }', + fixed: 'a { height: 1px; Width: 2px; font-weight: bold; }', + message: messages.expected('Width', 'font-weight'), + line: 1, + column: 37, + }, { code: 'a { font-weight: bold; height: 1px; width: 2px; }', fixed: 'a { height: 1px; width: 2px; font-weight: bold; }', @@ -109,6 +151,16 @@ testRule({ { code: 'a { font-size: 2px; font-weight: bold; height: 1px; width: 2px; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Font-size: 2px; Font-weight: bold; height: 1px; width: 2px; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Font-size: 2px; Font-weight: bold; Height: 1px; Width: 2px; }', + }, ], reject: [ { @@ -117,6 +169,30 @@ testRule({ line: 1, column: 18, }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; }', + message: messages.expected('Font-weight', 'height', 'font'), + line: 1, + column: 18, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; font-weight: bold; }', + message: messages.expected('font-weight', 'Height', 'font'), + line: 1, + column: 18, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; Font-weight: bold; }', + message: messages.expected('Font-weight', 'Height', 'font'), + line: 1, + column: 18, + }, ], }); @@ -140,6 +216,16 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; width: 2px; Color: pink; Font-size: 2px; font-weight: bold; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', + }, { code: 'a { width: 2px; height: 1px; font-size: 2px; color: pink; font-weight: bold; }', }, @@ -159,6 +245,33 @@ testRule({ line: 1, column: 37, }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; font-weight: bold; Width: 2px; }', + fixed: 'a { Width: 2px; height: 1px; font-weight: bold; }', + message: messages.expected('Width', 'font-weight'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; width: 2px; }', + fixed: 'a { width: 2px; height: 1px; Font-weight: bold; }', + message: messages.expected('width', 'Font-weight'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', + fixed: 'a { Width: 2px; height: 1px; Font-weight: bold; }', + message: messages.expected('Width', 'Font-weight'), + line: 1, + column: 37, + }, { code: 'a { font-weight: bold; height: 1px; width: 2px; }', fixed: 'a { width: 2px; height: 1px; font-weight: bold; }', @@ -198,6 +311,16 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; width: 2px; Color: pink; font-size: 2px; font-weight: bold; }', + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', + }, ], reject: [ { @@ -207,5 +330,32 @@ testRule({ line: 1, column: 37, }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; font-weight: bold; Width: 2px; }', + fixed: 'a { Width: 2px; height: 1px; font-weight: bold; }', + message: messages.expected('Width', 'font-weight', 'dimensions'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; width: 2px; }', + fixed: 'a { width: 2px; height: 1px; Font-weight: bold; }', + message: messages.expected('width', 'Font-weight', 'dimensions'), + line: 1, + column: 37, + }, + { + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', + fixed: 'a { Width: 2px; height: 1px; Font-weight: bold; }', + message: messages.expected('Width', 'Font-weight', 'dimensions'), + line: 1, + column: 37, + }, ], }); diff --git a/rules/properties-order/tests/validate-options.js b/rules/properties-order/tests/validate-options.js index 10c68f9..57a0c80 100644 --- a/rules/properties-order/tests/validate-options.js +++ b/rules/properties-order/tests/validate-options.js @@ -121,3 +121,33 @@ testConfig({ ], message: `Invalid option "[{"emptyLineBefore":"always","order":"flexible","properties":null}]" for rule "${ruleName}"`, }); + +testConfig({ + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + ruleName, + description: 'no duplicates in properties', + valid: false, + config: [ + { + properties: ['top', 'top'], + }, + ], + message: `Invalid option "[{"properties":["top", "top"]}]" for rule "${ruleName}"`, +}); + +testConfig({ + // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 + skip: true, + ruleName, + description: 'no duplicates in properties (case insensitive)', + valid: false, + config: [ + { + emptyLineBefore: 'always', + order: 'flexible', + properties: ['top', 'Top'], + }, + ], + message: `Invalid option "[{"properties":["top", "Top"]}]" for rule "${ruleName}"`, +}); From 6e87e2f8536090424f252fe6be85cf5b40cf4238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Wed, 9 Oct 2024 10:13:09 +0200 Subject: [PATCH 5/6] Remove unnecessary tests --- .../tests/index.js | 14 -- rules/properties-order/tests/flat.js | 133 ------------------ .../tests/validate-options.js | 30 ---- 3 files changed, 177 deletions(-) diff --git a/rules/properties-alphabetical-order/tests/index.js b/rules/properties-alphabetical-order/tests/index.js index 2adf808..7b2f1af 100644 --- a/rules/properties-alphabetical-order/tests/index.js +++ b/rules/properties-alphabetical-order/tests/index.js @@ -177,20 +177,6 @@ testRule({ fixed: 'a { align: center; Border-width: 1px; border-top-width: 2px; color: red; }', message: messages.expected('Border-width', 'border-top-width'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { color: red; align: center; margin: 1px; Margin: 1px; }', - fixed: 'a { align: center; color: red; margin: 1px; Margin: 1px; }', - message: messages.expected('align', 'color'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { color: red; Color: red; margin-top: 1px; margin: 1px; }', - fixed: 'a { color: red; Color: red; margin: 1px; margin-top: 1px; }', - message: messages.expected('margin', 'margin-top'), - }, ], }); diff --git a/rules/properties-order/tests/flat.js b/rules/properties-order/tests/flat.js index f8e9b6b..3830c01 100644 --- a/rules/properties-order/tests/flat.js +++ b/rules/properties-order/tests/flat.js @@ -73,13 +73,6 @@ testRule({ fixed: 'a { top: 0; Color: pink; }', message: messages.expected('top', 'Color'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { color: pink; Top: 0; }', - fixed: 'a { Top: 0; color: pink; }', - message: messages.expected('Top', 'color'), - }, { // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 skip: true, @@ -87,13 +80,6 @@ testRule({ fixed: 'a { Top: 0; top: 0; color: pink; }', message: messages.expected('top', 'color'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { top: 0; color: pink; Top: 0; }', - fixed: 'a { top: 0; Top: 0; color: pink; }', - message: messages.expected('Top', 'color'), - }, { code: 'a { top: 0; transform: scale(1); color: pink; }', fixed: 'a { transform: scale(1); top: 0; color: pink; }', @@ -237,19 +223,9 @@ testRule({ { code: 'a { top: 0; height: 1px; color: pink; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { top: 0; height: 1px; Color: pink; }', - }, { code: 'a { bottom: 0; top: 0; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Bottom: 0; top: 0; }', - }, ], reject: [ @@ -258,27 +234,6 @@ testRule({ fixed: 'a { top: 0; height: 1px; }', message: messages.expected('top', 'height'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; top: 0; }', - fixed: 'a { top: 0; Height: 1px; }', - message: messages.expected('top', 'Height'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Top: 0; }', - fixed: 'a { Top: 0; height: 1px; }', - message: messages.expected('Top', 'height'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; Top: 0; }', - fixed: 'a { Top: 0; Height: 1px; }', - message: messages.expected('Top', 'Height'), - }, { code: 'a { color: 1px; top: 0; }', fixed: 'a { top: 0; color: 1px; }', @@ -301,19 +256,9 @@ testRule({ { code: 'a { height: 1px; color: pink; bottom: 0; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; color: pink; bottom: 0; }', - }, { code: 'a { bottom: 0; top: 0; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { bottom: 0; Top: 0; }', - }, ], reject: [ @@ -322,27 +267,6 @@ testRule({ fixed: 'a { height: 1px; bottom: 0; }', message: messages.expected('height', 'bottom'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Bottom: 0; height: 1px; }', - fixed: 'a { height: 1px; Bottom: 0; }', - message: messages.expected('height', 'Bottom'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { bottom: 0; Height: 1px; }', - fixed: 'a { Height: 1px; bottom: 0; }', - message: messages.expected('Height', 'bottom'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Bottom: 0; Height: 1px; }', - fixed: 'a { Height: 1px; Bottom: 0; }', - message: messages.expected('Height', 'Bottom'), - }, { code: 'a { bottom: 0; color: 1px; }', fixed: 'a { color: 1px; bottom: 0; }', @@ -371,21 +295,6 @@ testRule({ { code: 'a { all: initial; compose: b; bottom: 0; top: 0; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { all: initial; Compose: b; bottom: 0; top: 0; }', - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { all: initial; compose: b; Bottom: 0; top: 0; }', - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { all: initial; Compose: b; Bottom: 0; top: 0; }', - }, ], reject: [ @@ -394,27 +303,6 @@ testRule({ fixed: 'a { all: initial; align-items: flex-end; }', message: messages.expected('all', 'align-items'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Align-items: flex-end; all: initial; }', - fixed: 'a { all: initial; Align-items: flex-end; }', - message: messages.expected('all', 'Align-items'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { align-items: flex-end; All: initial; }', - fixed: 'a { All: initial; align-items: flex-end; }', - message: messages.expected('All', 'align-items'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Align-items: flex-end; All: initial; }', - fixed: 'a { All: initial; Align-items: flex-end; }', - message: messages.expected('All', 'Align-items'), - }, { code: 'a { compose: b; top: 0; bottom: 0; }', fixed: 'a { compose: b; bottom: 0; top: 0; }', @@ -441,27 +329,6 @@ testRule({ fixed: '.foo { left: 0; margin: 0; color: pink; }', message: messages.expected('left', 'margin'), }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: '.foo { margin: 0; color: pink; Left: 0; }', - fixed: '.foo { Left: 0; margin: 0; color: pink; }', - message: messages.expected('Left', 'margin'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: '.foo { Margin: 0; color: pink; left: 0; }', - fixed: '.foo { left: 0; Margin: 0; color: pink; }', - message: messages.expected('left', 'Margin'), - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: '.foo { Margin: 0; color: pink; Left: 0; }', - fixed: '.foo { Left: 0; Margin: 0; color: pink; }', - message: messages.expected('Left', 'Margin'), - }, ], }); diff --git a/rules/properties-order/tests/validate-options.js b/rules/properties-order/tests/validate-options.js index 57a0c80..10c68f9 100644 --- a/rules/properties-order/tests/validate-options.js +++ b/rules/properties-order/tests/validate-options.js @@ -121,33 +121,3 @@ testConfig({ ], message: `Invalid option "[{"emptyLineBefore":"always","order":"flexible","properties":null}]" for rule "${ruleName}"`, }); - -testConfig({ - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - ruleName, - description: 'no duplicates in properties', - valid: false, - config: [ - { - properties: ['top', 'top'], - }, - ], - message: `Invalid option "[{"properties":["top", "top"]}]" for rule "${ruleName}"`, -}); - -testConfig({ - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - ruleName, - description: 'no duplicates in properties (case insensitive)', - valid: false, - config: [ - { - emptyLineBefore: 'always', - order: 'flexible', - properties: ['top', 'Top'], - }, - ], - message: `Invalid option "[{"properties":["top", "Top"]}]" for rule "${ruleName}"`, -}); From 513ec2b14c387fae180811578622f031885f0a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Ma=C5=82olepszy?= Date: Wed, 9 Oct 2024 10:17:40 +0200 Subject: [PATCH 6/6] Remove tests from grouped-flexible.js --- .../tests/grouped-flexible.js | 150 ------------------ 1 file changed, 150 deletions(-) diff --git a/rules/properties-order/tests/grouped-flexible.js b/rules/properties-order/tests/grouped-flexible.js index 3c77a67..c4cb9ef 100644 --- a/rules/properties-order/tests/grouped-flexible.js +++ b/rules/properties-order/tests/grouped-flexible.js @@ -20,11 +20,6 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', - }, { code: 'a { height: 1px; width: 2px; font-size: 2px; color: pink; font-weight: bold; }', }, @@ -57,20 +52,10 @@ testRule({ code: 'a { height: 10px; background: orange; }', description: 'unspecified after groupless specified', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 10px; background: orange; }', - }, { code: 'a { font-weight: bold; background: orange; }', description: 'unspecified after grouped specified', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Font-weight: bold; background: orange; }', - }, ], reject: [ @@ -81,33 +66,6 @@ testRule({ line: 1, column: 37, }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', - fixed: 'a { height: 1px; Width: 2px; Font-weight: bold; }', - message: messages.expected('Width', 'Font-weight'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; width: 2px; }', - fixed: 'a { height: 1px; width: 2px; Font-weight: bold; }', - message: messages.expected('width', 'Font-weight'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; font-weight: bold; Width: 2px; }', - fixed: 'a { height: 1px; Width: 2px; font-weight: bold; }', - message: messages.expected('Width', 'font-weight'), - line: 1, - column: 37, - }, { code: 'a { font-weight: bold; height: 1px; width: 2px; }', fixed: 'a { height: 1px; width: 2px; font-weight: bold; }', @@ -151,16 +109,6 @@ testRule({ { code: 'a { font-size: 2px; font-weight: bold; height: 1px; width: 2px; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Font-size: 2px; Font-weight: bold; height: 1px; width: 2px; }', - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Font-size: 2px; Font-weight: bold; Height: 1px; Width: 2px; }', - }, ], reject: [ { @@ -169,30 +117,6 @@ testRule({ line: 1, column: 18, }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; }', - message: messages.expected('Font-weight', 'height', 'font'), - line: 1, - column: 18, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; font-weight: bold; }', - message: messages.expected('font-weight', 'Height', 'font'), - line: 1, - column: 18, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; Font-weight: bold; }', - message: messages.expected('Font-weight', 'Height', 'font'), - line: 1, - column: 18, - }, ], }); @@ -216,16 +140,6 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; width: 2px; Color: pink; Font-size: 2px; font-weight: bold; }', - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', - }, { code: 'a { width: 2px; height: 1px; font-size: 2px; color: pink; font-weight: bold; }', }, @@ -245,33 +159,6 @@ testRule({ line: 1, column: 37, }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; font-weight: bold; Width: 2px; }', - fixed: 'a { Width: 2px; height: 1px; font-weight: bold; }', - message: messages.expected('Width', 'font-weight'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; width: 2px; }', - fixed: 'a { width: 2px; height: 1px; Font-weight: bold; }', - message: messages.expected('width', 'Font-weight'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', - fixed: 'a { Width: 2px; height: 1px; Font-weight: bold; }', - message: messages.expected('Width', 'Font-weight'), - line: 1, - column: 37, - }, { code: 'a { font-weight: bold; height: 1px; width: 2px; }', fixed: 'a { width: 2px; height: 1px; font-weight: bold; }', @@ -311,16 +198,6 @@ testRule({ { code: 'a { height: 1px; width: 2px; color: pink; font-size: 2px; font-weight: bold; }', }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; width: 2px; Color: pink; font-size: 2px; font-weight: bold; }', - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { Height: 1px; Width: 2px; Color: pink; Font-size: 2px; Font-weight: bold; }', - }, ], reject: [ { @@ -330,32 +207,5 @@ testRule({ line: 1, column: 37, }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; font-weight: bold; Width: 2px; }', - fixed: 'a { Width: 2px; height: 1px; font-weight: bold; }', - message: messages.expected('Width', 'font-weight', 'dimensions'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; width: 2px; }', - fixed: 'a { width: 2px; height: 1px; Font-weight: bold; }', - message: messages.expected('width', 'Font-weight', 'dimensions'), - line: 1, - column: 37, - }, - { - // blocked by https://github.com/hudochenkov/stylelint-order/issues/78 - skip: true, - code: 'a { height: 1px; Font-weight: bold; Width: 2px; }', - fixed: 'a { Width: 2px; height: 1px; Font-weight: bold; }', - message: messages.expected('Width', 'Font-weight', 'dimensions'), - line: 1, - column: 37, - }, ], });