Reactjs ESLint报告流类型的全局类型上没有未定义错误
我在Reactjs ESLint报告流类型的全局类型上没有未定义错误,reactjs,eslint,flowtype,eslint-config-airbnb,Reactjs,Eslint,Flowtype,Eslint Config Airbnb,我在/flow-typed/redux.flow.js中定义了全局类型: declare type Action = {| +type: string, +payload: any, |} declare type State = {| +ui: UI, +user: User, +team: Team, +projects: Project[], +profile: Profile, |} declare type UI = {| +isSliderOpen
/flow-typed/redux.flow.js
中定义了全局类型:
declare type Action = {|
+type: string,
+payload: any,
|}
declare type State = {|
+ui: UI,
+user: User,
+team: Team,
+projects: Project[],
+profile: Profile,
|}
declare type UI = {|
+isSliderOpen: boolean,
+isModalVisible: boolean,
+modalAction: string,
+modalPayload: Object,
|}
...
我已将airbnb eslint配置添加到我的项目中,现在我得到:
type Props = {
logout: () => Action, //error ESLint 'Action' is not defined.(no-undef)
user: UserDetails, //error ESLint 'UserDetails' is not defined.(no-undef)
}
这完全是埃斯林断层。一切都配置正确,流程本身也很愉快
如何告诉eslint这些类型确实声明为全局类型?或者我应该将它们添加到一些忽略列表中吗?您可以使用文件内部、eslint配置文件或package.json中的注释来定义全局变量。阅读如何在中完成它。如果您需要更多帮助,请留下评论。事实证明(就像我想的那样),方法不是将全局类型添加到eslint忽略列表中。事实上,我已经安装好了,但我没有像这样扩展它: .eslintrc
"extends": ["airbnb", "plugin:flowtype/recommended"],
"plugins": [
"flowtype"
],
这是唯一的解决办法吗?然后,我必须忽略流类型目录中的每个类型,如:
SyntheticInputEvent
或Dispatch