Tslint: New completed-docs "tags" property doesn't work with single-line doc comments

Created on 21 Oct 2017  路  6Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.8.0
  • __TypeScript version__: 2.5.3
  • __Running TSLint via__: CLI

TypeScript code being linted

...
/** @see Class */
export const balls: string = 'balls';
...
    /** @inheritDoc */
    public async doSomething () : Promise<string> {
        return balls;
    }
...

with tslint.json configuration:

...
"completed-docs": [true, {
    "classes": {"visibilities": ["exported"]},
    "enums": {"visibilities": ["exported"]},
    "functions": {"visibilities": ["exported"]},
    "interfaces": {"visibilities": ["exported"]},
    "methods": {"privacies": ["protected", "public"]},
    "namespaces": {"visibilities": ["exported"]},
    "properties": {"privacies": ["protected", "public"]},
    "types": {"visibilities": ["exported"]},
    "variables": {"visibilities": ["exported"]},
    "tags": {
        "content": {"see": [".*"]},
        "exists": ["inheritDoc"]
    }
}],
...

(Also tested with tags copied and pasted as a nested property of all of its sibling properties.)

Actual behavior

...
ERROR: /path/to/file.ts[12, 14]: Documentation must exist for exported variables.
ERROR: /path/to/file.ts[43, 2]: Documentation must exist for public,async methods.
...

Expected behavior

No errors.

Documentation Fixed Accepting PRs Bug

All 6 comments

Can you try without the curly braces:

"content": {"see": ".*"},

Looks like an issue with the docs and examples

(Also tested with tags copied and pasted as a nested property of all of its sibling properties.)

That seems to be the way it works. At least that's how it's done in the tests.

Thanks for the quick reply! Just tested with the two configurations below and reproduced the same result:

...
"completed-docs": [true, {
    "classes": {"visibilities": ["exported"]},
    "enums": {"visibilities": ["exported"]},
    "functions": {"visibilities": ["exported"]},
    "interfaces": {"visibilities": ["exported"]},
    "methods": {"privacies": ["protected", "public"]},
    "namespaces": {"visibilities": ["exported"]},
    "properties": {"privacies": ["protected", "public"]},
    "types": {"visibilities": ["exported"]},
    "variables": {"visibilities": ["exported"]},
    "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}
}],
...
...
"completed-docs": [true, {
    "classes": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "enums": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "functions": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "interfaces": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "methods": {"privacies": ["protected", "public"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "namespaces": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "properties": {"privacies": ["protected", "public"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "types": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}},
    "variables": {"visibilities": ["exported"], "tags": {"content": {"see": ".*"}, "exists": ["inheritDoc"]}}
}],
...

Testing the rule revealed that the new tags logic doesn't handle singleline JSDoc.
If you make it multiline, everything should work as expected.

Interesting, thanks! I'll wait for that to be resolved then before re-enabling this rule.

/** {@inheritdoc} */ appears to pass the rule, but I'm not sure it's properly valid.

This was fixed by #3841 while waiting for #3557. 馃帀

Was this page helpful?
0 / 5 - 0 ratings