From a2fac98651e8ac1ab75ce18e2965a34660dae878 Mon Sep 17 00:00:00 2001 From: PomanoB Date: Tue, 31 Jul 2018 21:04:59 +0300 Subject: [PATCH] [bugfix] Completed docs rule can check single-line comments (#3841) * Added tests for singleline comment * Optional new line in JsDoc --- src/rules/completed-docs/tagExclusion.ts | 2 +- .../completed-docs/tags/content/test.ts.lint | 18 ++++++++++++++++++ .../completed-docs/tags/existence/test.ts.lint | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/rules/completed-docs/tagExclusion.ts b/src/rules/completed-docs/tagExclusion.ts index a394724b163..1c4fc47ad5a 100644 --- a/src/rules/completed-docs/tagExclusion.ts +++ b/src/rules/completed-docs/tagExclusion.ts @@ -75,7 +75,7 @@ export class TagExclusion extends Exclusion { return []; } - const docMatches = nodeText.match((/\/\*\*\s*\n([^\*]*(\*[^\/])?)*\*\//)); + const docMatches = nodeText.match((/\/\*\*\s*\n?([^\*]*(\*[^\/])?)*\*\//)); if (docMatches === null || docMatches.length === 0) { return []; } diff --git a/test/rules/completed-docs/tags/content/test.ts.lint b/test/rules/completed-docs/tags/content/test.ts.lint index 4d381365478..d0bbbc68cc3 100644 --- a/test/rules/completed-docs/tags/content/test.ts.lint +++ b/test/rules/completed-docs/tags/content/test.ts.lint @@ -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; diff --git a/test/rules/completed-docs/tags/existence/test.ts.lint b/test/rules/completed-docs/tags/existence/test.ts.lint index 924bd17fc4d..2fed3a242b2 100644 --- a/test/rules/completed-docs/tags/existence/test.ts.lint +++ b/test/rules/completed-docs/tags/existence/test.ts.lint @@ -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;