Skip to content

Commit

Permalink
no-redundant-jsdoc: allow @template with comment (palantir#3415)
Browse files Browse the repository at this point in the history
[bugfix] `no-redundant-jsdoc` allow `@template` tag if it has a description
Fixes: palantir#3386
  • Loading branch information
ajafff authored and adidahiya committed Dec 1, 2017
1 parent 271e651 commit 9afce3b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/rules/noRedundantJsdocRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ function walk(ctx: Lint.WalkContext<void>): void {
break;

case ts.SyntaxKind.JSDocClassTag:
case ts.SyntaxKind.JSDocTemplateTag:
case ts.SyntaxKind.JSDocTypeTag:
case ts.SyntaxKind.JSDocTypedefTag:
case ts.SyntaxKind.JSDocPropertyTag:
// Always redundant
ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_REDUNDANT_TAG(tag.tagName.text));
break;

case ts.SyntaxKind.JSDocTemplateTag:
if ((tag as ts.JSDocTemplateTag).comment === undefined || (tag as ts.JSDocTemplateTag).comment === "") {
ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text));
}
break;

case ts.SyntaxKind.JSDocReturnTag:
case ts.SyntaxKind.JSDocParameterTag: {
const { typeExpression, comment } = tag as ts.JSDocReturnTag | ts.JSDocParameterTag;
Expand Down
14 changes: 12 additions & 2 deletions test/rules/no-redundant-jsdoc/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ declare function g(x: number, y: number, z: number): number;
*/
declare function h(x: number): number;

/**
* @template T, U
#if typescript < 2.2.0 || >= 2.3.0
~~~~~~~~ [description % ('template')]
#endif
* @template V Some additional information
*/
declare function i<T, U, V>(x: T, y: V): U;

[tag]: JSDoc tag '@%s' is redundant in TypeScript code.
[type]: Type annotation in JSDoc is redundant in TypeScript code.
[param]: '@param' is redundant in TypeScript code if it has no description.
[returns]: '@returns' is redundant in TypeScript code if it has no description.
[description]: '@%s' is redundant in TypeScript code if it has no description.
[param]: description % ('param')
[returns]: description % ('returns')

0 comments on commit 9afce3b

Please sign in to comment.