Mar*_*ory 19 javascript facebook reactjs eslint flowtype
我在一个项目中使用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
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能让它发挥作用?有没有办法使用webpack一起在监视任务中运行流程?
zur*_*fyx 26
flow-vars 已弃用!
这是使Airbnb(使用eslint-plugin-flowtype)运行Flow的当前正确方法:
这假设您已经安装了流程.
npm install --save-dev eslint babel-eslint eslint-plugin-flowtype
Run Code Online (Sandbox Code Playgroud)
.eslintrc
{
"extends": [
"airbnb",
"plugin:flowtype/recommended"
],
"parser": "babel-eslint",
"plugins": [
"flowtype"
]
}
Run Code Online (Sandbox Code Playgroud)
想要自定义配置吗?
对我来说,通过添加"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
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8100 次 |
| 最近记录: |