Skip to content

Commit f04974f

Browse files
tomtomsentclindner
authored andcommitted
Bugfix/163 empty description (#164)
* Fix test description to match, what actually is happening * Allow empty description Fixed issue which results in a javascript error if description was empty. Fixes #163
1 parent 928a1d3 commit f04974f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/rules/description-format.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const lint = (packageJsonData, severity, config) => {
1919
if (
2020
config.hasOwnProperty('requireCapitalFirstLetter') &&
2121
config.requireCapitalFirstLetter &&
22+
description.length > 0 &&
2223
description[0] !== description[0].toUpperCase()
2324
) {
2425
return new LintIssue(

test/unit/rules/description-format.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,22 @@ describe('description-format Unit Tests', () => {
6363
});
6464
});
6565

66+
describe('when package.json has empty node', () => {
67+
test('true should be returned', () => {
68+
const packageJsonData = {
69+
description: ''
70+
};
71+
const config = {
72+
requireCapitalFirstLetter: true
73+
};
74+
const response = lint(packageJsonData, 'error', config);
75+
76+
expect(response).toBe(true);
77+
});
78+
});
79+
6680
describe('when package.json has node with correct format', () => {
67-
test('LintIssue object should be returned', () => {
81+
test('true should be returned', () => {
6882
const packageJsonData = {
6983
description: 'My description.'
7084
};

0 commit comments

Comments
 (0)