npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-pony-comments

v1.3.2

Published

校验代码注释规范

Downloads

4

Readme

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使用需要有注释