• Stars
    star
    505
  • Rank 87,373 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

Generate flow coverage reports in JSON, HTML and in the console.

flow-coverage-report

Greenkeeper badge

Build Status

flow-coverage-report is a node command line tool to help projects which are using flow types in their JavaScript code to keep track and visualize the coverage of the flow types checks.

Screenshot flow coverage report summary in the console

Screenshot flow coverage report summary

Screenshot flow coverage report sourcefile

How to generate flow coverage reports for your project

Install the command line tool (globally or as a dev dependency of your project)

$ npm install -g flow-coverage-report

or

$ npm install --save-dev flow-coverage-report

Run the flow reporter (-i configures the include globs, -x the exclude patterns, --threshold to configure a minimum coverage below which the build should fail, which defaults to 80%, and -t the report types enabled):

flow-coverage-report -i 'src/**/*.js' -i 'src/**/*.jsx' -x 'src/test/**' -t html -t json -t text --threshold 90

If the flow executable is not in your PATH, you can specified it using the -f option:

flow-coverage-report -f /path/to/flow ...

To customize the output dir (which defaults to flow-coverage/) you can use the -o option. Though by default the output type is text meaning that it ouputs to the console. Use -o in conjunction with -t to save your desired format:

flow-coverage-report -o my-custom-flow-coverage-dir/

To customize the type you can use -t options:

flow-coverage-report -t html

Load default options from a JSON config file

The --config flag allows specifying a path to a config file. The config file is a JSON file with the following structure:

{
  "concurrentFiles": 1,
  "globExcludePatterns": ["node_modules/**"],
  "flowCommandPath": "path/to/flow/bin",
  "globIncludePatterns": ["src/**/*.js"],
  "outputDir": "path/to/output",
  "projectDir": "path/to/project",
  "threshold": 90,
  "reportTypes": "text"
}

type can be one of "text", "html", or "json". The default is "text".

Load default options from package.json

For an npm package, the default options can also be configured by including them in a "flow-coverage-report" package.json property property:

{
  "name": "my-npm-package",
  "version": "1.0.1",
  "scripts": {
    "flow-coverage": "flow-coverage-report",
    ...
  },
  ...
  "flow-coverage-report": {
    "globIncludePatterns": [
      "src/lib/**/*.js",
      "src/lib/**/*.jsx"
    ],
    "reportTypes": [
      "text",
      "html",
      "json"
    ]
  }
}

Background

As a gradual typing system for JavaScript, flow will help you to statically checks parts of your JavaScript code by:

  • supporting syntaxes to annotate your code with types;
  • supporting syntaxes to declare, export and import new types implicitly and explicitly;
  • inferencing the type of the identifier used in your code as much as possible;

Unfortunately, even with a good amount of powerful inferencing strategies, sometimes flow is not able to inference the types in some chunks of our code.

That's usually the source of a "Meh!" moment, and we blame flow for not being able to catch some issue that we thought it would catch statically.

Fortunately, flow has a coverage command which can give us a quantitative info of the flow types coverage, and optionally a color-based visualization of the parts of the source file that are not covered, for a single file.

How to generate this quantitative info and this very useful visualization of the uncoverage parts of our sources for our entire project?

You have just found it ;-)

Changelog

0.8.0

Fixes:

  • Upgraded production dependencies (#197) (c13aca8):
    • Unpinned all dependencies (fixes #122)
    • Updated babel to v7
    • Updated parse-json to v5
    • Updated react and react-dom to v16
    • Updated strip-json-comments to v3
    • Updated yargs to v16

0.7.0

⚠ BREAKING CHANGES ⚠

  • Dropped support for node.js <= 10

Fixes:

  • npm audit: updated mkdirp dependency to version ^1.0.4 (removes minimist dependency and fixes npm audit failure due to CVE-2020-7598

0.6.2

  • npm audit: updated mkdirp dependency to version ^0.5.5

0.6.1

Fixes:

  • npm audit: changed the badge-up npm dependency to @rpl/badge-up, forked from the original (currently unmantained) package to update its svgo dependency, as it is detected by npm audit as the source of a moderate security vulnerability (#178, See #177 for a rationale).

0.6.0

Bug Fixes:

  • Added support for the new flow annotations (strict and strict-local) (#150, #155)
  • Added warning on deprecated config names and improve cli/config type checks

Features:

  • Added --percent-decimals cli options (#148, #157, #161)
  • Added -exclude-non-flow cli option (#144, #154)

This new release fixes the issues with the new flow annotations (e.g. strict and strict-local) and introduces two new command line options:

  • --exclude-non-flow to automatically ignore any file that match the patterns but do not have any flow annotation
  • --percent-decimals N to include N decimals digits in the coverage percent values

Thanks to Ville Saukkonen and Ben Styles for contributing the new --exclude-non-flow and --percent-deciments options, and Xandor Schiefer for adding support to the new flow annotations.

0.5.0

Features:

  • added a new badge reporter (#140)
  • added a new --strict-coverage option to enforce a more strict coverage reporting mode. (#141)

The new badge reporter is implicitly executed when the html report is enabled and it generates two badges: 'flow-badge.svg' is a badge related to the flow validation check, 'flow-coverage-badge.svg' is a badge related to the flow coverage level reached by the project.

The new --strict-coverage option enables a more strict coverage reporting where only the flow annotated files are considered as covered (while all the non annotated files and the "@flow weak" annotated ones are considered as fully uncovered).

Thanks to RΓΊnar Berg Baugsson SigrΓ­Γ°arson for contributing the new badge reporter, and to Desmond Brand and Matt Sprague for contributing the new --strict-coverage option.

0.4.1

Bug Fixes:

  • fixed wrong annotation on multiple pragmas on the same line (#135)

Thanks to Ryan Albrecht and Karolis Grinkevičius for their help on this bugfix release.

0.4.0

Features:

  • collect and report flow preamble annotation type along with coverage information (thanks to Ryan Albrecht)

Bug Fixes:

  • fixed bug related to ignored custom threshold in the rendered HTML report (thanks to Boris Egorov)
  • fixed coverage percent 0 rendered as NaN in report text
  • upgraded flow to v.0.57.3 and fixed new flow error (Julien Wajsberg)
  • fix flow coverage for escaped special chars in filenames

Thanks to Ryan Albrecht, Boris Egorov, Julien Wajsberg for their help on this new release.

0.3.0

Introduces the new command line options:

  • submit more then 1 concurrent file to flow using -c numManConcurentFilesSubmitted (defaults to 1)
  • load options from a specific config file using --config filepath and disable config loading using --no-config

flow-coverage-report v0.3.0 loads the configuration automatically from the flow-coverage-report section of the target project package.json (or from a .flow-coverage-report.json file in the project dir), which is going to help to reduce the number of command line options that have to be explicitly passed on the command line.

In this version, the flow-coverage-report npm package is also switching to a MIT license.

Features:

  • enhancements on the HTML report template (thanks to Jason Laster)
  • added optional -c/--concurrent-files option, to submit multiple files to flow
  • optionally load config from package.json or json config file

Bug Fixes:

  • fixed missing error exit code with text reporter
  • fixed the link to GitHub in the cli help
  • saved collected coverage data in temp json file to support larger project

Thanks to Ryan Albrecht, Jason Laster, Guillaume Claret and Steven Luscher for their help on this new release.

0.2.0

Introduces the new command line options:

  • excluded file patterns using -x "pattern"
  • customize the output dir using -o reportDirPath

flow-coverage-report v0.2.0 also introduces some fixes needed to be able to generate flow coverage reports on larger projects (and projects with flow issues) and new command line options:

  • fix: fixed NaN percent and React false-positive mutation warning (thanks to Ilia Saulenko)
  • feat: new -o cli option to customize the output dir (thanks to Ryan Albrecht)
  • fix: cleanup old dirs before a new babel build (thanks to Ryan Albrecht)
  • fix: fixed issues with larger projects and projects with flow issues (thanks to Ilia Saulenko and Ryan Albrecht for the help hunting this issue down)
  • feat: new -x cli option to exclude files from the coverage report
  • fix: fixed report-text rendering issues on larger number of files
  • feat: highlight files with errors and no coverage data in the reports
  • feat: included URL to the generated HTML report in the console output (thanks to Jason Laster)

Thanks to Ilia Saulenko, Ryan Albrecht and Jason Laster for their help on this new release.

0.1.0

Initial prototype release:

  • collect and report coverage data as json, text and html
  • navigable sourcefile coverage html view based on CodeMirror
  • run unit tests on travis

Thanks to Kumar McMillan and Andy MacKay for their advice and support, this project and its github repo wouldn't exist without you.

More Repositories

1

create-webextension

create a new WebExtension with only one command
JavaScript
24
star
2

grunt-mozilla-addon-sdk

OBSOLETE: use [grunt-jpm](https://github.com/rpl/grunt-jpm) instead - Integrate Mozilla Addon SDK download and cfx tool into grunt tasks
JavaScript
22
star
3

python-wiimote-hacks

Some little experiments of wiimote remote controller on GNU/Linux
Python
12
star
4

idb-file-storage

Simple Promise-based IndexedDB wrapper to store files
JavaScript
12
star
5

webpack-webext-plugin

a small Webpack plugin to integrate web-ext commands into a web-pack build.
JavaScript
10
star
6

example-msedge-extension-with-webextension-polyfill

a minimal webextension example which shows how to include the webextension-polyfill into a "legacy" (non Chromium-based) MSEdge version
JavaScript
8
star
7

dev-webext-permissions-manager

A small extension to visualize and clear extension permissions for development reasons
JavaScript
8
star
8

grunt-jpm

Grunt Mozilla Addon-SDK JPM Tasks (xpi & run)
JavaScript
8
star
9

MozillaRDP-wireshark-plugins

[prototype] automated UML Sequence Diagrams generation from a sniffed pcap file
Lua
5
star
10

learning-merb

Personal Merb Learning Notes
JavaScript
5
star
11

going-nuts

GOing nuts: personal golang exercises
Go
4
star
12

contribute-firefox-webextensions-apis

Notes and links related to contributing to the Firefox WebExtensions APIs
4
star
13

yaterl

YATE Erlang module (prototype/experiment quality ;-))
Erlang
4
star
14

firefox-devpanel-visibility-events-workaround

Reusable JPM package which provides the show/hide events for the dev/panel module
JavaScript
4
star
15

rai-on-fire

RAI.tv - .NET + OpenWeb
JavaScript
3
star
16

jpm-addon-watch

wrap jpm and jpm-addon to auto-reload a Firefox Addon on source code changes (prototype)
JavaScript
3
star
17

mod_http_testhelper

experimental/simple ejabberd http request handler to serve helpers useful during xmpp code testing
Erlang
3
star
18

mozconfig-env

mozconfig-env shell helpers for zsh/bash/fish to switch between a set of MOZCONFIG files
3
star
19

jetpack-sdk

my GIT mirror of Mozilla Jetpack Rebooted SDK HG repository
JavaScript
3
star
20

rdp-monitor-jpext

[prototype] Firefox DevTool panel to log and visualize Remote Debugger Protocol messages
JavaScript
3
star
21

tiny-slidedown

Personal All-in-one SlideDown fork
Ruby
2
star
22

webext-experiment-firefoxRDP

a webextension experiment which provides a simple WebExtensions API to directly interact with the Remote Debugging Protocol
JavaScript
2
star
23

jquery-tablesheet

experiment on using jquey-tmpl in custom jquery-ui widget
JavaScript
2
star
24

rpl.github.com

personal github pages
2
star
25

linuxday2010-erlang

"Erlang: do geeks dream of concurrent sheeps?
JavaScript
2
star
26

learning-erlang-experiments

personal learning experiments on Erlang
Erlang
2
star
27

rpl-on-jetpack

(Wannabe) Collection of my experiments on the Mozilla Jetpack Rebooted SDK
JavaScript
2
star
28

linuxday2010-openweb

slide "Mozilla, Firefox4 e l'OpenWeb" (LinuxDay2010 - SaLUG!)
JavaScript
2
star
29

xulnotificationbox-example-ff

Minimal Firefox Addon to experiment notificationbox API
JavaScript
1
star
30

atom-webextensions

This package provides a plugin for the Atom editor to help you write your next Firefox WebExtensions add-on.
JavaScript
1
star
31

fxos-gdg-firenze-2014

CSS
1
star
32

whereismycar-firefoxmobile

"Where is my car?" for Firefox Mobile addon (based on Jetpack SDK) ** Winner of Mozilla Mobile Add-ons Challenge! **
JavaScript
1
star
33

firefox-devtools-sidebar-tabs

Firefox Devtools Sidebar Custom Tabs - JPM helper module prototype
JavaScript
1
star
34

webext-experiment-devtools

A webextension experiment for experimental devtools-related APIs
JavaScript
1
star
35

xulrunner-jsctypes-testdrive

Test JS-CTypes in a minimal XULRunner application
1
star
36

mozilla-addons-and-browserify

two small example add-ons which shows how to use browserified modules in Firefox add-ons based on the WebExtensions or the Addon SDK.
JavaScript
1
star
37

firefox-devtools

*experimental* JPM helper for Firefox Developer Tools Add-on
JavaScript
1
star
38

ncouch

yet another collection of couchdb node utilities
JavaScript
1
star
39

appdeveloper-guide-firefoxos

slides from "FirefoxOS App Days" @ Rome - 26 Jan 2013
JavaScript
1
star
40

rdp-log-viewer

[prototype] Web-based viewer for rdp-logging json log files
JavaScript
1
star
41

mozrepl-panel

A Mozilla XULRunner/Firefox/Thunderbird and Songbird extension to embed MozRepl interactive javascript shell in a XUL Panel
JavaScript
1
star
42

firefox-webext-what-the-global

Collect and visualize the globals defined by the Firefox from ext-*.js API implementation scripts
TypeScript
1
star
43

flow-typed-webextensions

a set of flow types definitions generated from the WebExtensions API JSON schema files and the tool to update them over the time
JavaScript
1
star