From 2a608a8b4b3c2de2ed7a1f2a9c607259174786db Mon Sep 17 00:00:00 2001 From: Shaun Sweet Date: Wed, 21 Feb 2018 01:28:55 -0700 Subject: [PATCH] flow. --- .babelrc | 1 + .eslintrc.js | 3 +- .flowconfig | 15 +- .../npm/eslint-config-standard-flow_vx.x.x.js | 45 +++ .../npm/eslint-plugin-flowtype_vx.x.x.js | 375 ++++++++++++++++++ flow-typed/npm/react-hot-loader_v3.x.x.js | 2 +- flow-typed/redux-persist.js | 11 + package.json | 3 + src/App.js | 7 +- src/config/configStore.js | 2 - src/config/types/reduxTyper.js | 4 + .../AccountSelectionWidget.js | 32 +- src/features/Accounts/redux/addAccount.js | 49 ++- .../common/components/Layout/Layout.js | 4 +- .../common/components/Layout/index.js | 5 +- .../common/components/Layout/styles.js | 1 + webpack-config.js | 2 + yarn.lock | 142 ++++++- 18 files changed, 658 insertions(+), 45 deletions(-) create mode 100644 flow-typed/npm/eslint-config-standard-flow_vx.x.x.js create mode 100644 flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js create mode 100644 flow-typed/redux-persist.js create mode 100644 src/config/types/reduxTyper.js diff --git a/.babelrc b/.babelrc index de6beb4f..3bc3092b 100644 --- a/.babelrc +++ b/.babelrc @@ -9,6 +9,7 @@ "react-hot-loader/babel", "syntax-dynamic-import", "lodash", + "react-flow-props-to-prop-types", [ "module-resolver", { diff --git a/.eslintrc.js b/.eslintrc.js index 901993d2..763faaf3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,7 +2,8 @@ module.exports = { extends: [ "standard", "standard-react", - "standard-flow" + "standard-flow", + "plugin:flowtype/recommended" ], "parser": "babel-eslint", "plugins": [ "flowtype" ] diff --git a/.flowconfig b/.flowconfig index 0d0201e0..adee7422 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,11 +1,18 @@ [ignore] -.*/src/config/.* +.*/build/.* +.*/tests/.* +.*/tools/.* +.*/.git/.* +.*/node_modules/.* [include] - [libs] - [lints] [options] -all=true +suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe +module.name_mapper='^@config\/\(.*\)$' -> '/src/config/\1' +module.name_mapper='^@\/\(.*\)$' -> '/src/\1' +module.name_mapper='^@features\/\(.*\)$' -> '/src/features/\1' +module.name_mapper='^@components\/\(.*\)$' -> '/src/features/common/components/\1' +module.file_ext=.js [strict] diff --git a/flow-typed/npm/eslint-config-standard-flow_vx.x.x.js b/flow-typed/npm/eslint-config-standard-flow_vx.x.x.js new file mode 100644 index 00000000..d0a211e5 --- /dev/null +++ b/flow-typed/npm/eslint-config-standard-flow_vx.x.x.js @@ -0,0 +1,45 @@ +// flow-typed signature: 74a9ab74fd691e5301d62e5328d95cc6 +// flow-typed version: <>/eslint-config-standard-flow_v^1.0.1/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'eslint-config-standard-flow' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'eslint-config-standard-flow' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'eslint-config-standard-flow/test/basic' { + declare module.exports: any; +} + +declare module 'eslint-config-standard-flow/test/validate-config' { + declare module.exports: any; +} + +// Filename aliases +declare module 'eslint-config-standard-flow/index' { + declare module.exports: $Exports<'eslint-config-standard-flow'>; +} +declare module 'eslint-config-standard-flow/index.js' { + declare module.exports: $Exports<'eslint-config-standard-flow'>; +} +declare module 'eslint-config-standard-flow/test/basic.js' { + declare module.exports: $Exports<'eslint-config-standard-flow/test/basic'>; +} +declare module 'eslint-config-standard-flow/test/validate-config.js' { + declare module.exports: $Exports<'eslint-config-standard-flow/test/validate-config'>; +} diff --git a/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js b/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js new file mode 100644 index 00000000..df26e559 --- /dev/null +++ b/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js @@ -0,0 +1,375 @@ +// flow-typed signature: c356370ba2c5327d483cf24292d714d8 +// flow-typed version: <>/eslint-plugin-flowtype_v^2.45.0/flow_v0.66.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'eslint-plugin-flowtype' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'eslint-plugin-flowtype' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'eslint-plugin-flowtype/bin/readmeAssertions' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/index' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/booleanStyle' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/defineFlowType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/delimiterDangle' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/genericSpacing' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noDupeKeys' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noExistentialType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noMutableArray' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noUnusedExpressions' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireExactType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireReturnType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireTypesAtTop' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/requireVariableType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/semi' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/sortKeys' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/spaceAfterTypeColon' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/spaceBeforeGenericBracket' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/spaceBeforeTypeColon' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/useFlowType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/validSyntax' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/getParameterName' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/index' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/isFlowFile' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/isFlowFileAnnotation' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/iterateFunctionNodes' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/quoteName' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/utilities/spacingFixers' { + declare module.exports: any; +} + +// Filename aliases +declare module 'eslint-plugin-flowtype/bin/readmeAssertions.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/bin/readmeAssertions'>; +} +declare module 'eslint-plugin-flowtype/dist/index.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/index'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/booleanStyle.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/booleanStyle'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/defineFlowType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/defineFlowType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/delimiterDangle.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/delimiterDangle'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/genericSpacing.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/genericSpacing'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noDupeKeys.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noDupeKeys'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noExistentialType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noExistentialType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noMutableArray.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noMutableArray'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noUnusedExpressions.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noUnusedExpressions'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noWeakTypes'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireExactType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireExactType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireParameterType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireReturnType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireReturnType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireTypesAtTop.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireTypesAtTop'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/requireVariableType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireVariableType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/semi.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/semi'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/sortKeys.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/sortKeys'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/spaceAfterTypeColon.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/spaceAfterTypeColon'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/spaceBeforeGenericBracket.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/spaceBeforeGenericBracket'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/spaceBeforeTypeColon.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/spaceBeforeTypeColon'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateFunctions'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeIndexer'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateObjectTypeProperty'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateReturnType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeCastExpression'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeIdMatch'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/useFlowType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/useFlowType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/validSyntax.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/validSyntax'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/checkFlowFileAnnotation'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/fuzzyStringMatch'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/getParameterName.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getParameterName'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getTokenAfterParens'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/getTokenBeforeParens'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/index.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/index'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/isFlowFile.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/isFlowFile'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/isFlowFileAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/isFlowFileAnnotation'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/iterateFunctionNodes.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/iterateFunctionNodes'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/quoteName.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/quoteName'>; +} +declare module 'eslint-plugin-flowtype/dist/utilities/spacingFixers.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/utilities/spacingFixers'>; +} diff --git a/flow-typed/npm/react-hot-loader_v3.x.x.js b/flow-typed/npm/react-hot-loader_v3.x.x.js index 855c7a17..f0b21106 100644 --- a/flow-typed/npm/react-hot-loader_v3.x.x.js +++ b/flow-typed/npm/react-hot-loader_v3.x.x.js @@ -2,7 +2,7 @@ // flow-typed version: 23646d2d0e/react-hot-loader_v3.x.x/flow_>=v0.53.0 // @flow -declare module "react-hot-loader" { +declare module 'react-hot-loader' { declare class AppContainer extends React$Component<{ errorReporter?: React$Element | (() => React$Element), children: React$Element diff --git a/flow-typed/redux-persist.js b/flow-typed/redux-persist.js new file mode 100644 index 00000000..e01f5e5e --- /dev/null +++ b/flow-typed/redux-persist.js @@ -0,0 +1,11 @@ +// @flow +declare module 'redux-persist/integration/react' { + declare export function PersistGate(): any +} + +declare module 'redux-persist/lib/storage' { + declare class storage { + + } + declare export default typeof storage; +} diff --git a/package.json b/package.json index 07632a2a..ef12ab23 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "babel-plugin-istanbul": "4.1.5", "babel-plugin-lodash": "3.3.2", "babel-plugin-module-resolver": "3.1.0", + "babel-plugin-react-flow-props-to-prop-types": "^0.15.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-polyfill": "6.26.0", "babel-preset-env": "1.6.1", @@ -62,6 +63,7 @@ "express-history-api-fallback": "2.2.1", "file-loader": "1.1.7", "flow-bin": "0.66.0", + "flow-webpack-plugin": "^1.2.0", "fs": "0.0.1-security", "history": "4.7.2", "jsdom": "11.6.2", @@ -102,6 +104,7 @@ "antd": "3.2.1", "dotenv": "5.0.0", "dropbox": "3.0.4", + "prop-types-extra": "^1.0.1", "redux-persist": "5.9.1", "styled-components": "3.1.6", "uuid": "3.2.1" diff --git a/src/App.js b/src/App.js index c50ea825..43bcc61d 100644 --- a/src/App.js +++ b/src/App.js @@ -1,13 +1,14 @@ -import React, { Component } from 'react' +// @flow +import React from 'react' import { Provider } from 'react-redux' import storeConfig from '@config/configStore' import { ConnectedRouter } from 'react-router-redux' import history from '@config/history' import Layout from '@components/Layout' import { PersistGate } from 'redux-persist/integration/react' - const { store, persistor } = storeConfig() -class App extends Component { + +class App extends React.Component<{}> { render () { return ( diff --git a/src/config/configStore.js b/src/config/configStore.js index 8d88ec6e..4235a3a6 100644 --- a/src/config/configStore.js +++ b/src/config/configStore.js @@ -1,4 +1,3 @@ -// @flow import { createStore, applyMiddleware, compose } from 'redux' import ReduxThunk from 'redux-thunk' import history from './history' @@ -8,7 +7,6 @@ import storage from 'redux-persist/lib/storage' // eslint-disable-next-line import { ConnectedRouter, routerReducer, routerMiddleware, push } from 'react-router-redux' // Now you can dispatch navigation actions from anywhere! - const middlewares = [ ReduxThunk, routerMiddleware(history) diff --git a/src/config/types/reduxTyper.js b/src/config/types/reduxTyper.js new file mode 100644 index 00000000..cc030afb --- /dev/null +++ b/src/config/types/reduxTyper.js @@ -0,0 +1,4 @@ +// @flow +// eslint-disable-next-line +type _ExtractReturn B> = B +export type ExtractReturn = _ExtractReturn<*, F> diff --git a/src/features/Accounts/containers/AccountSelectionWidget/AccountSelectionWidget.js b/src/features/Accounts/containers/AccountSelectionWidget/AccountSelectionWidget.js index cefdb896..e10f1610 100644 --- a/src/features/Accounts/containers/AccountSelectionWidget/AccountSelectionWidget.js +++ b/src/features/Accounts/containers/AccountSelectionWidget/AccountSelectionWidget.js @@ -1,32 +1,34 @@ +// @flow import React from 'react' // import propTypes from 'prop-types' // import { push } from 'react-router-redux' -import { connect } from 'react-redux' +// import { connect } from 'react-redux' // import { bindActionCreators } from 'redux' import CompStyles from './styles' - -class AccountSelectionWidget extends React.Component { - static propTypes = { - - } +type Props = { + name: string +} +export default class AccountSelectionWidget extends React.Component { + props: Props render = () => ( AccountSelectionWidget + {this.props.name} ) } AccountSelectionWidget.displayName = 'AccountSelectionWidget' -const mapStateToProps = state => ({ +// const mapStateToProps = state => ({ -}) +// }) -const mapDispatchToProps = dispatch => ({ - // actions: bindActionCreators({ **actionCreatorFunc** }, dispatch) -}) +// const mapDispatchToProps = dispatch => ({ +// // actions: bindActionCreators({ **actionCreatorFunc** }, dispatch) +// }) -export default connect( - mapStateToProps, - mapDispatchToProps -)(AccountSelectionWidget) +// export default connect( +// mapStateToProps, +// mapDispatchToProps +// )(AccountSelectionWidget) diff --git a/src/features/Accounts/redux/addAccount.js b/src/features/Accounts/redux/addAccount.js index b31acacd..6befc138 100644 --- a/src/features/Accounts/redux/addAccount.js +++ b/src/features/Accounts/redux/addAccount.js @@ -1,21 +1,46 @@ -const uuidv1 = require('uuid/v1') +// @flow +// const uuidv1 = require('uuid/v1') +import type { ExtractReturn } from '@config/types/reduxTyper' +type Account = { + id: string, + nickname: string, + balance: number +} +type State = { + accounts: { + budgetAccounts: string[], + allAccounts: { + [account_id: string]: Account + } + } +} +const initialState = { + accounts: { + budgetAccounts: [], + allAccounts: {} + } +} const ADD_NEW_ACCOUNT = 'sr/Accounts/ADD_NEW_ACCOUNT' +const addNewAccount = (account: Account) => ({ type: ADD_NEW_ACCOUNT, payload: account }) +type Action = ExtractReturn + +// export const saveAccountToDropbox = () => (dispatch, getState) => { +// dispatch() +// } -export default function reducer (state = initialState(), action = {}) { +export default function reducer (state: State = initialState, action: Action): State { switch (action.type) { case ADD_NEW_ACCOUNT: - return {} + const { accounts: { budgetAccounts, allAccounts } } = state + const account = action.payload + return { + accounts: { + budgetAccounts: [...budgetAccounts, account.id], + allAccounts: { ...allAccounts, [account.id]: account } + } + } default: return state } } -function initialState () { - return { - - } -} - -export const addNewAccount = () => (dispatch, getState) => { - -} diff --git a/src/features/common/components/Layout/Layout.js b/src/features/common/components/Layout/Layout.js index 7a7dc20b..a6a0fd1e 100644 --- a/src/features/common/components/Layout/Layout.js +++ b/src/features/common/components/Layout/Layout.js @@ -1,3 +1,4 @@ +// @flow import React from 'react' import { DBoxLandingPage, SuccessCallback } from '@features/Dropbox/pages' import { @@ -6,7 +7,8 @@ import { import CompStyles from './styles' import Home from '@features/common/pages/Home' -const AppLayout = () => { +/** Main page layout */ +const AppLayout = (): any => { return (
diff --git a/src/features/common/components/Layout/index.js b/src/features/common/components/Layout/index.js index edae7904..5f72e11b 100644 --- a/src/features/common/components/Layout/index.js +++ b/src/features/common/components/Layout/index.js @@ -1,3 +1,2 @@ -import Layout from './Layout' - -export default Layout +// @flow +export { default } from './Layout' diff --git a/src/features/common/components/Layout/styles.js b/src/features/common/components/Layout/styles.js index ecf2746d..c2f94d62 100644 --- a/src/features/common/components/Layout/styles.js +++ b/src/features/common/components/Layout/styles.js @@ -1,3 +1,4 @@ +// @flow import styled from 'styled-components' const CompStyles = styled.div` diff --git a/webpack-config.js b/webpack-config.js index 204242a7..91cf7778 100644 --- a/webpack-config.js +++ b/webpack-config.js @@ -5,6 +5,7 @@ require('dotenv').config() const path = require('path') const _ = require('lodash') const webpack = require('webpack') +const FlowWebpackPlugin = require('flow-webpack-plugin') const LodashModuleReplacementPlugin = require('lodash-webpack-plugin') const alias = require('./alias').resolve.alias @@ -83,6 +84,7 @@ module.exports = (type) => { // eslint-disable-line plugins: _.compact([ isDev && new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), + new FlowWebpackPlugin(), isDist && new LodashModuleReplacementPlugin(), isDist && new webpack.optimize.UglifyJsPlugin(), isDist && new webpack.optimize.AggressiveMergingPlugin(), diff --git a/yarn.lock b/yarn.lock index c211bd79..fc467809 100644 --- a/yarn.lock +++ b/yarn.lock @@ -402,7 +402,7 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.2.0: +ansi-styles@^3.0.0, ansi-styles@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" dependencies: @@ -456,6 +456,10 @@ antd@3.2.1: shallowequal "^1.0.1" warning "~3.0.0" +any-promise@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + anymatch@^1.3.0: version "1.3.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" @@ -610,6 +614,12 @@ assertion-error@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" +ast-pretty-print@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ast-pretty-print/-/ast-pretty-print-1.3.0.tgz#6654e50ee3de665c541fcf038ddbae5097ce8c43" + dependencies: + ansi-styles "^3.0.0" + ast-types-flow@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" @@ -726,7 +736,7 @@ babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: esutils "^2.0.2" js-tokens "^3.0.2" -babel-core@6.26.0, babel-core@^6.26.0: +babel-core@6.26.0, babel-core@^6.24.1, babel-core@^6.25.0, babel-core@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: @@ -750,6 +760,10 @@ babel-core@6.26.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" +babel-errors@^1.0.1, babel-errors@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/babel-errors/-/babel-errors-1.1.1.tgz#43f7142dd3b365633c758d155bffa3ba41523794" + babel-eslint@6.1.2: version "6.1.2" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-6.1.2.tgz#5293419fe3672d66598d327da9694567ba6a5f2f" @@ -771,6 +785,48 @@ babel-eslint@8.2.1: eslint-scope "~3.7.1" eslint-visitor-keys "^1.0.0" +babel-explode-module@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/babel-explode-module/-/babel-explode-module-1.4.0.tgz#b20076f0ee5ff28e8f16baa3146fe136a27c6504" + dependencies: + babel-types "^6.24.1" + +babel-explode-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/babel-explode-module/-/babel-explode-module-2.0.0.tgz#d635653b44b1bdf1d5ceafacafb891611876ce3b" + dependencies: + babel-types "^6.24.1" + +babel-file-loader@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/babel-file-loader/-/babel-file-loader-1.0.3.tgz#b9df875e136d6cddc9dfcb36334cd1ad58fffe7f" + dependencies: + babel-errors "^1.0.1" + babel-file "^1.0.2" + babel-plugin-tester "^3.0.0" + babel-types "^6.24.1" + read-file-async "^1.0.0" + resolve "^1.3.3" + resolve-async "^1.0.1" + +babel-file@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/babel-file/-/babel-file-1.0.2.tgz#6435c01fc79c33365751957156a0561965a29d56" + dependencies: + babel-core "^6.24.1" + babel-errors "^1.0.1" + +babel-flow-identifiers@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/babel-flow-identifiers/-/babel-flow-identifiers-1.1.3.tgz#8ada2633e7afa2cab58892ee2b25b2b6cc4ce598" + dependencies: + babel-flow-scope "^1.2.1" + babel-identifiers "^1.0.0" + +babel-flow-scope@^1.2.0, babel-flow-scope@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/babel-flow-scope/-/babel-flow-scope-1.2.1.tgz#2b646211811a203ef0b11ebd219af29428b15990" + babel-generator@^6.18.0, babel-generator@^6.23.0, babel-generator@^6.26.0: version "6.26.1" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" @@ -934,6 +990,12 @@ babel-helper-replace-supers@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" +babel-helper-simplify-module@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/babel-helper-simplify-module/-/babel-helper-simplify-module-2.2.0.tgz#62ccda7d379992eea9c1141400d1f63cd9918e16" + dependencies: + babel-explode-module "^1.4.0" + babel-helper-to-multiple-sequence-expressions@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/babel-helper-to-multiple-sequence-expressions/-/babel-helper-to-multiple-sequence-expressions-0.2.0.tgz#d1a419634c6cb301f27858c659167cfee0a9d318" @@ -945,6 +1007,10 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" +babel-identifiers@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/babel-identifiers/-/babel-identifiers-1.1.2.tgz#fed5d526c88b1c669ba2dbd1148eaed4357aea42" + babel-loader@7.1.2, babel-loader@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.2.tgz#f6cbe122710f1aa2af4d881c6d5b54358ca24126" @@ -953,6 +1019,13 @@ babel-loader@7.1.2, babel-loader@^7.1.2: loader-utils "^1.0.2" mkdirp "^0.5.1" +babel-log@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/babel-log/-/babel-log-1.0.4.tgz#e3bebf1de68d10e094605392181d290a91876200" + dependencies: + ansi-styles "^3.0.0" + ast-pretty-print "^1.2.0" + babel-messages@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" @@ -1074,6 +1147,20 @@ babel-plugin-react-docgen@^1.8.0: lodash "^4.17.0" react-docgen "^2.20.0" +babel-plugin-react-flow-props-to-prop-types@^0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/babel-plugin-react-flow-props-to-prop-types/-/babel-plugin-react-flow-props-to-prop-types-0.15.0.tgz#0008ecf31bb68f43c11dec57e366f58b73a8acbd" + dependencies: + babel-errors "^1.1.0" + babel-explode-module "^2.0.0" + babel-file-loader "^1.0.1" + babel-flow-identifiers "^1.1.2" + babel-flow-scope "^1.2.0" + babel-helper-simplify-module "^2.2.0" + babel-log "^1.0.3" + babel-react-components "^1.0.1" + babel-types "^6.24.1" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" @@ -1130,6 +1217,17 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" +babel-plugin-tester@^3.0.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-tester/-/babel-plugin-tester-3.3.0.tgz#9844f77a661b48b5c7e08bd54acca590dbcee5b4" + dependencies: + babel-core "^6.25.0" + common-tags "^1.4.0" + invariant "^2.2.2" + lodash.merge "^4.6.0" + path-exists "^3.0.0" + strip-indent "^2.0.0" + babel-plugin-transform-async-generator-functions@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz#f058900145fd3e9907a6ddf28da59f215258a5db" @@ -1634,6 +1732,10 @@ babel-preset-stage-3@^6.24.1: babel-plugin-transform-exponentiation-operator "^6.24.1" babel-plugin-transform-object-rest-spread "^6.22.0" +babel-react-components@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/babel-react-components/-/babel-react-components-1.1.0.tgz#3683490747259ea41cef734ceb9fc6098bc5dcd2" + babel-register@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" @@ -2264,7 +2366,7 @@ commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" -common-tags@^1.6.0: +common-tags@^1.4.0, common-tags@^1.6.0: version "1.7.2" resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.7.2.tgz#24d9768c63d253a56ecff93845b44b4df1d52771" dependencies: @@ -3771,6 +3873,10 @@ flow-bin@0.66.0: version "0.66.0" resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26" +flow-webpack-plugin@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/flow-webpack-plugin/-/flow-webpack-plugin-1.2.0.tgz#1958821d16135028e391cad5ee2f3a4fa78197ec" + flush-write-stream@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.2.tgz#c81b90d8746766f1a609a46809946c45dd8ae417" @@ -6415,6 +6521,12 @@ promise@^7.1.1: dependencies: asap "~2.0.3" +prop-types-extra@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prop-types-extra/-/prop-types-extra-1.0.1.tgz#a57bd4810e82d27a3ff4317ecc1b4ad005f79a82" + dependencies: + warning "^3.0.0" + prop-types@15.6.0, prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.6, prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.5.9, prop-types@^15.6.0: version "15.6.0" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856" @@ -7095,6 +7207,13 @@ react@16.2.0: object-assign "^4.1.1" prop-types "^15.6.0" +read-file-async@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/read-file-async/-/read-file-async-1.0.0.tgz#118fd0b8d0f76dc95cbb658e72ea6f107210deae" + dependencies: + graceful-fs "^4.1.11" + typeable-promisify "^1.0.1" + read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -7441,6 +7560,13 @@ reselect@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147" +resolve-async@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-async/-/resolve-async-1.0.1.tgz#6bf9f26451e9a64a58a13edb82e615ddfcbda86b" + dependencies: + resolve "^1.3.3" + typeable-promisify "^1.0.1" + resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" @@ -7973,6 +8099,10 @@ strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -8235,6 +8365,12 @@ type-is@~1.6.15: media-typer "0.3.0" mime-types "~2.1.18" +typeable-promisify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/typeable-promisify/-/typeable-promisify-1.0.1.tgz#005d43502e7753affccc8af8c05e3ac24f30e617" + dependencies: + any-promise "^1.3.0" + typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"