Skip to content

Commit 0fb07c1

Browse files
committed
fix(require-description-complete-sentence): allow pipe symbol at beginning/end of sentences; fixes #423
1 parent bdff306 commit 0fb07c1

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4778,6 +4778,15 @@ function quux (foo) {
47784778
* 1) The main Item;
47794779
* 2) All its variants.
47804780
*/
4781+
4782+
/**
4783+
* This method is working on 2 steps.
4784+
*
4785+
* | Step | Comment |
4786+
* |------|-------------|
4787+
* | 1 | do it |
4788+
* | 2 | do it again |
4789+
*/
47814790
````
47824791

47834792

src/rules/requireDescriptionCompleteSentence.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const isNewLinePrecededByAPeriod = (text) => {
4141
return true;
4242
}
4343

44-
lastLineEndsSentence = /[.:?!]$/u.test(line);
44+
lastLineEndsSentence = /[.:?!|]$/u.test(line);
4545

4646
return false;
4747
});
@@ -51,6 +51,10 @@ const isCapitalized = (str) => {
5151
return str[0] === str[0].toUpperCase();
5252
};
5353

54+
const isTable = (str) => {
55+
return str.charAt() === '|';
56+
};
57+
5458
const capitalize = (str) => {
5559
return str.charAt(0).toUpperCase() + str.slice(1);
5660
};
@@ -75,7 +79,7 @@ const validateDescription = (description, reportOrig, jsdocNode, sourceCode, tag
7579
}
7680

7781
for (const sentence of sentences.filter((sentence_) => {
78-
return !(/^\s*$/u).test(sentence_) && !isCapitalized(sentence_);
82+
return !(/^\s*$/u).test(sentence_) && !isCapitalized(sentence_) && !isTable(sentence_);
7983
})) {
8084
const beginning = sentence.split('\n')[0];
8185

@@ -102,12 +106,12 @@ const validateDescription = (description, reportOrig, jsdocNode, sourceCode, tag
102106
};
103107

104108
if (sentences.some((sentence) => {
105-
return !(/^\s*$/u).test(sentence) && !isCapitalized(sentence);
109+
return !(/^\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
106110
})) {
107111
report('Sentence should start with an uppercase character.', fix, tag);
108112
}
109113

110-
if (!/[.!?]$/u.test(paragraph)) {
114+
if (!/[.!?|]$/u.test(paragraph)) {
111115
report('Sentence must end with a period.', fix, tag);
112116

113117
return true;

test/rules/assertions/requireDescriptionCompleteSentence.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,5 +897,17 @@ export default {
897897
*/
898898
`,
899899
},
900+
{
901+
code: `
902+
/**
903+
* This method is working on 2 steps.
904+
*
905+
* | Step | Comment |
906+
* |------|-------------|
907+
* | 1 | do it |
908+
* | 2 | do it again |
909+
*/
910+
`,
911+
},
900912
],
901913
};

0 commit comments

Comments
 (0)