Skip to content

Commit 685838f

Browse files
committed
flow
1 parent a114ad1 commit 685838f

File tree

9 files changed

+50
-13
lines changed

9 files changed

+50
-13
lines changed

mobile/ReactNativeTutorial/.eslintrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
no-console: 0
3131
import/imports-first: 2
3232
import/prefer-default-export: 2
33+
no-duplicate-imports: 0
3334

3435
# Delegating proptypes check to flow
3536
react/prop-types: 0

mobile/ReactNativeTutorial/.flowconfig

+11-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
.*/Libraries/react-native/React.js
2424
.*/Libraries/react-native/ReactNative.js
2525
.*/node_modules/jest-runtime/build/__tests__/.*
26+
.*/node_modules/react/node_modules/.*
27+
.*/node_modules/react-native-experimental-navigation/.*
28+
.*/node_modules/react-native/Libraries/Components/StaticContainer.js
29+
30+
# Json lint doesn't pass flow
31+
.*/node_modules/jsonlint/.*
2632

2733
[include]
2834

@@ -48,8 +54,11 @@ suppress_type=$FlowIssue
4854
suppress_type=$FlowFixMe
4955
suppress_type=$FixMe
5056

51-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
57+
suppress_type=$FlowIgnore
58+
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore
59+
60+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
61+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
5362
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
5463

5564
unsafe.enable_getters_and_setters=true

mobile/ReactNativeTutorial/app/bundles/comments/components/Add/Add.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { View } from 'react-native';
44
import { FormLabel, FormInput, Button } from 'react-native-elements';
55

66
import withAddProps from '../../hocs/withAddProps';
7+
import type { AddPropsType } from '../../hocs/withAddProps';
78

89
import styles from './AddStyle';
910

10-
type PropsType = {
11-
12-
}
11+
type PropsType = AddPropsType;
1312

1413
const Add = (props: PropsType) => (
1514
<View>

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/Index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { View } from 'react-native';
44
import List from './List/List';
55
import Footer from './Footer/Footer';
66
import withIndexProps from '../../hocs/withIndexProps';
7+
import type { IndexPropsType } from '../../hocs/withIndexProps';
78

89
import styles from './IndexStyle';
910

10-
type PropsType = {
11-
12-
}
11+
type PropsType = IndexPropsType;
1312

1413
class Index extends React.Component {
1514

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/List/Item/Item.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @flow
12
import React from 'react';
23
import { View, Text } from 'react-native';
34

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/List/List.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import React from 'react';
33
import { ListView, RefreshControl } from 'react-native';
44
import _ from 'lodash/fp';
5+
import type { IndexPropsType } from '../../../hocs/withIndexProps';
56
import Item from './Item/Item';
67

78
import styles from './ListStyle';
89

9-
type PropsType = {
10-
}
10+
type PropsType = IndexPropsType;
1111

1212
const List = (props: PropsType) => {
1313
const data = _.compose(

mobile/ReactNativeTutorial/app/bundles/comments/hocs/withAddProps.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import { createSelector } from 'reselect';
66
import commentFormSelector from '../../../selectors/commentFormSelector';
77
import { actions } from '../sagas';
88

9+
export type AddPropsType = {
10+
author?: string,
11+
text?: string,
12+
actions: {
13+
fetch: () => void,
14+
updateForm: (payload: Object) => void,
15+
createComment: (payload: Object) => void,
16+
}
17+
}
18+
919
const mapStateToProps = createSelector(
1020
commentFormSelector,
1121
(commentForm: any) => commentForm.toJS()
@@ -15,5 +25,5 @@ const mapDispatchToProps = (dispatch: Function) => ({
1525
actions: bindActionCreators(actions, dispatch),
1626
});
1727

18-
export default (Component: ReactClass<any>): ReactClass<{}> =>
28+
export default (Component: ReactClass<AddPropsType>): ReactClass<{}> =>
1929
connect(mapStateToProps, mapDispatchToProps)(Component);

mobile/ReactNativeTutorial/app/bundles/comments/hocs/withIndexProps.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ import { createSelector } from 'reselect';
66
import commentsStoreSelector from '../../../selectors/commentsStoreSelector';
77
import { actions } from '../sagas';
88

9+
type CommentType = {
10+
author?: string,
11+
text?: string,
12+
}
13+
14+
export type IndexPropsType = {
15+
comments: Array<CommentType>,
16+
meta: {
17+
loading: boolean,
18+
},
19+
actions: {
20+
fetch: () => void,
21+
updateForm: (payload: Object) => void,
22+
createComment: (payload: Object) => void,
23+
}
24+
}
25+
926
const mapStateToProps = createSelector(
1027
commentsStoreSelector,
1128
(commentsStore: any) => ({
@@ -18,5 +35,5 @@ const mapDispatchToProps = (dispatch: Function) => ({
1835
actions: bindActionCreators(actions, dispatch),
1936
});
2037

21-
export default (Component: ReactClass<any>): ReactClass<{}> =>
38+
export default (Component: ReactClass<IndexPropsType>): ReactClass<{}> =>
2239
connect(mapStateToProps, mapDispatchToProps)(Component);

mobile/ReactNativeTutorial/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start",
77
"test": "jest",
8-
"flow": "flow",
8+
"flow": "node_modules/flow-bin/cli.js",
99
"lint": "node_modules/eslint/bin/eslint.js --config .eslintrc.yml app"
1010
},
1111
"dependencies": {
@@ -37,6 +37,7 @@
3737
"eslint-plugin-jsx-a11y": "^2.2.3",
3838
"eslint-plugin-react": "^6.7.1",
3939
"eslint-plugin-react-native": "^2.1.0",
40+
"flow-bin": "^0.33.0",
4041
"jest": "17.0.3",
4142
"jest-react-native": "17.0.3",
4243
"react-test-renderer": "15.3.2"

0 commit comments

Comments
 (0)