强制开发人员在功能中添加注释

问题描述 投票:1回答:1

我知道这一定是一个简单的问题。但我努力用Google搜索,但找不到合适的结果。我正在管理一个拥有大量人员的大团队。我想确保我的开发人员编写的每个函数都应该在它之前发表评论。在我的tslint文件中添加规则是有意义的。

如何强制我的开发人员在开始功能之前添加注释(如下所示)?

/**
* This function returns a string hello
* @author Sahil Purav
*/
myfunction(): string {
   return 'hello';
}
typescript tslint tsconfig
1个回答
0
投票

我对此进行了更多的研究,发现tslint中有一条规则来强制执行注释和好事,它是高度可配置的。

我使用了满足我要求的以下规则:

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

有关更多信息,请查看 - https://palantir.github.io/tslint/rules/completed-docs/

© www.soinside.com 2019 - 2024. All rights reserved.