eslint-plugin-flowtype
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@babel/plugin-syntax-flow | 7.24.1 | 5.3 kB | MIT | prod peer | 1 1 |
@babel/plugin-transform-react-jsx | 7.23.4 | 19.11 kB | MIT | prod peer | 1 1 |
eslint | 8.57.0 | 2.9 MB | MIT | prod peer | |
lodash | 4.17.21 | 311.49 kB | MIT | prod | |
string-natural-compare | 3.0.1 | 4 kB | MIT | prod |
ESLint-plugin-flowtype is an extension for ESLint that enforces static type checking using Facebook's Flow. It equipped with various Flow-specific linting rules that encourage better type annotation style and practices when developing JavaScript applications.
Using eslint-plugin-flowtype is as simple as installing it along with ESLint and the Babel-eslint parser, then setting them up in your ESLint configuration.
Installation can be done using npm as follows:
npm install eslint --save-dev
npm install @babel/eslint-parser --save-dev
npm install eslint-plugin-flowtype --save-dev
After installation, you need to set up your ESLint configuration file, .eslintrc
:
parser
property to @babel/eslint-parser
.plugins
section and specify eslint-plugin-flowtype
as a plugin.Here’s an example of .eslintrc
setup:
{
"parser": "@babel/eslint-parser",
"plugins": [
"flowtype"
],
"rules": {
"flowtype/boolean-style": [
2,
"boolean"
],
"flowtype/define-flow-type": 1,
// ...more rules
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
}
}
In this setup, the flowtype/boolean-style
rule is set to enforce the use of boolean
instead of bool
, and the flowtype/define-flow-type
rule is set to treat Flow type identifiers as defined, among other rules.
You can also extend the plugin's recommended configuration:
{
"extends": [
"plugin:flowtype/recommended"
],
"plugins": [
"flowtype"
]
}
Remember to annotate your JavaScript files with @flow
to apply the Flow checking.
The detailed documentation for eslint-plugin-flowtype is located in the GitHub repository for the package. It includes specific details about each rule and configurations options available, along with examples for better understanding. Please refer to this guide to learn about installing, configuring and effectively utilizing the eslint-plugin-flowtype for enforcing Flow type checking in your JavaScript application.