Skip to content

Commit ea74188

Browse files
committed
fix: handle multiline bodies properly
1 parent e314d5b commit ea74188

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

source/rules/footer-leading-blank.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ export default (parsed, when) => {
66

77
const negated = when === 'never';
88

9-
// get complete body split into lines
10-
const lines = (parsed.raw || '').split(/\r|\n/).slice(2);
9+
const count = (parsed.body || '').split(/\r|\n/).length;
10+
11+
// get complete message split into lines
12+
const lines = (parsed.raw || '')
13+
.split(/\r|\n/)
14+
.slice(count + 1);
15+
1116
const [leading] = lines;
1217

13-
// check if the first line of body is empty
18+
// check if the first line of footer is empty
1419
const succeeds = leading === '';
1520

1621
return [

source/rules/footer-leading-blank.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ test('with blank line before footer should succeed for "always"', t => {
110110
t.is(actual, expected);
111111
});
112112

113-
test.failing('with blank line before footer and multiline body should succeed for empty keyword', t => {
113+
test('with blank line before footer and multiline body should succeed for empty keyword', t => {
114114
const [actual] = footerLeadingBlank(parsed.withMulitLine);
115115
const expected = true;
116116
t.is(actual, expected);
117117
});
118118

119-
test.failing('with blank line before footer and multiline body should fail for "never"', t => {
119+
test('with blank line before footer and multiline body should fail for "never"', t => {
120120
const [actual] = footerLeadingBlank(parsed.withMulitLine, 'never');
121121
const expected = false;
122122
t.is(actual, expected);
123123
});
124124

125-
test.failing('with blank line before footer and multiline body should succeed for "always"', t => {
125+
test('with blank line before footer and multiline body should succeed for "always"', t => {
126126
const [actual] = footerLeadingBlank(parsed.withMulitLine, 'always');
127127
const expected = true;
128128
t.is(actual, expected);

0 commit comments

Comments
 (0)