From a1df43f4b22c23edd883836459ba535d8e1723d4 Mon Sep 17 00:00:00 2001 From: Aleks Hudochenkov Date: Tue, 9 Apr 2019 20:56:47 +0200 Subject: [PATCH] Fix false negatives with `noEmptyLineBetween` in combination with the `order: "flexible"` Closes #82 --- rules/properties-order/createExpectedOrder.js | 1 + .../tests/no-empty-line-between.js | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/rules/properties-order/createExpectedOrder.js b/rules/properties-order/createExpectedOrder.js index 5006aa0..2092fae 100644 --- a/rules/properties-order/createExpectedOrder.js +++ b/rules/properties-order/createExpectedOrder.js @@ -40,6 +40,7 @@ module.exports = function createExpectedOrder(input) { if (item.order && item.order === 'flexible') { expectedPosition += 1; + groupPosition += 1; item.properties.forEach(property => { appendItem(property, true, item); diff --git a/rules/properties-order/tests/no-empty-line-between.js b/rules/properties-order/tests/no-empty-line-between.js index f8bcfc6..05221aa 100644 --- a/rules/properties-order/tests/no-empty-line-between.js +++ b/rules/properties-order/tests/no-empty-line-between.js @@ -215,3 +215,96 @@ testRule(rule, { }, ], }); + +testRule(rule, { + ruleName, + config: [ + [ + { + emptyLineBefore: 'always', + noEmptyLineBetween: true, + order: 'flexible', + properties: ['height', 'width'], + }, + { + emptyLineBefore: 'always', + noEmptyLineBetween: true, + order: 'flexible', + properties: ['font-size', 'font-weight'], + }, + ], + ], + fix: true, + + accept: [ + { + code: ` + a { + height: 1px; + width: 2px; + + font-size: 2px; + font-weight: bold; + } + `, + }, + { + code: ` + a { + height: 1px; + width: 2px; + + font-weight: bold; + font-size: 2px; + } + `, + }, + ], + + reject: [ + { + code: ` + a { + height: 1px; + width: 2px; + + font-weight: bold; + + font-size: 2px; + } + `, + fixed: ` + a { + height: 1px; + width: 2px; + + font-weight: bold; + font-size: 2px; + } + `, + message: messages.rejectedEmptyLineBefore('font-size'), + }, + { + code: ` + a { + height: 1px; + width: 2px; + + font-size: 2px; + + font-weight: bold; + } + `, + fixed: ` + a { + height: 1px; + width: 2px; + + font-size: 2px; + font-weight: bold; + } + `, + message: messages.rejectedEmptyLineBefore('font-weight'), + }, + ], +});