• Stars
    star
    790
  • Rank 55,688 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Parse and output TODOs and FIXMEs from comments in your files



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

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|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');

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

More Repositories

1

react-page-visibility

Declarative, nested, stateful, isomorphic page visibility React component
JavaScript
222
star
2

gulp-todo

Generate a TODO.md from todos & fixmes in your code using Gulp stream
JavaScript
90
star
3

spring-boot-webflux-swagger-starter

An example project to illustrate how to document Spring Boot Webflux with Swagger2
Java
63
star
4

gulp-sitemap

Generate a search engine friendly sitemap.xml using a Gulp stream
JavaScript
60
star
5

gulp-colorguard

Keep a watchful eye on your css colors.
JavaScript
37
star
6

gulp-angular-htmlify

Change your HTML ng-attributes to data-ng-attributes for HTML5 validation
JavaScript
33
star
7

awesome-blogs

A curated list of awesome blogs
33
star
8

dotfiles

My dotfiles powered by Dotbot and Fish shell
Shell
29
star
9

grunt-dev-update

Automate the updating of your package.json packages with a grunt task
JavaScript
29
star
10

vim-skeletons

Quickly scaffold template files in your favorite editor using UltiSnips templates
Vim Script
28
star
11

gulp-sort

Sort files in stream by path or any custom sort comparator
JavaScript
22
star
12

grunt-jade-usemin

Grunt plugin for running Usemin on Jade files
JavaScript
21
star
13

angular-html5

Change your ng-attributes to data-ng-attributes for html5 validation
JavaScript
19
star
14

check-constants

Find numbers and strings that should be extracted as a declaration statement
JavaScript
14
star
15

vim-react-proptypes-snippets

Vim React PropTypes Snippets
11
star
16

esformatter-braces

Esformatter plugin for enforcing braces around statements
JavaScript
9
star
17

jtl-parse

Stream decode JMeter JTL files and output them as XML, CSV
Go
8
star
18

grunt-angular-htmlify

Change your ng-attributes to data-ng-attributes for HTML5 validation
JavaScript
7
star
19

neobundle-packages

Neobundle list of packages in json format
Vim Script
6
star
20

find-used-lodash

Use esprima to find and detect used lodash packages
JavaScript
5
star
21

unquoted-property-validator

Unquoted JavaScript property name validator
JavaScript
5
star
22

slush-gulpfile

Quickly generate a pro-like customized gulpfile.js
JavaScript
4
star
23

csp-builder

A builder tool to help generate Content Security Policies in a type-safe way
TypeScript
4
star
24

esformatter-dot-notation

esformatter plugin for transforming object bracket usage to dot notation
JavaScript
4
star
25

sprint-boot-mongodb-starter

A starter kit for Spring Boot with MongoDB Backend
Java
4
star
26

rework-zyndexer

Rework plugin to scale down z-indexes in your stylesheet with ease
JavaScript
4
star
27

java-micro-benchmark-example

A Java micro-benchmark example of Pattern find vs. matches using JMH framework
Java
4
star
28

spring-boot-graphql-mongodb

Spring Boot demo with GraphQL and MongoDB as database
Java
3
star
29

Pirateer

Chrome Extension that adds IMDb ratings to TV shows and movies on The Pirate Bay
Rich Text Format
3
star
30

get-line-from-pos

Get the line number of a string using index or position
JavaScript
3
star
31

eslint-plugin-react-redux

Enforce best practices when using Redux with React
JavaScript
3
star
32

security-keys-ftw

My list of congrats and call-outs for services supporting (or not) security keys
3
star
33

broccoli-ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
JavaScript
3
star
34

ansible-role-zookeeper

Role to install and manage Apache ZooKeeper
3
star
35

package-json-previewer

Web interface to preview your normalized package.json or metadata using normalize-package-data
CoffeeScript
3
star
36

array-scaler

Scale an array preserving order to a discrete or continuous scale
JavaScript
2
star
37

jade-globals

Detect which global variables are needed for your jade templates
JavaScript
2
star
38

ISIS2

Brand new, meaner and tougher ISIS
JavaScript
2
star
39

ansible-role-nvm

An Ansible role to install and setup nvm
2
star
40

esformatter-plugins

Simple client-side app to browse and search esformatter plugins
JavaScript
2
star
41

terraform-docker-swarm

Create EC2 terraform for docker swarm
HCL
2
star
42

www.giladpeleg.com

My personal blog, where I write about technology, development methodologies and general thoughts about life
TypeScript
2
star
43

spring-boot-demo

A guide to understanding Spring Boot WebFlux with Reactive Mongo
Java
2
star
44

grunt-check-constants

Find numbers that should be extracted as a declaration statement
JavaScript
1
star
45

prometheus-nodejs-instrument-demo

A short showcase for manual instrumentation of Node.js backend with Prometheus
JavaScript
1
star
46

derived-property

Create a derived property for an object
JavaScript
1
star
47

awesome-5

curated list of awesome^4 lists
1
star
48

jade-loader2

A sane jade loader module for webpack
JavaScript
1
star
49

fb-calendar

A Facebook calendar exercise
JavaScript
1
star
50

advent-of-code-2017

My solutions to advent of code 2017
Python
1
star
51

babel-plugin-add-regex-unicode

Babel plugin to add regex Unicode flag
JavaScript
1
star
52

ship-tracking

Demonstration of ship tracking
JavaScript
1
star
53

fit-to-range

Fit a number to a given range
JavaScript
1
star
54

rustputin

A sample Rust web server to see the time in Moscow, Russia
CSS
1
star
55

giladpeleg.com

This is my old webpage code, see my new blog code at https://github.com/pgilad/www.giladpeleg.com
CSS
1
star
56

vim-lazy-recipes

Collection of lazy loading recipes using NeoBundle
Vim Script
1
star
57

gulp-check-constants

Find numbers that should be extracted to a declaration statement
JavaScript
1
star