Sahil Purav
Sahil Purav

Reputation: 1354

Force Developers to add comments in function

I know it must be a simple question. But I tried hard googling around this but couldn't find a single suitable result. I'm managing a big team with large number of people working under me. I want to make sure that, every single function written by my developers should have a comment before it. It makes sense to add the rule in my tslint file.

How do I enforce my developers to add comment before function begins (like below)?

/**
* This function returns a string hello
* @author Sahil Purav
*/
myfunction(): string {
   return 'hello';
}

Upvotes: 2

Views: 895

Answers (1)

Sahil Purav
Sahil Purav

Reputation: 1354

I did some more research on this and found that, there is a rule in tslint to enforce comments and good thing, it is highly configurable.

I used following rule which suffice my requirement:

"completed-docs": [
      true,
      {
        "enums": true,
        "functions": {
          "visibilities": ["exported"]
        },
        "methods": {
          "location": "instance",
          "privacies": ["public", "protected"]
        }
      }
    ]

For more information check this - https://palantir.github.io/tslint/rules/completed-docs/

Upvotes: 1

Related Questions