eslint-plugin-flowtype-errors
Demo
NOTE: This demo is using Atom and the packages linter
, linter-eslint
, language-babel
Why?
- Lower barrier: Any editor that has ESLint support now supports Flow 🎉
- Less editor configuration: No need to change your entire workflow to incorporate flow. No multiple-linters-per-file nonsense.
- Simple: Its literally just an ESLint rule! Just install the dependency, add a flowconfig, and you're good to go!
Getting Started
This guide assumes that you have installed eslint, babel, babel-plugin-transform-flow-strip-types and configured flow. Check out the from-scratch guide for the full guide on getting started.
⚠️ Make sure the 64-bit version of your texteditor/IDE. For atom, see this comment
Step 1. Install
npm install --save-dev eslint-plugin-flowtype-errors
Step 2. Configure
Add this line to the 'rules' section of your .eslintrc
to report flow errors.
"flowtype-errors/show-errors": "error"
Add this line to the 'rules' section of your .eslintrc
to report flow warnings.
"flowtype-errors/show-warnings": "warn"
Note that flow won't report warnings unless you add this setting to your .flowconfig
:
[options]
include_warnings=true
Add this line to the 'rules' section of your .eslintrc
to enforce a minimum percentage of flow coverage per file (optional). Here's an example of enforcing a converage of at least 50%:
"flowtype-errors/enforce-min-coverage": ["error", 50]
Add this line to the 'plugins' section of your .eslintrc
"flowtype-errors"
Add the @flow
pragma to files that you want to lint
Also make sure that your .flowconfig
is in the root of your project directory
Step 3. Settings (optional)
Add this line to the 'settings' section of your .eslintrc
to force the Flow server to stop after it finishes checking types.
"settings": {
"flowtype-errors": {
"stopOnExit": true
}
},
Step 4. Lint
Run eslint
and you're all set!
Support
If this project is saving you (or your team) time, please consider supporting it on Patreon 👍 thank you!
CI Configuration
Flow is supported on all OS's except Windows 32bit. Add this line to appveyor to make tests run properly.
Editor Configuration
Atom
apm install linter linter-eslint language-babel
Sublime
Others
http://eslint.org/docs/user-guide/integrations#editors
Planned Implementations
- Add more extensive tests
- Allow passing arguments to flow binary
- Run flow minimal amount of times for faster linting
- Custom formatting of flow error messages
- Enable rules to allow and disallow specific flow errors
Related flow tools: