leasot
Parse and output TODOs and FIXMEs from comments in your files
Last updated a month ago by pgilad .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install leasot 
SYNC missed versions from official npm registry.



Leasot


Leasot

Intelligently parse and output TODOs and FIXMEs from comments in your files

npm npm downloads Travis (.org) code style: prettier

Easily extract, collect and report TODOs and FIXMEs in your code. This project uses regex in order to extract your todos from comments.

Basic output example of leasot

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 something is not supported).
  • Can be prefixed with a @ (i.e @TODO).
  • Spaces are trimmed around comment text.
  • Supported default types are TODO and FIXME - case insensitive.
  • Additional types can be added (using tags in cli and customTags in leasot.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

Filetype Extension Notes Parser Name
C# .cs Supports // and /* */ comments. defaultParser
C++/C .cpp .c .h Supports // and /* */ comments. defaultParser
Coffee-React .cjsx Supports # comments. coffeeParser
Coffeescript .coffee Supports # comments. coffeeParser
Crystal .cr Supports # comments. coffeeParser
CSon .cson Supports # comments. coffeeParser
CSS .css Supports /* */ comments. defaultParser
EJS .ejs Supports <!-- --> and <%# %> ejsParser
Erb .erb Supports <!-- --> and <%# %> ejsParser
Erlang .erl .hrl Supports % comments. erlangParser
Go .go Supports // and /* */ comments. defaultParser
Haml .haml Supports / -# <!-- --> and <%# %> twigParser
Handlebars .hbs .handlebars Supports {{! }} and {{!-- --}} hbsParser
Haskell .hs Supports -- haskellParser
Hogan .hgn .hogan Supports {{! }} and {{!-- --}} hbsParser
HTML .html .htm Supports <!-- --> twigParser
Jade .jade .pug Supports // and //- comments. jadeParser
Java .java Supports // and /* */ comments defaultParser
Javascript .js .es .es6 Supports // and /* */ comments defaultParser
Jsx .jsx Supports // and /* */ comments. defaultParser
Kotlin .kt Supports // and /* */ comments. defaultParser
Latex .tex Supports \begin{comment} and % comments latexParser
Less .less Supports // and /* */ comments. defaultParser
Markdown .markdown, .md Supports <!-- --> twigParser
Mustache .mustache Supports {{! }} and {{!-- --}} hbsParser
Nunjucks .njk Supports {# #} and <!-- --> twigParser
Objective-C .m Supports // and /* */ comments defaultParser
Objective-C++ .mm Supports // and /* */ comments defaultParser
Pascal .pas Supports // and { } comments. pascalParser
Perl .pl, .pm Supports # comments. coffeeParser
PHP .php Supports // and /* */ comments. defaultParser
Protocol Buffer .proto Supports // and /* */ comments. defaultParser
Python .py Supports """ and # comments. pythonParser
Ruby .rb Supports # comments. coffeeParser
Rust .rs Supports // and /* */ comments. defaultParser
Sass .sass .scss Supports // and /* */ comments. defaultParser
Scala .scala Supports // and /* */ comments. defaultParser
Shell .sh .zsh .bash Supports # comments. coffeeParser
SilverStripe .ss Supports <%-- --%> comments. ssParser
SQL .sql Supports -- and /* */ comments defaultParser & haskellParser
Stylus .styl Supports // and /* */ comments. defaultParser
Swift .swift Supports // and /* */ comments. defaultParser
Svelte .svelte Supports // /* */ <!-- --> comments. twigParser
Twig .twig Supports {# #} and <!-- --> twigParser
Typescript .ts, .tsx Supports // and /* */ comments. defaultParser
Vue .vue Supports // /* */ <!-- --> comments. twigParser
Yaml .yaml .yml Supports # comments. coffeeParser

Javascript is the default parser. PRs for additional filetypes 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|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(content, { extension: filetype, filename: file });

// -> todos now contains the array of todos/fixme parsed

const output = leasot.reporter(todos, 'json', { spacing: 2 });

console.log(output);
// -> json output of the todos

Leasot with build tools

API

const leasot = require('leasot');

See main exported functions

Mainly, you should be using 2 functions:

  • parse for parsing file contents
  • report for reporting the todos

Type documentation

Built-in Reporters

See built-in reporters

License

MIT © Gilad Peleg

Current Tags

  • 8.2.0                                ...           latest (a month ago)

93 Versions

  • 8.2.0                                ...           a month ago
  • 8.1.0                                ...           a month ago
  • 8.0.0                                ...           3 months ago
  • 7.5.0                                ...           4 months ago
  • 7.4.0                                ...           4 months ago
  • 7.3.4                                ...           8 months ago
  • 7.3.3                                ...           8 months ago
  • 7.3.2                                ...           8 months ago
  • 7.3.1                                ...           8 months ago
  • 7.3.0                                ...           8 months ago
  • 7.2.0                                ...           9 months ago
  • 7.1.0                                ...           9 months ago
  • 7.0.0                                ...           9 months ago
  • 7.0.0-rc.7                                ...           10 months ago
  • 7.0.0-rc.6                                ...           10 months ago
  • 7.0.0-rc.5                                ...           a year ago
  • 7.0.0-rc.4 [deprecated]           ...           a year ago
  • 7.0.0-rc.3                                ...           a year ago
  • 7.0.0-rc.2                                ...           a year ago
  • 7.0.0-rc.1                                ...           a year ago
  • 7.0.0-rc.0                                ...           a year ago
  • 6.6.2                                ...           a year ago
  • 6.6.1                                ...           a year ago
  • 6.6.0                                ...           a year ago
  • 6.5.0                                ...           a year ago
  • 6.3.0                                ...           a year ago
  • 6.2.1                                ...           a year ago
  • 6.2.0                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.13.0                                ...           2 years ago
  • 4.12.0                                ...           2 years ago
  • 4.11.0                                ...           2 years ago
  • 4.10.2                                ...           2 years ago
  • 4.10.1                                ...           2 years ago
  • 4.10.0                                ...           2 years ago
  • 4.9.0                                ...           2 years ago
  • 4.8.0                                ...           2 years ago
  • 4.7.1                                ...           2 years ago
  • 4.7.0                                ...           2 years ago
  • 4.6.0                                ...           2 years ago
  • 4.5.0                                ...           2 years ago
  • 4.4.0                                ...           2 years ago
  • 4.3.1                                ...           3 years ago
  • 4.3.0                                ...           3 years ago
  • 4.2.1                                ...           3 years ago
  • 4.2.0                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 3.2.2                                ...           4 years ago
  • 3.2.1                                ...           4 years ago
  • 3.2.0                                ...           4 years ago
  • 3.1.2                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.6.0                                ...           4 years ago
  • 2.5.0                                ...           4 years ago
  • 2.4.0                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.2.3                                ...           4 years ago
  • 2.2.2                                ...           4 years ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.4                                ...           4 years ago
  • 2.1.3                                ...           4 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.4                                ...           4 years ago
  • 2.0.3                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0 [deprecated]           ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 2
This Week 130
This Month 132
Last Day 0
Last Week 2
Last Month 268
Dependencies (11)
Dev Dependencies (16)

Copyright 2014 - 2016 © taobao.org |