Skip to content

Commit

Permalink
[bugfix] Completed docs rule can check single-line comments (palantir…
Browse files Browse the repository at this point in the history
…#3841)

* Added tests for singleline comment

* Optional new line in JsDoc
  • Loading branch information
PomanoB authored and giladgray committed Jul 31, 2018
1 parent 0a676b7 commit a2fac98
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/completed-docs/tagExclusion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class TagExclusion extends Exclusion<ITagExclusionDescriptor> {
return [];
}

const docMatches = nodeText.match((/\/\*\*\s*\n([^\*]*(\*[^\/])?)*\*\//));
const docMatches = nodeText.match((/\/\*\*\s*\n?([^\*]*(\*[^\/])?)*\*\//));
if (docMatches === null || docMatches.length === 0) {
return [];
}
Expand Down
18 changes: 18 additions & 0 deletions test/rules/completed-docs/tags/content/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,42 @@ const CompletelyEmptyVariable = 0;
const ContentEmptyVariable = 1;
~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/** */
const ContentSingleLineEmptyVariable = 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/**
* @see
*/
const ContentMissingVariable = 2;
~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/** @see */
const ContentSingleLineMissingVariable = 2;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/**
* @see wat
*/
const ContentInvalidVariable = 3;
~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/** @see wat */
const ContentSingleLineInvalidVariable = 3;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/**
* @see #123
*/
const ContentValidVariable = 4;

/** @see #123 */
const ContentSingleLineValidVariable = 4;

/**
* ...
*/
const CommentBodyVariableRofl = 5;

/** ... */
const CommentBodyVariableRofl = 5;
13 changes: 13 additions & 0 deletions test/rules/completed-docs/tags/existence/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@ const CompletelyEmptyVariable = 0;
const ContentEmptyVariable = 1;
~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/** */
const ContentSingleLineEmptyVariable = 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for variables.]

/**
* @deprecated
*/
const ContentMissingVariable = 2;

/** @deprecated */
const ContentSingleLineMissingVariable = 2;

/**
* @deprecated Do not use!
*/
const ContentValidVariable = 4;

/** @deprecated Do not use! */
const ContentSingleLineValidVariable = 4;

/**
* ...
*/
const CommentBodyVariable = 5;

/** ... */
const CommentSingleLineBodyVariable = 5;

0 comments on commit a2fac98

Please sign in to comment.