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 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-better-codes

v1.4.15

Published

eslint代码规范校验自定义插件合集,提升代码质量

Readme

eslint-plugin-better-codes

简体中文

简介

eslint-plugin-better-codes 是一组自定义的 ESLint 插件规则集合,其中包含用于检测并禁止被注释掉的代码的规则 eslint-no-commented-code。帮助团队保持代码库清洁,避免大量被注释的冗余代码。

安装

使用 npm:

npm install --save-dev eslint-plugin-better-codes

或使用 yarn:

yarn add -D eslint-plugin-better-codes

使用方式

在你的 ESLint 配置文件中启用插件并打开规则。例如 .eslintrc.js

module.exports = {
  plugins: ["better-codes"],
  rules: {
    "better-codes/no-commented-code": "error",
  },
};

规则名:no-commented-code(导出于 index.js 中)。

主要功能

no-commented-code

禁止提交注释掉的代码:

  • 对于单行注释:累计行数大于等于minLines时报错。对于第一个字符为中文、大写英文字母、数字,不进行校验。如果最后面包含ignore-eslint,不进行校验(最多可以忽略minLines - 1次)
  • 对于多行注释:单块累计行数或者累计块数大于等于minLines时报错,空格行、只包含*的行、空行不计数。如果内容包含@param、@returns(函数注释),@D(d)escription(文件头注释),@C(c)omment(块状功能注释)不进行校验,注释的内容如果以中文、数字、大写英文字母开头,不进行校验

function-with-try-catch

强制函数必须包含 try-catch 语句块

  • 普通函数
  • 箭头函数
  • 方法函数

不校验的情况:

  • React组件函数
  • 函数体只有一行代码的函数。例如const exportData = async () => await service.exportData(selectList)
  • 函数体只有一条执行语句的函数。例如
    const handleDelete = ({ id }) => {
      Modal.confirm({
        title: "确认删除该条数据?",
        onOk: async () => service.deleteData(id),
      });
    };
  • 用于map/forEach中返回元素/组件用于渲染的箭头函数
  • 嵌套函数内的子函数,,如果父函数已经包含try-catch,则子函数不进行校验

long-expression-with-optional-chain

强制使用可选链操作符(?.)来约束长表达式的点访问

针对赋值表达式 = 左半部分的表达式不会进行校验,将来进行针对性处理

针对new语句中的表达式不会进行校验,将来进行针对性处理

更新日志

功能新增

功能调整

1.4.14

取消long-expression-with-optional-chain规则中对于例如new echarts.graphic.LinearGradient().LinearGradient()的校验

Bug修复

1.4.12

修复long-expression-with-optional-chain规则中对于例如obj.user.getName().num中的getName().num不会进行校验的情况

许可证

MIT