Skip to content
This repository was archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Formatting and fix lint-staged
Browse files Browse the repository at this point in the history
tptee committed Jan 30, 2018
1 parent 46efe10 commit e9c60dd
Showing 5 changed files with 30 additions and 12 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -20,4 +20,3 @@ esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
suppress_comment= \\(.\\|\n\\)*\\$FlowIssue
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
"jsnext:main": "es/index.js",
"scripts": {
"preversion": "npm run check",
"precommit": "lint-staged",
"version": "npm run clean && npm run build",
"demo":
"webpack-dev-server --port 3000 --config config/webpack/demo/webpack.config.demo.dev.js --colors",
@@ -148,6 +149,6 @@
"instrument": false
},
"lint-staged": {
"*.js": ["prettier --single-quote --write", "git add"]
"*.js": ["prettier --write", "git add"]
}
}
26 changes: 19 additions & 7 deletions src/components/fragment.js
Original file line number Diff line number Diff line change
@@ -29,9 +29,12 @@ const withId = ComposedComponent =>
};

const resolveChildRoute = (parentRoute, currentRoute) => {
const parentIsRootRoute = parentRoute && parentRoute !== '/' && parentRoute !== currentRoute;
const parentIsRootRoute =
parentRoute && parentRoute !== '/' && parentRoute !== currentRoute;

return parentIsRootRoute ? `${parentRoute}${currentRoute || ''}` : currentRoute;
return parentIsRootRoute
? `${parentRoute}${currentRoute || ''}`
: currentRoute;
};

const resolveCurrentRoute = (parentRoute, currentRoute) => {
@@ -55,21 +58,29 @@ const resolveCurrentRoute = (parentRoute, currentRoute) => {
// <Fragment forRoute='/'>
// </Fragment>
// </Fragment>
const routeSuffix = currentIsRootRoute && !parentIsRootRoute ? '' : currentRoute;
const routeSuffix =
currentIsRootRoute && !parentIsRootRoute ? '' : currentRoute;

const wildcard = currentIsRootRoute && parentIsRootRoute ? '' : '*';

return `${routePrefix}${routeSuffix}${wildcard}`;
};

const shouldShowFragment = ({ forRoute, withConditions, matcher, location }) => {
const shouldShowFragment = ({
forRoute,
withConditions,
matcher,
location
}) => {
if (!forRoute) {
return withConditions && withConditions(location);
}

const matchesRoute = matcher && matcher.match(location.pathname);

return withConditions ? matchesRoute && withConditions(location) : matchesRoute;
return withConditions
? matchesRoute && withConditions(location)
: matchesRoute;
};

type Props = {
@@ -145,7 +156,6 @@ export class FragmentComponent extends Component<*> {
}
}

// $FlowFixMe
export const withIdAndContext = compose(
getContext({
parentRoute: PropTypes.string,
@@ -168,4 +178,6 @@ const mapStateToProps: MapStateToProps<*, *, *> = state => ({
location: state.router
});

export default compose(connect(mapStateToProps), withIdAndContext)(FragmentComponent);
export default compose(connect(mapStateToProps), withIdAndContext)(
FragmentComponent
);
4 changes: 3 additions & 1 deletion src/immutable/components/fragment.js
Original file line number Diff line number Diff line change
@@ -11,4 +11,6 @@ const mapStateToProps: MapStateToProps<*, *, *> = state => ({
});

// $FlowFixMe
export default compose(connect(mapStateToProps), withIdAndContext, propsToJS)(FragmentComponent);
export default compose(connect(mapStateToProps), withIdAndContext, propsToJS)(
FragmentComponent
);
8 changes: 6 additions & 2 deletions src/immutable/components/props-to-js.js
Original file line number Diff line number Diff line change
@@ -4,11 +4,15 @@ import type { Component } from 'react';
import React from 'react';
import { isImmutable } from '../util/immutable';

export default <P: Object>(WrappedComponent: Class<Component<*>>) => (wrappedProps: P) => {
export default <P: Object>(WrappedComponent: Class<Component<*>>) => (
wrappedProps: P
) => {
const propsJS = Object.keys(wrappedProps).reduce(
(props, key) => ({
...props,
[key]: isImmutable(wrappedProps[key]) ? wrappedProps[key].toJS() : wrappedProps[key]
[key]: isImmutable(wrappedProps[key])
? wrappedProps[key].toJS()
: wrappedProps[key]
}),
{}
);

0 comments on commit e9c60dd

Please sign in to comment.