Thanks to visit codestin.com
Credit goes to github.com

Skip to content

前端项目注释率统计(支持国际化), 支持Vue/React/Angular/js等等各种前端、Node项目的代码统计。 -- Neo 2022-11-26

License

Notifications You must be signed in to change notification settings

zeeklog/comment-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨ 注释率统计工具(支持国际化)

  • 前端项目注释率统计(支持国际化)
  • 目前仅支持英语和中文(Only English and Chinese are supported.)
  • 作者/Author: Neo ([email protected])

⚙ 用法 Usage

标准运行 Common Run

// 引入包
const commentCount = require('commentCount');
// 标准运行
commentCount.run();

带参数运行 Run with arg

// 引入包
const commentCount = require('commentCount');
// 带参数运行
const filterList = [
    './node_modules',
];
// 指定统计某些类型的文件
const countType = ['.js', 'ts'];
const config = {
    filterList, countType
}
/**
 * @param dir 需要统计的项目目录, 统计当前目录:./
 * @param config 配置文件
 *  @param config.filterList 需要过滤的文件夹和文件,可以不提供,默认添加了javascript项目常见的过滤目录
 *  @param config.countType 需要统计的文件类型,默认为['.js','.jsx','.ts','.tsx','.vue']
 * @description 默认配置,请看包目录下的./config/config.js
 * @description 支持国际化,请修改包目录下的./lib/i18n.js配置文件
 * **/
commentCount.run('./', config);

📝 默认过滤规则 Default filter rules

  • 当不提供过滤列表时,工具会默认使用以下过滤配置
  • 过滤了大部分的业务无关的文件
filterList = [
    './node_modules',
    './.vscode',
    './.idea',
    './husky',
    './.git',
    './.tscache',
    './.eslintrc.js',
    './.stylelintrc.js',
    './jest.config.js',
]

配置npm run count

  • 在package.json中添加scripts
{
    // ......
    scripts: {
        // 配置执行的脚本
        // 案例为: 统计当前目录下:./ 的所有.js .ts文件, 第一个参数为路径, 其余参数为文件类型 , 使用空格间隔
        "count": "node ./node_modules/commentcount/index.js ./ .js .ts"
    }
    // ......
}
  • 添加上述配置后,执行:
npm run count
  • 结果:Result

https://github.com/ethwillupto10000/comment-counter/blob/master/example.png

Base on MIT, Feel free to use anywhere you want.

Apperiate if you mention the origin link when using it.

About

前端项目注释率统计(支持国际化), 支持Vue/React/Angular/js等等各种前端、Node项目的代码统计。 -- Neo 2022-11-26

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published