The error is thrown in each file which contains a jsdoc. Removing the jsdoc clears the error that was thrown.
// Snippet who's existence introduces the error.
/**
*
* @returns {Promise<Object>}
*/
export const handler = async () => { ... }
```ts
// Snippet where no error occurs (But completed-docs correctly gives an error on the lack of jsdoc).
export const handler = async () => { ... }
with `tslint.json` configuration:
```json
"completed-docs": [
true,
{
"variables": {
"visibilities": ["exported"],
"tags": { "existence": [""] }
}
}
]
Full config:
{
"extends": ["tslint:all", "tslint-eslint-rules", "tslint-config-prettier"],
"defaultSeverity": "error",
"jsRules": {
"prefer-for-of": true,
"completed-docs": [
true,
{ "variables": { "visibilities": ["exported"], "tags": { "existence": ["ap"] } } }
],
"valid-jsdoc": [
true,
{
"prefer": {
"return": "returns"
},
"requireReturn": false,
"requireParamDescription": false,
"requireReturnDescription": false
}
],
"no-null-keyword": false,
"comment-format": false,
"object-literal-sort-keys": false,
"ordered-imports": false,
"newline-before-return": false,
"object-literal-shorthand": false,
"no-submodule-imports": false,
"arrow-return-shorthand": false,
"radix": false,
"no-empty": false,
"no-console": false,
"no-import-side-effect": false,
"no-magic-numbers": false,
"curly": false,
"forin": false,
"no-trailing-whitespace": false
}
}
The error is thrown in each file which contains a jsdoc. Removing the jsdoc clears the error that was thrown (but introduces a proper error for a missing jsdoc.) This invalid behavior only occurs when "tags": { "existence": [""] } is present in the config.
The 'completed-docs' rule threw an error in '/home/test/repos/api/src/utils.js':
TypeError: Cannot read property 'param' of undefined
at TagExclusion.excludes (/home/test/repos/api/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js:42:47)
at checkNode (/home/test/repos/api/node_modules/tslint/lib/rules/completedDocsRule.js:306:27)
at cb (/home/test/repos/api/node_modules/tslint/lib/rules/completedDocsRule.js:282:29)
at visitNodes (/home/test/repos/api/node_modules/typescript/lib/typescript.js:15788:30)
at Object.forEachChild (/home/test/repos/api/node_modules/typescript/lib/typescript.js:16016:24)
at walk (/home/test/repos/api/node_modules/tslint/lib/rules/completedDocsRule.js:239:15)
at Rule.AbstractRule.applyWithFunction (/home/test/repos/api/node_modules/tslint/lib/language/rule/abstractRule.js:39:9)
at Rule.applyWithProgram (/home/test/repos/api/node_modules/tslint/lib/rules/completedDocsRule.js:59:21)
at Linter.applyRule (/home/test/repos/api/node_modules/tslint/lib/linter.js:194:29)
at /home/test/repos/api/node_modules/tslint/lib/linter.js:139:85
I would expect for this this configuration to give proper "Documentation must exist..." errors for any exported variable that doesn't have a jsdoc. An empty jsdoc should give no errors (as I am doing validation with a separate rule). Disabling other rules does not change the error.
Correction: "Documentation must exist..." error is still thrown on a completely empty /** ... */, the TypeError occurs once JSDoc rules are added in such as @returns or @param
This _might_ be fixed already by #3557 _(or by one of the completed-docs fixers already merged into master)_... marking this as a bug & accepting PRs in case someone can give a quick little fix not already implemented!
It's still an issue building from master, but I wasn't able to test from that PR.
Awesome, thanks for checking!
Any news about this issue? In my case I have the error when I use @internal in the JSDoc:
The 'completed-docs' rule threw an error in 'C:/LocalData/DEV/WORKSPACE/stark-monorepo-master/packages/stark-ui/src/modules/progress-indicator/entities/progress-indicator-full-config.entity.intf.ts':
TypeError: Cannot read property 'internal' of undefined
at TagExclusion.excludes (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completed-docs\tagExclusion.js:40:47)
at nodeIsExcluded (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completedDocsRule.js:319:29)
at checkNode (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completedDocsRule.js:295:14)
at cb (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completedDocsRule.js:250:17)
at visitNodes (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\typescript\lib\typescript.js:16144:30)
at Object.forEachChild (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\typescript\lib\typescript.js:16372:24)
at walk (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completedDocsRule.js:231:15)
at Rule.AbstractRule.applyWithFunction (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\language\rule\abstractRule.js:39:9)
at Rule.apply (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\rules\completedDocsRule.js:59:21)
at Linter.applyRule (C:\LocalData\DEV\WORKSPACE\stark-monorepo-master\node_modules\tslint\lib\linter.js:214:29)
However the error is thrown only if the @internal is on the JSDoc of an interface... it works fine on classes.
grabbing this @JoshuaKGoldberg
@JoshuaKGoldberg @adidahiya submitted a PR for this. https://github.com/palantir/tslint/pull/4895
I may be failing on Circle because of it says I need to write documentation for test/rules/completed-docs/defaults/edge-case/test.ts.lint
` export const handler = async () => { ... }
Most helpful comment
grabbing this @JoshuaKGoldberg