grunt-flow
Validates JavaScript with Facebook's Flow Library
Getting Started
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-flow --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "flow" task
Overview
In your project's Gruntfile, add a section named flow
to the data object passed into grunt.initConfig()
.
grunt
Options
options.style
Type: String
Default value: color
A string value that is used to determine flow output styling. There are two options to choose from:
color
- This will colorize the output from flownone
- This will keep the default standard text output from flow without any color.
options.server
Type: Boolean
Default value: true
If set, flow
instead of flow check
will be used. This starts the background flow server, which is much more performant at re-running checks.
This should used in conjunction with grunt-contrib-watch:
grunt.initConfig({
flow: {
watch: {
src: 'src/**/*.js',
options: {
server: true
}
}
},
watch : {
flow: {
files: ['src/**/*.js'],
tasks: ['flow'] // Get the status from the server
}
}
});
// Run 'flow' before the watch task to start the server
grunt.registerTask('default', ['flow', 'watch']);
options.config
Type: String
Default value: .flowconfig
Path to the configuration file for flow. Default is .flowconfig
in the current directory.
Usage
Config
Flow requires that you have a .flowconfig
file in the root of you project folder. Below is an example of what your .flowconfig
file should look like:
# .flowconfig [include] [ignore].*/node_modules/flow-bin
You can look up more information on the .flowconfig
file on the flow website
Note that you can set the path to configuration file with options.config
.
Task
Within your Gruntfile.js, add the following code to enable colorized output for flow.
grunt
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
v1.0.3 - Fixed logic so that all error codes above 0
cause a grunt failure
v1.0.2 - Added server
option to allow for using the flow background server with the grunt-contrib-watch task.
v1.0.1 - Added logic to correctly exit task on Flow error.
v1.0.0 - Updated to latest version of flow (v0.14.0)
v0.0.3 - Fixed colorized output
v0.0.2 - Added style
option to enable colorized output
v0.0.1 - Initial release
License
Copyright (c) 2015 Jake Larson. Licensed under the MIT license.