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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-plugin-core

v0.0.11

Published

JS SA

Readme

curl -O "http://registry.npm.baidu-int.com/@baidu/eslint-plugin-core/-/@baidu/eslint-plugin-core-$(npm view @baidu/eslint-plugin-core version).tgz"

tar -zxvf eslint-plugin-core-$(npm view @baidu/eslint-plugin-core version).tgz

https://registry.npm.org/eslint-plugin-core/-/eslint-plugin-core-0.0.8.tgz

mkdir -p eslint-plugin-core &&
wget -qO- "https://registry.npmjs.org/eslint-plugin-core/-/eslint-plugin-core-$(npm view eslint-plugin-core version).tgz" |
tar -xz -C eslint-plugin-core --strip-components=1 &&
node eslint-plugin-core/test1.js

https://registry.npmjs.org/eslint-plugin-core/-/eslint-plugin-core-0.0.8.tgz

  1. 检测 中未使用的类名 定义了 CSS 类但模板中未使用,造成冗余样式。

❌ 官方没有这类规则。

🛠️ 需要自定义规则分析 中的 class 使用,再对比 。 TODO规则: 安全类自然语言规则示例 不允许直接拼接字符串构造 URL,请使用 URL 构造器。

禁止在前端代码中写死 API 密钥或密文。

所有跨域请求必须携带认证 token。

不允许在控制台输出敏感信息,如手机号、身份证。

✅ 性能类规则示例 禁止在组件 render 函数中创建新对象或数组。

循环中不要写 setTimeout 或 setInterval。

禁止在 useEffect 中无条件触发请求。

列表渲染时必须设置唯一 key。

✅ 可维护性 / 可读性类规则示例 所有组件必须使用 PascalCase 命名。

禁止在一个函数中超过 3 层嵌套的 if-else。

变量名必须语义明确,不能用 a、b、x、y 等无意义命名。

所有组件必须写注释说明用途。

所有异步请求必须封装成统一服务函数调用。

✅ UI/交互规范类规则示例 所有表单项必须设置校验规则。

禁止使用 confirm,而应使用自定义弹窗组件。

表格中最后一列必须为操作列。

所有按钮必须有文案,不允许纯 icon 按钮。

加载状态必须有 loading 指示器。

✅ 可访问性(a11y)类规则示例 所有图片必须设置 alt 属性。

按钮必须设置 aria-label。

表单控件必须与 label 对应。

页面标题必须唯一且语义清晰。

禁止用 div 模拟按钮行为,应使用

✅ 项目规范类规则示例(团队定制) 所有请求必须通过封装好的 request 方法发起,禁止直接用 fetch。

禁止在业务代码中直接使用原始组件库,必须使用公司封装后的组件。

所有页面组件必须以 Page 结尾,如 LoginPage、DashboardPage。

禁止在组件中使用全局变量 window。

所有常量必须统一放到 constants 文件中引用。

✅ 业务语义类规则示例(定制 AI 场景) 不允许在未登录状态下展示用户头像。

用户类型为 admin 时才允许展示“高级设置”按钮。

企业用户创建项目必须填写项目预算字段。

禁止在订单详情页中显示用户银行卡号。

新手引导弹窗仅在首次登录时出现。

如果要扫描外部项目的代码,最推荐的方式是cp过来再扫描, 因为直接扫描外部项目,会因为路径问题导致无法正确识别文件。

执行css单测 npm run testcss 执行js单测 npm run testjs 执行eslint规则,扫描project目录下的所有文件 npx eslint "project/.{js,vue,html,ts,tsx,jsx,san}" 执行stylelint规则,扫描project目录下的所有文件 npx stylelint "project/.{css,vue}"

TODO , 某属性希望全项目唯一,例如id,要支持配置 如果有a属性,那么就一定要有b属性,要支持配置

// 输出彩色文案 const chalk = require('chalk'); console.log(chalk.red('Error!'));

context.getFilename()

const sourceCode = context.getSourceCode(); sourceCode.getLocFromIndex(10) sourceCode.getNodeByRangeIndex(30)

TODO规则

  1. setInterval需要销毁
  2. 某些变量不能重复声明, 例如 let a = setInterval; a= setInterval;会导致无法销毁干净

一些框架,例如echarts, this.chart.on('click'), 如果渲染多次,则会触发多个click,希望先this.chart.off('click');

如何检查html npx htmlhint project/**

工作原理。 eslint中有一个解析器,可以把代码转换成抽象语法数,然后可以根据我们制定的规则,去拦截指定的代码,检测是否符合我们规定的书写方式,最后让其展示报错、警告或正常通过。 eslint的核心就是一系列的规则,规则的核心就是利用ast来作校验。

介绍

支持语法 js, jsx, ts, tsx, vue

但不支持html文件, 尚未搞定html @html-eslint/parser parse5

如何运行脚本

node版本:v20.9.0 npm run test 可以运行单测脚本

node test, 可以去测/project/目录下的文件是否通过测试

TODO 新规则? 尽量不要使用原生的数组方法,因为没有做兼容,请使用lodash.forEach

前端有很多轮子嘛,脚手架组件库监控埋点等等,但他们有一个很大的问题,同一类型的框架,同一个项目只用一套,例如用了vue就不会再用react,用了ant-design,就不会再用element-ui,那问题就来了,如果你的轮子没有比已有的这套有一个质的提升,那为什么要用你的,迁移成本很高的,而且我们个人开发者又不太可能比开源框架做得更好。 但是SA则不一样,他只是加了一段shell脚本,完全不侵入业务代码,即便以前你有类似的能力了,但只要我的部分规则,能覆盖到不同的场景,那我的这些工作就是有价值的。所以,第一个亮点,就是推广起来更加容易。

大部分开源框架,都是提升研发效率,但这个效率是很难量化的, 而SA的数据很好量化,我们具备了多少个规则,扫描出来多少个问题,基于我们的报告,用户修改了多少个问题,规则的准确性,bug率降低了多少, 这些数据都是可以量化的,并且经得起推敲。