TODO 必须独占一行注释,行尾跟代码的写法不会被识别;在 CI 中使用需加 -x 参数,否则发现 TODO 会以非零码退出;未知扩展名需用 -A 关联解析器,否则可能被跳过

npm install --global leasot
leasot index.js 硬件要求按 README 说明
README 未说明,纯 Node.js 工具,无需 GPU
从代码注释里提取 TODO 和 FIXME 并生成报告的命令行工具
扫描代码文件里的注释,把 TODO、FIXME 这类待办标记提取出来并整理成清单,方便统一跟踪遗留任务。
核心能力
- 用正则解析注释中的 TODO/FIXME 标记
- 支持 49+ 种语言的注释语法
- 可自定义额外标签如 REVIEW
- 内置 table/json/xml/markdown 等多种报告格式
- 提供 parse 和 report 两个 API 供编程调用
容易踩的坑
内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选共 0 条
还没有人点评。第一个说出真实体验的人最有价值。
Intelligently parse and output TODOs and FIXMEs from comments in your files
Easily extract, collect and report TODOs and FIXMEs in your code. This project uses regex in order to extract your todos from comments.

Comment format
TODO: add some info
- Spaces are optional.
- Colon is optional.
- Must be in a comment (line or block) in its own line (
some code(); //TODO: do somethingis not supported). - Can be prefixed with a @ (i.e. @TODO).
- Spaces are trimmed around comment text.
- Supported default types are
TODOandFIXME- case-insensitive. - Additional types can be added (using
tagsin cli andcustomTagsinleasot.parse) - New extensions can be associated with bundled parsers as many languages have overlapping syntax
- Supports both leading and trailing references. Examples:
// TODO(tregusti): Make this better// TODO: Text /tregusti
Supported languages
49+ languages are supported, pull requests for additional language support is most welcomed!
Usage in command line
npm install --global leasot
Command line help
$ leasot --help
Usage: leasot [options] <file ...>
Parse and output TODOs and FIXMEs from comments in your files
Options:
-V, --version output the version number
-A, --associate-parser [ext,parser] associate unknown extensions with bundled parsers (parser optional / default: defaultParser) (default: {})
-i, --ignore <patterns> add ignore patterns (default: [])
-I, --inline-files parse possible inline files (default: false)
-r, --reporter [reporter] use reporter (table|json|xml|markdown|vscode|gitlab|raw) (default: table) (default: "table")
-S, --skip-unsupported skip unsupported filetypes (default: false)
-t, --filetype [filetype] force the filetype to parse. Useful for streams (default: .js)
-T, --tags <tags> add additional comment types to find (alongside todo & fixme) (default: [])
-x, --exit-nicely exit with exit code 0 even if todos/fixmes are found (default: false)
-h, --help output usage information
Examples:
# Check a specific file
$ leasot index.js
# Check php files with glob
$ leasot '**/*.php'
# Check multiple different filetypes
$ leasot 'app/**/*.js' test.rb
# Use the json reporter
$ leasot --reporter json index.js
# Search for REVIEW comments as well
$ leasot --tags review index.js
# Add ignore pattern to filter matches
$ leasot 'app/**/*.js' --ignore '**/custom.js'
# Search for REVIEW comments as well
$ leasot --tags review index.js
# Check a stream specifying the filetype as coffee
$ cat index.coffee | leasot --filetype .coffee
# Report from leasot parsing and filter todos using `jq`
$ leasot 'tests/**/*.styl' --reporter json | jq 'map(select(.tag == "TODO"))' | leasot-reporter
# Associate a parser for an unknown extension`
$ leasot -A '.svelte,twigParser' -A '.svelte,defaultParser' 'frontend/*.svelte'
Usage in NPM scripts
Use leasot -x in order to prevent exiting with a non-zero exit code. This is a good solution if you plan to
run leasot in a CI tool to generate todos.
{
"scripts": {
"todo": "leasot 'src/**/*.js'",
"todo-ci": "leasot -x --reporter markdown 'src/**/*.js' > TODO.md"
},
"devDependencies": {
"leasot": "^7.0.0"
}
}
Programmatic Installation
npm install --save-dev leasot
Programmatic Examples
const fs = require('fs');
const leasot = require('leasot');
const contents = fs.readFileSync('./contents.js', 'utf8');
// get the filetype of the file, or force a special parser
const filetype = path.extname('./contents.js');
// add file for better reporting
const file = 'contents.js';
const todos = leasot.parse(contents, { extension: filetype, filename: file });
// -> todos now contains the array of todos/fixme parsed
const output = leasot.report(todos, 'json', { spacing: 2 });
console.log(output);
// -> json output of the todos
Leasot with build tools
API
const leasot = require('leasot');
Mainly, you should be using 2 functions:
Built-in Reporters
License
MIT © Gilad Peleg