Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everyone likes to flow these days #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[libs]
./flow-typed

[options]
module.name_mapper='^\(actions\|components\|constants\|containers\|reducers\|store\|test\)\/\(.*\)$' -> '<PROJECT_ROOT>/src/\1/\2'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ dist

# Ignore logs
npm-debug.log

# Ignore flow
flow-typed
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
before_install:
- npm i flow-typed -g
node_js:
- "6"
- "8"
script:
- npm test
- yarn test
after_script:
- npm run eslint
- yarn run eslint
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
environment:
nodejs_version: "6.0"
nodejs_version: "8.0"

install:
- ps: Install-Product node $env:nodejs_version
- npm i flow-typed -g
- npm install

test_script:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"postinstall": "npm run build",
"postinstall": "flow-typed update && npm run build",
"eslint": "eslint .",
"flow": "flow",
"build": "cross-env NODE_ENV=production webpack --config ./webpack.production.js --progress --profile --colors",
"surge": "rm -rf dist && npm run build && cp dist/index.html dist/200.html && surge dist"
},
Expand Down Expand Up @@ -69,6 +70,7 @@
"express": "^4.16.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.3",
"flow-bin": "^0.57.3",
"history": "^4.7.2",
"html-loader": "^0.5.1",
"html-webpack-plugin": "^2.30.1",
Expand Down
8 changes: 7 additions & 1 deletion src/actions/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates


import { APP_LOAD } from 'constants/action-types';

export function loadApp() {
export type LoadApp = {
type: 'APP_LOAD'
}

export function loadApp(): LoadApp {
return {
type: APP_LOAD,
};
Expand Down
9 changes: 9 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions


import type {
LoadApp
} from './app';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './app' import/no-unresolved
Missing file extension for "./app" import/extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './app' import/no-unresolved
Missing file extension for "./app" import/extensions


export type ActionType = LoadApp;

export type Dispatch = (action: ActionType) => void;
4 changes: 3 additions & 1 deletion src/constants/action-types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const APP_LOAD = 'APP_LOAD';
// @flow

export const APP_LOAD: 'APP_LOAD' = 'APP_LOAD';

export default { APP_LOAD };
34 changes: 21 additions & 13 deletions src/containers/app.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-named-as-default
Resolve error: package.json not found in path import/no-named-as-default-member


import React, { Component } from 'react';
import { connect } from 'react-redux';
import { loadApp } from 'actions/app';
import type { MapStateToProps } from 'react-redux';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'react-redux' import/no-unresolved
Missing file extension for "react-redux" import/extensions

import type { Dispatch } from 'actions/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'actions/index' import/no-unresolved
Missing file extension for "actions/index" import/extensions

import type { State } from 'reducers/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'reducers/index' import/no-unresolved
Missing file extension for "reducers/index" import/extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'reducers/index' import/no-unresolved
Missing file extension for "reducers/index" import/extensions

import styles from './app.css';

type Props = {
dispatch: () => void,
type StateProps = {
loaded: boolean
}

export class AppContainer extends Component {
type Props = StateProps & {
dispatch: Dispatch
}

export class AppContainer extends Component<Props> {
componentDidMount() {
this.props.dispatch(loadApp());
}
const { dispatch } = this.props;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'dispatch' is missing in props validation react/prop-types


props: Props;
dispatch(loadApp());
}

render() {
if (!this.props.loaded) {
const { loaded } = this.props;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'loaded' is missing in props validation react/prop-types


if (!loaded) {
return null;
}

Expand All @@ -26,10 +36,8 @@ export class AppContainer extends Component {
}
}

function mapStateToProperties(state) {
return {
loaded: state.app.loaded
};
}
const mapStateToProps: MapStateToProps<State, {}, StateProps> = (state) => ({
loaded: state.app.loaded
});

export default connect(mapStateToProperties)(AppContainer);
export default connect(mapStateToProps)(AppContainer);
2 changes: 2 additions & 0 deletions src/containers/layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path
Resolve error: package.json not found in path import/no-named-as-default
Resolve error: package.json not found in path import/no-named-as-default-member


import React from 'react';

type Props = {
Expand Down
17 changes: 11 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path
Resolve error: package.json not found in path import/no-named-as-default
Resolve error: package.json not found in path import/no-named-as-default-member

import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import store from 'store';
import routes from 'routes';
import store from 'store/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'store/index' import/no-unresolved
Missing file extension for "store/index" import/extensions

import routes from './routes';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './routes' import/no-unresolved
Missing file extension for "./routes" import/extensions


render(
<Provider store={store}>{routes}</Provider>,
document.getElementById('react')
);
const root = document.getElementById('react');

if (root) {
render(
<Provider store={store}>{routes}</Provider>,
root
);
}
16 changes: 12 additions & 4 deletions src/reducers/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path


import type { ActionType } from 'actions/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'actions/index' import/no-unresolved
Missing file extension for "actions/index" import/extensions

import { APP_LOAD } from 'constants/action-types';

const initialState = {
loaded: false,
export type AppState = {
+loaded: boolean
}

const initialState: AppState = {
loaded: false
};

export default function app(state = initialState, action) {
export default function app(state: AppState = initialState, action: ActionType) {
switch (action.type) {
case APP_LOAD:
case APP_LOAD: {
return { ...state, loaded: true };
}
default:
return state;
}
Expand Down
15 changes: 15 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path


import type { Dispatch } from 'actions/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'actions/index' import/no-unresolved
Missing file extension for "actions/index" import/extensions

import type { AppState } from './app';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './app' import/no-unresolved
Missing file extension for "./app" import/extensions


export { default as app } from './app';

export type State = {
+app: AppState
};

export type Store = {
dispatch: Dispatch,
getState: () => State,
subscribe: (listener: () => void) => () => void
};

export default {};
2 changes: 2 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path
Resolve error: package.json not found in path import/no-named-as-default
Resolve error: package.json not found in path import/no-named-as-default-member


import React from 'react';
import { Switch, Route } from 'react-router';
import { ConnectedRouter } from 'connected-react-router';
Expand Down
4 changes: 3 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates
Resolve error: package.json not found in path import/extensions
Resolve error: package.json not found in path import/no-absolute-path


// Create final store using all reducers and applying middleware
import { createBrowserHistory } from 'history';
// Redux utility functions
import { compose, createStore, combineReducers, applyMiddleware } from 'redux';
import { routerMiddleware, connectRouter } from 'connected-react-router';
// Import all reducers
import * as reducers from 'reducers';
import * as reducers from 'reducers/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'reducers/index' import/no-unresolved
Missing file extension for "reducers/index" import/extensions


// Configure reducer to store state at state.router
// You can store it elsewhere by specifying a custom `routerStateSelector`
Expand Down
Loading