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

@chiriwu-wjx/code-quality-plugin

v1.0.1

Published

Webpack plugin for code quality analysis and reporting

Downloads

9

Readme

Code Quality Plugin

一个用于 Webpack 的代码质量分析插件,可以检测代码质量问题、计算复杂度指标并生成详细的质量报告。

功能特性

  • 🔍 代码质量分析
  • 📊 圈复杂度计算
  • 📈 可维护性指数
  • 📋 Halstead 复杂度指标
  • 🚨 问题检测和报告
  • 📄 JSON 格式报告输出
  • 🎨 彩色控制台输出
  • ⚙️ 可配置的规则和阈值

检测规则

  • 行长度检查: 检测超过 120 字符的行
  • 圈复杂度检查: 检测过高的圈复杂度
  • 未使用变量: 检测声明但未使用的变量
  • 魔法数字: 检测代码中的魔法数字
  • 可维护性指数: 计算代码的可维护性
  • Halstead 体积: 计算代码的 Halstead 复杂度

安装

npm install @chiriwu-wjx/code-quality-plugin --save-dev

使用方法

基本用法

// webpack.config.js
const CodeQualityPlugin = require("@chiriwu-wjx/code-quality-plugin");

module.exports = {
  // ... 其他配置
  plugins: [new CodeQualityPlugin()]
};

带配置的用法

// webpack.config.js
const CodeQualityPlugin = require("@chiriwu-wjx/code-quality-plugin");

module.exports = {
  // ... 其他配置
  plugins: [
    new CodeQualityPlugin({
      outputPath: "./reports/code-quality.json",
      failOnError: true,
      failOnWarning: false,
      verbose: true,
      includePatterns: ["**/*.{js,ts,jsx,tsx}"],
      excludePatterns: ["**/node_modules/**", "**/dist/**"],
      maxComplexity: 8,
      maxMaintainabilityIndex: 70
    })
  ]
};

配置选项

| 选项 | 类型 | 默认值 | 描述 | | ------------------------- | ---------- | ----------------------------------------------------- | ---------------------- | | outputPath | string | ./code-quality-report.json | 报告输出路径 | | failOnError | boolean | false | 发现错误时是否终止构建 | | failOnWarning | boolean | false | 发现警告时是否终止构建 | | verbose | boolean | true | 是否显示详细输出 | | includePatterns | string[] | ['**/*.{js,ts,jsx,tsx}'] | 包含的文件模式 | | excludePatterns | string[] | ['**/node_modules/**', '**/dist/**', '**/build/**'] | 排除的文件模式 | | maxComplexity | number | 10 | 最大圈复杂度 | | maxMaintainabilityIndex | number | 65 | 最小可维护性指数 |

输出示例

控制台输出

🔍 Code Quality Analysis Report
============================================================
📁 Files Analyzed: 15
📄 Total Lines: 1250
🔄 Cyclomatic Complexity: 45
📊 Maintainability Index: 78.5
📈 Halstead Volume: 234.7

🚨 Issues Summary:
  Errors: 2
  Warnings: 8
  Info: 12

📋 Detailed Issues:
  ERROR src/components/ComplexComponent.js:1:1 - Cyclomatic complexity (15) exceeds maximum (10)
  WARNING src/utils/helper.js:45:1 - Line is too long (max 120 characters)
  INFO src/constants.js:12:1 - Magic number detected: 1000
============================================================

JSON 报告格式

{
  "timestamp": "2024-01-15T10:30:00.000Z",
  "metrics": {
    "totalFiles": 15,
    "totalLines": 1250,
    "issues": [...],
    "errorCount": 2,
    "warningCount": 8,
    "infoCount": 12,
    "maintainabilityIndex": 78.5,
    "cyclomaticComplexity": 45,
    "halsteadVolume": 234.7
  },
  "summary": {
    "status": "failed",
    "totalIssues": 22,
    "errorCount": 2,
    "warningCount": 8,
    "infoCount": 12
  }
}

开发

# 安装依赖
pnpm install

# 构建
pnpm build

# 开发模式(监听文件变化)
pnpm dev

# 运行测试
pnpm test

# 代码检查
pnpm lint

许可证

MIT