Tslint: completed-docs should have an option to check every method/function overload

Created on 28 Dec 2018  路  7Comments  路  Source: palantir/tslint

Feature request for completed-docs rule

Is it possible to enforce (add option if does not exist) jsDoc comment for function/method overloading?

Requires Type Checker Needs Investigation Rule Enhancement

Most helpful comment

Thumbs up for configurable. Suggestion:

"overloads": false

All 7 comments

@SerhiiBilyk sorry, what do you mean by "overloading"? Could you post a code snippet or two?

@JoshuaKGoldberg

class Foo {

    /*
     * Enforce jsDoc comment here
     */
    emit(event: string, data: number) => void;

    /*
     * Enforce jsDoc comment  here
     */
    emit(event:string, data: string) => void;

    emit(event:string, data:any) {
        // ....... some code
    }
}

this is not currently possible but seems like a reasonable request. currently TSLint will report 3 failures here but adding a jsdoc comment to any overload will make them go away:

  class Foo {
      emit(event: string, data: number): void;
-     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
      emit(event: string, data: string): void;
-     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
      emit(event: string, data: string | number) {
-     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.]
          // ....... some code
      }
  }

Did you do something on this? Because since my update from 5.12.x to 5.13.0 today, i get new reports for exactly that and I definitly do not want to write a separate comment for each overload ;-) If so: is there a not yet documented option to turn this back to "one documentation for all overloads required"?

hmm, that could have happened as a result of #3557. @JoshuaKGoldberg could you take a look?

Yes, the behavior is now to require one on all overloads.

{
  "rules": {
    "completed-docs": [
      true,
      {
        "methods": true
      }
    ]
  }
}
class Foo {
    // completed-docs: Documentation must exist for methods
    emit(event: string, data: number): void;

    // completed-docs: Documentation must exist for methods
    emit(event:string, data: string): void;

    /**
     * Exists in one place
     */
    emit(event:string, data:any) {
        // ....... some code
    }
}

I'll look at making this an opt-in behavior...

Thumbs up for configurable. Suggestion:

"overloads": false
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

DanielKucal picture DanielKucal  路  3Comments

CSchulz picture CSchulz  路  3Comments

jacob-robertson picture jacob-robertson  路  3Comments

SwintDC picture SwintDC  路  3Comments