Skip to content

Commit

Permalink
fix(newline-after-description): avoid erring on encountering sequen…
Browse files Browse the repository at this point in the history
…ce of carriage returns (or other non-whitespace) as sole content of jsdoc block description (fixes #433)
  • Loading branch information
brettz9 committed Nov 19, 2019
1 parent a38b28b commit e453b2d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4350,6 +4350,20 @@ function quux () {
// Options: ["never"]
// Message: There must be no newline after the description of the JSDoc block.
/**
* Bar.
*
* Bar.
*
* @bar
*/
function quux () {
}
// Options: ["never"]
// Message: There must be no newline after the description of the JSDoc block.
/**
* A.
*
Expand Down Expand Up @@ -4415,6 +4429,23 @@ function quux () {
}
// Options: ["never"]
/**
* @foo
* Test 
* abc 
* @bar 
*/
/**
*
* @foo
* Test 
* abc 
* @bar 
*/
````
Expand Down
2 changes: 1 addition & 1 deletion src/rules/newlineAfterDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default iterateJsdoc(({
}) => {
let always;

if (!jsdoc.description || !jsdoc.tags.length) {
if (!jsdoc.description.trim() || !jsdoc.tags.length) {
return;
}

Expand Down
55 changes: 55 additions & 0 deletions test/rules/assertions/newlineAfterDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,40 @@ export default {
}
`,
},
{
code: `\r
/**\r
* Bar.\r
*\r
* Bar.\r
*\r
* @bar\r
*/\r
function quux () {\r
\r
}\r
`,
errors: [
{
line: 6,
message: 'There must be no newline after the description of the JSDoc block.',
},
],
options: [
'never',
],
output: `\r
/**\r
* Bar.\r
*\r
* Bar.\r
* @bar\r
*/\r
function quux () {\r
\r
}\r
`,
},
{
code: `
/**
Expand Down Expand Up @@ -232,5 +266,26 @@ export default {
'never',
],
},
{
code: `\r
/**\r
* @foo\r
* Test\u00a0\r
* abc\u00a0\r
* @bar\u00a0\r
*/\r
`,
},
{
code: `\r
/**\r
* \r
* @foo\r
* Test\u00a0\r
* abc\u00a0\r
* @bar\u00a0\r
*/\r
`,
},
],
};

0 comments on commit e453b2d

Please sign in to comment.