我在项目中使用ESLint并且也希望使用Facebook流程,但是我收到ESLint关于流类型注释的警告。
我在项目根目录中有.flowconfig和.eslintrc。
.eslintrc:
// When you write javascript you should follow these soft rules and best practices
// https://github.com/airbnb/javascript
// This is a link to best practices and enforcer settings for eslint
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
// Use this file as a starting point for your project's .eslintrc.
{
"extends": "airbnb",
"plugins": [
"flow-vars"
],
"rules": {
"flow-vars/define-flow-type": 1,
"flow-vars/use-flow-type": 1
}
}
我该怎么做才能让它发挥作用?有没有办法使用webpack一起在监视任务中运行流程?
答案 0 :(得分:25)
flow-vars
已被弃用!
这是使用Airbnb(eslint-plugin-flowtype
)运行Flow的当前正确方法:
这假设您已经安装了flow。
npm install --save-dev eslint babel-eslint eslint-plugin-flowtype
.eslintrc
{
"extends": [
"airbnb",
"plugin:flowtype/recommended"
],
"parser": "babel-eslint",
"plugins": [
"flowtype"
]
}
要改为custom configuration吗?
答案 1 :(得分:8)
对我来说,问题已经通过将"parser": "babel-eslint"
添加到我的.eslintrc
来解决了。
(我必须首先运行npm install babel-eslint --save-dev
)。
{
"extends": "airbnb",
"parser": "babel-eslint", // <--
"plugins": [
"flow-vars"
],
"rules": {
"flow-vars/define-flow-type": 1,
"flow-vars/use-flow-type": 1
}
}