Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint reports no-undef error on flow-typed global types

I have global types defined in /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,
|}

...

I have added airbnb eslint configuration to my project and now I get:

type Props = {
  logout: () => Action, //error ESLint 'Action' is not defined.(no-undef)
  user: UserDetails, //error ESLint 'UserDetails' is not defined.(no-undef)
}

Its purelly eslint fault. Everything is configured properly and flow by itself is happy.

How to tell eslint that these types are indeed declared as global? or should I add them to some ignore list?

like image 900
Tomasz Mularczyk Avatar asked Jul 13 '17 19:07

Tomasz Mularczyk


1 Answers

It turned out (like I thought) the way is not to add global types to eslint ignore list. Actually it's is all handled by eslint-plugin-flowtype which I already had installed but I didn't extend it like:

.eslintrc

"extends": ["airbnb", "plugin:flowtype/recommended"],
"plugins": [
  "flowtype"
],
like image 117
Tomasz Mularczyk Avatar answered Oct 24 '22 19:10

Tomasz Mularczyk