Skip to content

Commit

Permalink
fix(newline-after-description): only treat comments with whitespace…
Browse files Browse the repository at this point in the history
… after two asterisks only as jsdoc

Per jsdoc spec at https://jsdoc.app/about-getting-started.html :

> Each comment must start with a /** sequence in order to be recognized by the JSDoc parser. Comments beginning with /*, /***, or more than 3 stars will be ignored.
  • Loading branch information
brettz9 committed Nov 20, 2019
1 parent e453b2d commit 3d61126
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -1111,7 +1111,7 @@ report a padding issue:
The following patterns are considered problems:

````js
/*** foo */
/** foo */
function quux () {

}
Expand Down Expand Up @@ -4446,6 +4446,14 @@ function quux () {
* abc 
* @bar 
*/
/***
*
*/
function quux () {
}
// Options: ["always"]
````
Expand Down
2 changes: 1 addition & 1 deletion src/iterateJsdoc.js
Expand Up @@ -431,7 +431,7 @@ const iterateAllJsdocs = (iterator, ruleConfig) => {
const comments = sourceCode.getAllComments();

comments.forEach((comment) => {
if (!sourceCode.getText(comment).startsWith('/**')) {
if (!(/\/\*\*\s/).test(sourceCode.getText(comment))) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/rules/assertions/checkIndentation.js
Expand Up @@ -2,7 +2,7 @@ export default {
invalid: [
{
code: `
/*** foo */
/** foo */
function quux () {
}
Expand Down
12 changes: 12 additions & 0 deletions test/rules/assertions/newlineAfterDescription.js
Expand Up @@ -287,5 +287,17 @@ export default {
*/\r
`,
},
{
code: `
/***
*
*/
function quux () {
}`,
options: [
'always',
],
},
],
};

0 comments on commit 3d61126

Please sign in to comment.