
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
code-quality-checker
Advanced tools
一个功能强大的基于Node.js的代码质量检查工具,用于全面扫描、分析和评估JavaScript/TypeScript代码质量,帮助团队保持代码一致性并提高代码可维护性。
Code Quality Checker 是一个一站式代码质量解决方案,它集成了多种代码分析工具和规则,能够快速识别代码中的问题、评估代码质量并提供改进建议。
适合在多个项目中使用或作为独立工具:
npm install -g code-quality-checker
适合集成到特定项目的开发流程中:
npm install --save-dev code-quality-checker
# 检查当前目录
code-checker .
# 检查src目录
code-checker ./src
# 使用项目根目录下的配置文件
code-checker ./src --config ./code-checker.config.js
# 生成详细的HTML报告
code-checker ./src --output html
# 排除node_modules和测试目录
code-checker ./src --exclude node_modules,test
# 启用详细输出模式
code-checker ./src --verbose
Usage: code-checker [options] <directory>
Arguments:
directory 要扫描的目标目录(必填)
Options:
-V, --version 输出版本号
-c, --config <path> 自定义配置文件路径
-o, --output <format> 输出格式(console, json, html),默认值: "console"
-e, --exclude <patterns> 要排除的模式(逗号分隔)
--verbose 显示详细信息
-h, --help 显示帮助信息
创建一个 code-checker.config.js 文件来自定义工具行为,配置示例:
module.exports = {
// 支持的文件扩展名
fileExtensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
// 排除的目录和文件
defaultExcludes: ['node_modules', 'dist', 'build', '.git', 'coverage'],
// ESLint 配置
eslint: {
enable: true,
config: {
rules: {
'no-console': 'warn',
'indent': ['error', 2],
'semi': ['error', 'always'],
'quotes': ['error', 'single'],
'no-unused-vars': 'warn',
'no-trailing-spaces': 'error',
'object-curly-spacing': ['error', 'always']
}
}
},
// 代码复杂度配置
complexity: {
enable: true,
maxCyclomaticComplexity: 10,
maxHalsteadVolume: 100
},
// 质量等级配置
qualityGrades: {
A: { minScore: 90, maxErrors: 0, maxWarnings: 5 },
B: { minScore: 80, maxErrors: 0, maxWarnings: 15 },
C: { minScore: 70, maxErrors: 2, maxWarnings: 25 },
D: { minScore: 60, maxErrors: 5, maxWarnings: 40 },
F: { minScore: 0, maxErrors: Infinity, maxWarnings: Infinity }
},
// Vue特定配置
vue: {
enable: true,
templateRules: {
'no-unescaped': 'error',
'no-v-html': 'warn'
}
},
// 报告配置
report: {
showFileSummary: true,
showDetailedIssues: true,
highlightErrorLines: true
}
};
规则名: 严重程度工具根据多维度指标对代码质量进行综合评分(0-100分),并划分为以下等级:
| 等级 | 描述 | 评分范围 | 错误限制 | 警告限制 |
|---|---|---|---|---|
| A级 | 优秀 | 90-100 | 0 | 最多5个 |
| B级 | 良好 | 80-89 | 0 | 最多15个 |
| C级 | 一般 | 70-79 | 最多2个 | 最多25个 |
| D级 | 较差 | 60-69 | 最多5个 | 最多40个 |
| F级 | 不合格 | 0-59 | 无限制 | 无限制 |
控制台报告提供简洁的质量摘要和问题列表,适合快速检查。
主要包含:
HTML报告是最详细的报告格式,提供交互式的质量分析结果:
主要特点:
将代码质量检查集成到持续集成流程中:
# 示例: GitHub Actions 配置
name: Code Quality
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Install code-checker
run: npm install -g code-quality-checker
- name: Run code quality check
run: code-checker ./src --output html
- name: Upload report
uses: actions/upload-artifact@v2
with:
name: quality-report
path: code-quality-report.html
将代码检查添加到开发工作流中:
// package.json 脚本配置
{
"scripts": {
"lint": "code-checker ./src",
"lint:report": "code-checker ./src --output html",
"precommit": "code-checker ./src --verbose"
}
}
node --max-old-space-size=4096 $(which code-checker) ./src欢迎贡献代码!请按照以下步骤:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)MIT © 2023 Code Quality Checker
如有问题或建议,请在GitHub仓库提交Issue或联系项目维护者。
FAQs
A Node.js code quality checker tool
The npm package code-quality-checker receives a total of 2 weekly downloads. As such, code-quality-checker popularity was classified as not popular.
We found that code-quality-checker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.