Tslint: completed-docs rule doesn't shows errors

Created on 15 May 2017  路  11Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.2.0
  • __TypeScript version__: 2.3.2
  • __Running TSLint via__: (pick one) VSCode

TypeScript code being linted

export class MyTest {
    private _myVar: number;

    private test: string[] = [];

    constructor() {
        // TODO:
    }

    public getSomething(): number {
        console.log("Hello World");
        if (this._myVar) {
            return this._myVar;
        }

        return -1;
    }

    public doSth() {
        this.execute(p => console.log(p));
    }

    private execute(cb: (param: string) => void) {
        if (cb) {
            cb("Hallo");
        }
    }
}

with tslint.json configuration:

{
    "defaultSeverity": "error",
    "extends": [
        "tslint:recommended"
    ],
    "jsRules": {},
    "rules": {
        "indent": [
            true,
            "tabs"
        ],
        "eofline": true,
        "no-console": [
            true,
            "debug",
            "error",
            "info"
        ],
        "variable-name": [
            true,
            "check-format",
            "allow-leading-underscore"
        ],
        "array-type": [
            true,
            "array"
        ],
        "arrow-parens": false,
        "class-name": true,
        "completed-docs": [
            true,
            {
                "classes": {
                    "visibilities": "all"
                },
                "enums": {
                    "visibilities": "all"
                },
                "functions": {
                    "visibilities": "all"
                },
                "methods": {
                    "privacies": "all",
                    "locations": "all"
                },
                "properties": {
                    "privacies": "all",
                    "locations": "all"
                }
            }
        ]
    },
    "rulesDirectory": []
}

or

...
        "completed-docs": [
            true,
            "classes",
            "functions",
            "methods",
            "properties"
        ]
...

Actual behavior

It shows no errors or warnings about missing or incomplete documentation.

Expected behavior

It should show errors or warnings about missing or incomplete documentation.

External Duplicate

Most helpful comment

any update?

All 11 comments

I think this is the same as #2701, fixed by #2749

Still unable to get working on TSLint 5.5.0 with rule settings:

    "completed-docs": [
            true,
            {
                "classes":    {"visibilities": ["exported"]},
                "enums":      {"visibilities": ["exported"]},
                "functions":  {"visibilities": ["exported"]},
                "interfaces": {"visibilities": ["exported"]},
                "namespaces": {"visibilities": ["exported"]},
                "types":      {"visibilities": ["exported"]},
                "variables":  {"visibilities": ["exported"]},
                "methods":    {"locations": "all", "privacies": ["public"]},
                "properties": {"locations": "all", "privacies": ["public"]}
            }
        ],

TSlint does not complain on non-documented public methods.
But complains well on exported though.

UPD: We found out that wrapping "locations" value in array does help, i.e.:

"methods":    {"locations": ["all"], "privacies": ["public"]},
"properties": {"locations": ["all"], "privacies": ["public"]}

work as expected.

I'm having the same issue. Running tslint -p . shows the appropriate errors but vscode does not.

This rule requires the type information. That's currently not possible with vscode-tslint. Therefore this rule is simply ignored.
You can give the experimental next version of vscode-tslint a try: https://marketplace.visualstudio.com/items?itemName=eg2.ts-tslint

@adidahiya, looks like it is not duplicate, 'cos not fixed by #2749

I run into the same issue. Tslint via CLI reports the missing documentation properly. However, PhpStorm ignores that particular error and reports nothing.

To solve this problem the rule could be refactored to no longer use the type checker.
Getting the JSDoc is fairly easy, I already did that in deprecation-rule. The tricky part is finding all merged declarations and collect all JSDoc comments from them.

/**
 * Complete documenation
 */
interface Foo {
}

// this one has no documentation, but since it's merged with the interface above, the rule should not fail on it
class Foo {
}

I'm having the same issue with IntelliJ: The CLI reports all issues, IntelliJ reports all, but documentation issues, maybe more... (Win10, JDK 1.8.0_152, IntelliJ 2017.2.5, IntelliJ tslint plugin 172.4343.14, node 6.9.4, tslint 5.7.0)

This issue could be fixed, but the behavior of the rule would differ in certain cases.
Please see #3376 and leave a comment over there so we get some feedback whether this change is accepted by the community.

any update?

Exciting!

Was this page helpful?
0 / 5 - 0 ratings