Skip to content

Commit 04d84a1

Browse files
committed
fix(require-description-complete-sentence); avoid treating line breaks preceding colon/semi-colon as new paragraph; fixes #390
1 parent cce70b0 commit 04d84a1

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.README/rules/require-description-complete-sentence.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ tag descriptions are written in complete sentences, i.e.,
88
* Sentences must end with a period.
99
* Every line in a paragraph (except the first) which starts with an uppercase
1010
character must be preceded by a line ending with a period.
11+
* A colon or semi-colon followed by two line breaks is still part of the
12+
containing paragraph (unlike normal dual line breaks).
1113

1214
#### Options
1315

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,6 +3834,8 @@ tag descriptions are written in complete sentences, i.e.,
38343834
* Sentences must end with a period.
38353835
* Every line in a paragraph (except the first) which starts with an uppercase
38363836
character must be preceded by a line ending with a period.
3837+
* A colon or semi-colon followed by two line breaks is still part of the
3838+
containing paragraph (unlike normal dual line breaks).
38373839

38383840
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-7"></a>
38393841
#### Options
@@ -4280,6 +4282,13 @@ function quux (foo) {
42804282

42814283
}
42824284
// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4285+
4286+
/**
4287+
* We stop loading Items when we have loaded:
4288+
*
4289+
* 1) The main Item;
4290+
* 2) All its variants.
4291+
*/
42834292
````
42844293

42854294

src/rules/requireDescriptionCompleteSentence.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {RegExtras} from 'regextras/dist/main-umd';
33
import iterateJsdoc from '../iterateJsdoc';
44

55
const extractParagraphs = (text) => {
6-
return text.split(/\n\n/);
6+
// Todo [engine:node@>8.11.0]: Uncomment following line with neg. lookbehind instead
7+
// return text.split(/(?<![;:])\n\n/);
8+
return [...text].reverse().join('').split(/\n\n(?![;:])/).map((par) => {
9+
return [...par].reverse().join('');
10+
}).reverse();
711
};
812

913
const extractSentences = (text) => {

test/rules/assertions/requireDescriptionCompleteSentence.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,5 +887,15 @@ export default {
887887
},
888888
},
889889
},
890+
{
891+
code: `
892+
/**
893+
* We stop loading Items when we have loaded:
894+
*
895+
* 1) The main Item;
896+
* 2) All its variants.
897+
*/
898+
`,
899+
},
890900
],
891901
};

0 commit comments

Comments
 (0)