Skip to content

Commit

Permalink
husky
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lkan committed Jan 9, 2018
1 parent 6abc019 commit 808a3b7
Show file tree
Hide file tree
Showing 3 changed files with 450 additions and 29 deletions.
28 changes: 17 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ import { identity } from 'delgado';
import { connect as reduxConnect } from 'react-redux';
import { bindActionCreators } from 'redux';

const ensureReducer = (reducer: ?Fn): Reducer => reducer ? reducer : identity;
const ensureReducer = (reducer: ?Fn): Reducer => (reducer ? reducer : identity);

const createRootReducer = (getInitialState: Fn, reducers: { [string]: Fn }) =>
(state: any = getInitialState(), action: {type:string}) => {
if (process.env.NODE_ENV !== 'production') {
log(state, action);
}
const createRootReducer = (getInitialState: Fn, reducers: { [string]: Fn }) => (
state: any = getInitialState(),
action: { type: string }
) => {
if (process.env.NODE_ENV !== 'production') {
log(state, action);
}

return ensureReducer(reducers[action.type])(state, action);
return ensureReducer(reducers[action.type])(state, action);
};

const connect = (componentConstructor: React.Node, actions: any = {}, mapStateToProps: Fn = identity) => reduxConnect(
mapStateToProps,
(dispatch) => bindActionCreators({ ...actions }, dispatch)
)(componentConstructor);
const connect = (
componentConstructor: React.Node,
actions: any = {},
mapStateToProps: Fn = identity
) =>
reduxConnect(mapStateToProps, dispatch =>
bindActionCreators({ ...actions }, dispatch)
)(componentConstructor);

export { connect, createRootReducer };
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
"precommit": "bin/precommit.sh"
},
"lint-staged": {
"*.{js,json,css,sass,scss,md}": [
"prettier --write",
"git add"
]
"*.{js,json,css,sass,scss,md}": ["prettier --write", "git add"]
},
"files": [
"lib/",
"index.js"
],
"files": ["lib/", "index.js"],
"keywords": [
"byte",
"byte-sized javascript",
Expand Down Expand Up @@ -58,6 +52,8 @@
"eslint-loader": "^1.9.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-react": "^7.5.1",
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"prettier": "^1.9.2",
"react-redux": "^5.0.6",
"redux": "^3.7.2"
Expand Down
Loading

0 comments on commit 808a3b7

Please sign in to comment.