1.3.2 • Published 2 years ago

eslint-plugin-pony-comments v1.3.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

eslint-plugin-pony-comments

在实际前端项目开发中,开发同学编写代码时写注释的风格不尽一致,并且有些关键代码没有注释,这些都影响着代码的可读性、项目可维护性。虽然团队尽可能地在制定一些公约来要求开发同学去遵守或者引入gerrit代码检视工具,但结果反馈仅依靠人为的方式去避免起到的效果甚微,该插件由此诞生,帮助校验interface、enum、function、type、hooks等关键代码块是否有注释说明。

安装

首先,你需要安装 ESLint:

$ npm i eslint --save-dev

接着,安装 eslint-plugin-pony-comments:

$ npm install eslint-plugin-pony-comments --save-dev

使用

添加pony-comments.eslintrc,你可以省略eslint-plugin-前缀:

{
    "plugins": [
        "pony-comments"
    ]
}

然后在规则部分配置您要使用的规则:

{
    "rules": {
        "pony-comments/no-enum-comments": [2, "always", { "leadingCommentType": "Block", "propertyComments": { "pos": "tail", "commentsType": "Line" } }]
    }
}

该插件有导出默认规则,如果你没有自定义规则的需求,可以在extends字段中添加默认规则:

{
    "extends": ["plugin:pony-comments/recommended"]
}

另外,该插件是基于@typescript-eslint/parser解析器做的,如果eslint服务控制台有报解析有关的错误,请指定该解析器

{
    "parser": "@typescript-eslint/parser"
}

如果在yarn start启动项目时报了很多未更改文件的校验错误,需要在根目录下config-overrides.jsoverride函数中添加config.module.rules.splice(1, 1);

支持的规则

  • ✔️如果规则属于recommended配置
  • 🛠如果规则报告的某些问题可以通过--fix 命令行选项自动修复
  • 💡如果规则报告的某些问题可以通过编辑器建议手动修复
规则✔️🛠💡描述
no-enum-comments✔️🛠定义枚举时需要加上注释
no-function-comments✔️🛠定义函数时需要加上注释
no-interface-comments✔️🛠定义接口类型时需要加上注释
no-type-comments✔️🛠定义类型时需要加上注释
empty-comments🛠不能有空注释
no-jsx-component-comments✔️🛠自定义组件需要有注释
no-hooks-comments✔️🛠hooks使用需要有注释
1.3.2

2 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.8

3 years ago

1.0.9

3 years ago

1.1.7

3 years ago

1.0.8

3 years ago

1.1.6

3 years ago

1.0.7

3 years ago

1.1.5

3 years ago

1.0.6

3 years ago

1.1.4

3 years ago

1.0.5

3 years ago

1.1.3

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago