From 60b5b4ee9f8fc4740df8c3a9d585e0d49f98da83 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Thu, 21 Jul 2016 23:44:01 -1000 Subject: [PATCH 1/3] WIP --- .eslintrc.json | 29 +++++++++++++++++++++++-- .flowconfig | 7 +++--- .jscsrc | 18 +++++++++++++++ app/App.js | 3 ++- app/components/AddComment/AddComment.js | 3 ++- app/components/Comments/Comments.js | 5 ++++- app/hocs/withAddCommentHandlers.js | 29 +++++++++++-------------- app/hocs/withRemoteDataSource.js | 2 +- app/libs/api/index.js | 1 + app/libs/utils/redux.js | 4 ++-- app/reducers/commentsReducer.js | 15 +++++++------ app/sagas/submitComment.js | 1 + package.json | 25 ++++++++++++--------- test/libs/utils/redux.spec.js | 3 ++- test/sagas/fetchComments.spec.js | 2 +- 15 files changed, 100 insertions(+), 47 deletions(-) create mode 100644 .jscsrc diff --git a/.eslintrc.json b/.eslintrc.json index e1065ce..30b8c2b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,8 @@ "extends": "eslint-config-shakacode", "plugins": [ - "react-native" + "react-native", + "flowtype" ], "env": { @@ -17,6 +18,9 @@ "extensions": [".js", ".android.js", ".ios.js"], "moduleDirectory": ["..", "node_modules"] } + }, + "flowtype": { + "onlyFilesWithFlowAnnotation": true } }, @@ -31,6 +35,27 @@ "react-native/no-color-literals": 2, "react/jsx-no-bind": 1, "react/prefer-stateless-function": 1, - "react/jsx-indent": 1 + "react/jsx-indent": 1, + + "flowtype/require-parameter-type": 1, + "flowtype/require-return-type": [ + 1, + "always", + { + "annotateUndefined": "never" + } + ], + "flowtype/space-after-type-colon": [ + 1, + "never" + ], + "flowtype/space-before-type-colon": [ + 1, + "never" + ], + "flowtype/type-id-match": [ + 1, + "^([A-Z][a-z0-9]+)+Type$" + ] } } diff --git a/.flowconfig b/.flowconfig index e28e2f5..410fc39 100644 --- a/.flowconfig +++ b/.flowconfig @@ -8,13 +8,14 @@ # Ignore malformed json .*/node_modules/y18n/test/.*\.json +.*/node_modules/jsonlint/test/.*\.json [include] [libs] node_modules/react-native/Libraries/react-native/react-native-interface.js node_modules/react-native/flow -flow/ +node_modules/immutable/dist [options] module.system=haste @@ -22,8 +23,6 @@ module.system=haste esproposal.class_static_fields=enable esproposal.class_instance_fields=enable -experimental.strict_type_args=true - munge_underscores=true module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' @@ -38,4 +37,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9 suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy [version] -^0.27.0 +^0.22.1 diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..8a0704f --- /dev/null +++ b/.jscsrc @@ -0,0 +1,18 @@ +{ + "preset": "airbnb", + "fileExtensions": [ + ".js", + ".jsx" + ], + "excludeFiles": [ + "ios/**", + "android/**", + "node_modules/**" + ], + "esprima": "babel-jscs", + "validateQuoteMarks": { + "mark": "'", + "escape": true, + "ignoreJSX": true + } +} diff --git a/app/App.js b/app/App.js index e68429f..484c96b 100644 --- a/app/App.js +++ b/app/App.js @@ -1,10 +1,11 @@ +// @flow import React from 'react'; import { Provider } from 'react-redux'; import createStore from './store/store'; import ReduxContainer from './containers/ReduxContainer'; -export default () => { +export default ():ReactElement => { const store = createStore(); return ( diff --git a/app/components/AddComment/AddComment.js b/app/components/AddComment/AddComment.js index f10bfd2..9d926ee 100644 --- a/app/components/AddComment/AddComment.js +++ b/app/components/AddComment/AddComment.js @@ -2,7 +2,8 @@ import React, { PropTypes } from 'react'; import { Text, View, TextInput } from 'react-native'; import _ from 'lodash/fp'; -import ActivityIndicator from 'ReactNativeTutorial/app/components/ActivityIndicator/ActivityIndicator'; +import ActivityIndicator from + 'ReactNativeTutorial/app/components/ActivityIndicator/ActivityIndicator'; import withFormState from 'ReactNativeTutorial/app/hocs/withFormState'; import withAddCommentHandlers from 'ReactNativeTutorial/app/hocs/withAddCommentHandlers'; import Button from 'ReactNativeTutorial/app/components/Button/Button'; diff --git a/app/components/Comments/Comments.js b/app/components/Comments/Comments.js index 7df93dd..740bfac 100644 --- a/app/components/Comments/Comments.js +++ b/app/components/Comments/Comments.js @@ -8,7 +8,8 @@ import _ from 'lodash/fp'; import Comment from 'ReactNativeTutorial/app/components/Comment/Comment'; import Button from 'ReactNativeTutorial/app/components/Button/Button'; -import ActivityIndicator from 'ReactNativeTutorial/app/components/ActivityIndicator/ActivityIndicator'; +import ActivityIndicator from + 'ReactNativeTutorial/app/components/ActivityIndicator/ActivityIndicator'; import withRemoteDataSource from 'ReactNativeTutorial/app/hocs/withRemoteDataSource'; import routes from 'ReactNativeTutorial/app/constants/routes'; import styles from './CommentsStyle'; @@ -21,6 +22,7 @@ const Comments = (props) => ( props.actions.resetErrorState(); props.remoteDataSourceFetch(); }} + text="Reload" />