Skip to content

Commit 65fc90a

Browse files
committed
fix: handle empty body gracefully
1 parent 6c338e0 commit 65fc90a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

source/rules/body-case.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import ensureCase from '../library/ensure-case';
22

33
export default (parsed, when, value) => {
4+
const {body} = parsed;
5+
6+
if (!body) {
7+
return [true];
8+
}
9+
410
const negated = when === 'never';
11+
512
const result = ensureCase(parsed.body, value);
613
return [
714
negated ? !result : result,

source/rules/body-case.test.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ const parsed = {
1616
uppercase: parse(messages.uppercase)
1717
};
1818

19-
test.failing('with empty body should succeed for empty keyword', t => {
20-
const [actual] = bodyCase(parsed.empty);
21-
const expected = true;
22-
t.is(actual, expected);
23-
});
24-
25-
test.failing('with empty body should succeed for "never lowercase"', t => {
19+
test('with empty body should succeed for "never lowercase"', t => {
2620
const [actual] = bodyCase(parsed.empty, 'never', 'lowercase');
2721
const expected = true;
2822
t.is(actual, expected);
@@ -34,7 +28,7 @@ test('with empty body should succeed for "always lowercase"', t => {
3428
t.is(actual, expected);
3529
});
3630

37-
test.failing('with empty body should succeed for "never uppercase"', t => {
31+
test('with empty body should succeed for "never uppercase"', t => {
3832
const [actual] = bodyCase(parsed.empty, 'never', 'uppercase');
3933
const expected = true;
4034
t.is(actual, expected);

0 commit comments

Comments
 (0)