From ef4062068ead2d8a6517aee3b2aa4528a62c0576 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sun, 26 Apr 2020 01:07:35 -0700 Subject: [PATCH 1/4] adds isFirstNodeOfRoot check & tests for declaration-empty-line-before --- .../__tests__/index.js | 41 +++++++++++++++++++ .../declaration-empty-line-before/index.js | 6 +++ 2 files changed, 47 insertions(+) diff --git a/lib/rules/declaration-empty-line-before/__tests__/index.js b/lib/rules/declaration-empty-line-before/__tests__/index.js index 2cccebd2a5..7acf4b1cfa 100644 --- a/lib/rules/declaration-empty-line-before/__tests__/index.js +++ b/lib/rules/declaration-empty-line-before/__tests__/index.js @@ -2,6 +2,7 @@ const rule = require('..'); const { messages, ruleName } = rule; +const stripIndent = require('common-tags').stripIndent; testRule(rule, { ruleName, @@ -898,3 +899,43 @@ testRule(rule, { }, ], }); + +testRule(rule, { + ruleName, + config: ['always'], + syntax: 'html', + + accept: [ + { + code: ``, + description: 'Single-line HTML style tag', + }, + { + code: ``, + description: 'Single-line HTML style attribute with two declarations', + }, + { + code: stripIndent` + Text + `, + description: 'Multi-line HTML style attribute with two declarations', + }, + ], + reject: [ + { + code: stripIndent` + `, description: 'flush declaration in style tag', message: messages.expected, line: 4, - column: 8, + column: 2, }, ], }); From 94ef297af394cf09132373b3d0b3532eed0ed146 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Mon, 27 Apr 2020 20:13:28 -0700 Subject: [PATCH 4/4] adjusts passing tests thank you @jeddy3! --- .../__tests__/index.js | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/lib/rules/declaration-empty-line-before/__tests__/index.js b/lib/rules/declaration-empty-line-before/__tests__/index.js index 5da2d276c1..e4c73968d3 100644 --- a/lib/rules/declaration-empty-line-before/__tests__/index.js +++ b/lib/rules/declaration-empty-line-before/__tests__/index.js @@ -904,12 +904,66 @@ testRule(rule, { ruleName, config: ['always'], syntax: 'html', - + fix: true, accept: [ { code: ``, description: 'Single-line HTML style tag', }, + { + code: stripIndent` + + Text + `, + description: 'Multi-line HTML style attribute with two declarations', + }, + ], + reject: [ + { + code: stripIndent` + + `, + fixed: stripIndent` + + `, + description: 'flush declaration in style tag', + warnings: [ + { + message: messages.expected, + line: 1, + column: 25, + }, + { + message: messages.expected, + line: 4, + column: 2, + }, + ], + }, + ], +}); + +testRule(rule, { + ruleName, + config: ['always', { ignore: ['inside-single-line-block'] }], + syntax: 'html', + fix: true, + + accept: [ { code: ``, description: 'Single-line HTML style attribute with two declarations', @@ -919,6 +973,7 @@ testRule(rule, { Text @@ -929,9 +984,16 @@ testRule(rule, { reject: [ { code: stripIndent` - + `, + fixed: stripIndent` + + `, description: 'flush declaration in style tag',