Skip to content

Commit e453b2d

Browse files
committed
fix(newline-after-description): avoid erring on encountering sequence of carriage returns (or other non-whitespace) as sole content of jsdoc block description (fixes #433)
1 parent a38b28b commit e453b2d

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,6 +4350,20 @@ function quux () {
43504350
// Options: ["never"]
43514351
// Message: There must be no newline after the description of the JSDoc block.
43524352
4353+
4354+
/**
4355+
* Bar.
4356+
*
4357+
* Bar.
4358+
*
4359+
* @bar
4360+
*/
4361+
function quux () {
4362+
4363+
}
4364+
// Options: ["never"]
4365+
// Message: There must be no newline after the description of the JSDoc block.
4366+
43534367
/**
43544368
* A.
43554369
*
@@ -4415,6 +4429,23 @@ function quux () {
44154429
44164430
}
44174431
// Options: ["never"]
4432+
4433+
4434+
/**
4435+
* @foo
4436+
* Test 
4437+
* abc 
4438+
* @bar 
4439+
*/
4440+
4441+
4442+
/**
4443+
*
4444+
* @foo
4445+
* Test 
4446+
* abc 
4447+
* @bar 
4448+
*/
44184449
````
44194450
44204451

src/rules/newlineAfterDescription.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default iterateJsdoc(({
1111
}) => {
1212
let always;
1313

14-
if (!jsdoc.description || !jsdoc.tags.length) {
14+
if (!jsdoc.description.trim() || !jsdoc.tags.length) {
1515
return;
1616
}
1717

test/rules/assertions/newlineAfterDescription.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,40 @@ export default {
9999
}
100100
`,
101101
},
102+
{
103+
code: `\r
104+
/**\r
105+
* Bar.\r
106+
*\r
107+
* Bar.\r
108+
*\r
109+
* @bar\r
110+
*/\r
111+
function quux () {\r
112+
\r
113+
}\r
114+
`,
115+
errors: [
116+
{
117+
line: 6,
118+
message: 'There must be no newline after the description of the JSDoc block.',
119+
},
120+
],
121+
options: [
122+
'never',
123+
],
124+
output: `\r
125+
/**\r
126+
* Bar.\r
127+
*\r
128+
* Bar.\r
129+
* @bar\r
130+
*/\r
131+
function quux () {\r
132+
\r
133+
}\r
134+
`,
135+
},
102136
{
103137
code: `
104138
/**
@@ -232,5 +266,26 @@ export default {
232266
'never',
233267
],
234268
},
269+
{
270+
code: `\r
271+
/**\r
272+
* @foo\r
273+
* Test\u00a0\r
274+
* abc\u00a0\r
275+
* @bar\u00a0\r
276+
*/\r
277+
`,
278+
},
279+
{
280+
code: `\r
281+
/**\r
282+
* \r
283+
* @foo\r
284+
* Test\u00a0\r
285+
* abc\u00a0\r
286+
* @bar\u00a0\r
287+
*/\r
288+
`,
289+
},
235290
],
236291
};

0 commit comments

Comments
 (0)