Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

noRedundantJsdocRule emits Error: Unexpected tag kind #3413

Closed
emilio-martinez opened this issue Oct 29, 2017 · 1 comment · Fixed by #3414
Closed

noRedundantJsdocRule emits Error: Unexpected tag kind #3413

emilio-martinez opened this issue Oct 29, 2017 · 1 comment · Fixed by #3414

Comments

@emilio-martinez
Copy link

Bug Report

  • TSLint version: 5.8.0
  • TypeScript version: 2.5.3
  • Running TSLint via: CLI

TypeScript code being linted

/**
 * This is my class
 * @class This is a `class` test
 */
export class MyClass {}

with tslint.json configuration:

{
  "defaultSeverity": "error",
  "rules": {
    "no-redundant-jsdoc": true
  }
}

Actual behavior

Error: Unexpected tag kind: JSDocClassTag
    at checkTag (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:99:23)
    at cb (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:62:25)
    at Array.forEach (native)
    at walk (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:55:34)
    at Rule.AbstractRule.applyWithFunction (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/language/rule/abstractRule.js:39:9)
    at Rule.apply (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:35:21)
    at Linter.applyRule (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/linter.js:177:29)
    at /Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/linter.js:119:85
    at Object.flatMap (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/utils.js:151:29)
    at Linter.getAllFailures (/Users/emilio.martinez/Documents/emilio/is-datatype/node_modules/tslint/lib/linter.js:119:32)

Expected behavior

It seems like in the source code for noRedundantJsdocRule there's a non-exhaustive switch statement. JSDocClassTag may not be the only missing case, but that's the one I happened to stumble onto. See https://github.com/palantir/tslint/blob/master/src/rules/noRedundantJsdocRule.ts#L100

@emilio-martinez
Copy link
Author

Did a quick test to see what multiple JSDoc tags map to in the SyntaxKind enum. I included more than what is in the rule's Set, so not all of these may apply, but it might be helpful just for the record.

A fairly large amount of these result in a FirstJSDocTagNode kind, which is odd. All of the tags below were applied in the same JSDoc comment. I think FirstJSDocTagNode may be what is being returned for an unresolved kind, regardless of whether it's the first or not.

{ text: 'abstract', kind: 'FirstJSDocTagNode' }
{ text: 'access', kind: 'FirstJSDocTagNode' }
{ text: 'augments', kind: 'JSDocAugmentsTag' }
{ text: 'class', kind: 'JSDocClassTag' }
{ text: 'const', kind: 'FirstJSDocTagNode' }
{ text: 'constant', kind: 'FirstJSDocTagNode' }
{ text: 'constructor', kind: 'JSDocClassTag' }
{ text: 'constructs', kind: 'FirstJSDocTagNode' }
{ text: 'default', kind: 'FirstJSDocTagNode' }
{ text: 'enum', kind: 'FirstJSDocTagNode' }
{ text: 'export', kind: 'FirstJSDocTagNode' }
{ text: 'exports', kind: 'FirstJSDocTagNode' }
{ text: 'extends', kind: 'FirstJSDocTagNode' }
{ text: 'function', kind: 'FirstJSDocTagNode' }
{ text: 'global', kind: 'FirstJSDocTagNode' }
{ text: 'implements', kind: 'FirstJSDocTagNode' }
{ text: 'instance', kind: 'FirstJSDocTagNode' }
{ text: 'interface', kind: 'FirstJSDocTagNode' }
{ text: 'lends', kind: 'FirstJSDocTagNode' }
{ text: 'member', kind: 'FirstJSDocTagNode' }
{ text: 'memberof', kind: 'FirstJSDocTagNode' }
{ text: 'mixes', kind: 'FirstJSDocTagNode' }
{ text: 'mixin', kind: 'FirstJSDocTagNode' }
{ text: 'module', kind: 'FirstJSDocTagNode' }
{ text: 'name', kind: 'FirstJSDocTagNode' }
{ text: 'namespace', kind: 'FirstJSDocTagNode' }
{ text: 'override', kind: 'FirstJSDocTagNode' }
{ text: 'param', kind: 'JSDocParameterTag' }
{ text: 'private', kind: 'FirstJSDocTagNode' }
{ text: 'property', kind: 'FirstJSDocTagNode' }
{ text: 'protected', kind: 'FirstJSDocTagNode' }
{ text: 'public', kind: 'FirstJSDocTagNode' }
{ text: 'readonly', kind: 'FirstJSDocTagNode' }
{ text: 'record', kind: 'FirstJSDocTagNode' }
{ text: 'requires', kind: 'FirstJSDocTagNode' }
{ text: 'return', kind: 'JSDocReturnTag' }
{ text: 'returns', kind: 'JSDocReturnTag' }
{ text: 'static', kind: 'FirstJSDocTagNode' }
{ text: 'template', kind: 'JSDocTemplateTag' }
{ text: 'this', kind: 'FirstJSDocTagNode' }
{ text: 'type', kind: 'JSDocTypeTag' }
{ text: 'typedef', kind: 'JSDocTypedefTag' }

bugsduggan added a commit to bugsduggan/tslint that referenced this issue May 1, 2019
```
The 'no-redundant-jsdoc' rule threw an error in 'some-file.ts':
Error: Unexpected tag kind: JSDocThisTag
```

This appears to be similar to palantir#3413
bugsduggan added a commit to bugsduggan/tslint that referenced this issue May 7, 2019
```
The 'no-redundant-jsdoc' rule threw an error in 'some-file.ts':
Error: Unexpected tag kind: JSDocThisTag
```

This appears to be similar to palantir#3413
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants