0.0.1 • Published 3 years ago

del-dead-code v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

废弃代码删除工具dead-code

描述:这是一个删除废弃代码命令行工具

技术栈:ts-unused-exports + eslint-plugin + fixer + commander

相关依赖说明:

  • fork-ts-unused-exports:用于检测未使用的exports
  • eslint-plugin-deadvars:配合fork-ts-unused-exports检测出未使用的变量
  • eslint-plugin-autofix-fork:通过eslint的fixer,修复问题

使用:

  • 命令dead-codedc会根据当前目录的tsconfig.json文件中的include字段,检测出后缀为.js, .jsx, .ts, .tsx文件中未使用的exports,包括变量、函数、函数形参、import、type、interface、enum,以及项目中未使用的文件(仅支持.js, .jsx, .ts, .tsx文件)
命令描述默认值
dc --f 或 dc --fix是否自动修复检测问题false
dc -p path 或 dc --path pathtsconfig的路径当前工作目录 + tsconfig.json
dc --d 或 dc --del是否删除所有未使用的文件false
dc --ded 或 dc --delEmptyDirectory是否删除因删除未使用的文件产生的空文件夹false

也可以使用dc --help命令查看可传入的参数

除此之外,还可传入ts-unused-exports支持的参数,具体可查看文档

传入ts-unused-exports的默认参数:

  • excludeDeclarationFiles: true
  • ignoreFiles: (\\.(test|spec)\\.[tj]s$)|(\\.md$)|(\\.d\\.ts$)\