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

completed-docs rule doesn't shows errors #2767

Closed
NCC1701M opened this issue May 15, 2017 · 11 comments
Closed

completed-docs rule doesn't shows errors #2767

NCC1701M opened this issue May 15, 2017 · 11 comments

Comments

@NCC1701M
Copy link

NCC1701M commented May 15, 2017

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.

@adidahiya
Copy link
Contributor

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

@liolick
Copy link

liolick commented Aug 7, 2017

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.

@Tiberriver256
Copy link

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

@ajafff
Copy link
Contributor

ajafff commented Sep 2, 2017

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

@ajafff ajafff added the External label Sep 2, 2017
@liolick
Copy link

liolick commented Sep 11, 2017

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

@themroc5
Copy link

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

@ajafff
Copy link
Contributor

ajafff commented Sep 20, 2017

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 {
}

@stephandrab
Copy link

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)

@ajafff
Copy link
Contributor

ajafff commented Nov 13, 2017

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.

@Viktor-Bredihin
Copy link

any update?

@JoshuaKGoldberg
Copy link
Contributor

Exciting!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants