Skip to content

Commit b160397

Browse files
committed
chore: prepare for publishing
1 parent 76aeed0 commit b160397

File tree

8 files changed

+553
-388
lines changed

8 files changed

+553
-388
lines changed

.npmignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

__tests__/redux-connect.spec.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('<ReduxAsyncConnect />', function suite() {
5151
routes,
5252
externalState,
5353
remappedProp,
54+
staticContext,
5455
// our param
5556
lunch,
5657
// react-redux dispatch prop
@@ -130,8 +131,12 @@ describe('<ReduxAsyncConnect />', function suite() {
130131
*/
131132

132133
const routes = [
133-
{ path: '/', exact: true, component: WrappedApp, remap: 'on' },
134-
{ path: '/notconnected', component: UnwrappedApp },
134+
{
135+
path: '/', exact: true, component: WrappedApp, remap: 'on',
136+
},
137+
{
138+
path: '/notconnected', component: UnwrappedApp,
139+
},
135140
{
136141
path: '/multi',
137142
component: WrappedAppA,
@@ -155,17 +160,19 @@ describe('<ReduxAsyncConnect />', function suite() {
155160
const helpers = { eat };
156161
const location = { pathname: '/' };
157162

158-
return loadOnServer({ store, location, routes, helpers })
163+
return loadOnServer({
164+
store, location, routes, helpers,
165+
})
159166
.then(() => {
160167
const context = {};
161168

162-
const html = render(
169+
const html = render((
163170
<Provider store={store} key="provider">
164171
<StaticRouter location={location} context={context}>
165172
<ReduxAsyncConnect routes={routes} helpers={helpers} />
166173
</StaticRouter>
167174
</Provider>
168-
);
175+
));
169176

170177
if (context.url) {
171178
throw new Error('redirected');
@@ -197,13 +204,13 @@ describe('<ReduxAsyncConnect />', function suite() {
197204
spy(proto, 'loadAsyncData');
198205
spy(proto, 'componentDidMount');
199206

200-
const wrapper = mount(
207+
const wrapper = mount((
201208
<Provider store={store} key="provider">
202209
<MemoryRouter>
203210
<ReduxAsyncConnect routes={routes} helpers={{ eat }} />
204211
</MemoryRouter>
205212
</Provider>
206-
);
213+
));
207214

208215
expect(proto.loadAsyncData.called).toBe(false);
209216
expect(proto.componentDidMount.calledOnce).toBe(true);
@@ -230,13 +237,13 @@ describe('<ReduxAsyncConnect />', function suite() {
230237
spy(proto, 'loadAsyncData');
231238
spy(proto, 'componentDidMount');
232239

233-
mount(
240+
mount((
234241
<Provider store={store} key="provider">
235242
<MemoryRouter>
236243
<ReduxAsyncConnect routes={routes} helpers={{ eat }} />
237244
</MemoryRouter>
238245
</Provider>
239-
);
246+
));
240247

241248
expect(proto.loadAsyncData.calledOnce).toBe(true);
242249
expect(proto.componentDidMount.calledOnce).toBe(true);
@@ -263,13 +270,13 @@ describe('<ReduxAsyncConnect />', function suite() {
263270
spy(proto, 'loadAsyncData');
264271
spy(proto, 'componentDidMount');
265272

266-
const wrapper = mount(
273+
const wrapper = mount((
267274
<Provider store={store} key="provider">
268275
<MemoryRouter>
269276
<ReduxAsyncConnect routes={routes} helpers={{ eat }} />
270277
</MemoryRouter>
271278
</Provider>
272-
);
279+
));
273280

274281
expect(proto.loadAsyncData.calledOnce).toBe(true);
275282
expect(proto.componentDidMount.calledOnce).toBe(true);
@@ -302,17 +309,19 @@ describe('<ReduxAsyncConnect />', function suite() {
302309
const location = { pathname: '/notconnected' };
303310
const helpers = { eat };
304311

305-
return loadOnServer({ store, location, routes, helpers })
312+
return loadOnServer({
313+
store, location, routes, helpers,
314+
})
306315
.then(() => {
307316
const context = {};
308317

309-
const html = render(
318+
const html = render((
310319
<Provider store={store} key="provider">
311320
<StaticRouter location={location} context={context}>
312321
<ReduxAsyncConnect routes={routes} helpers={helpers} />
313322
</StaticRouter>
314323
</Provider>
315-
);
324+
));
316325

317326
if (context.url) {
318327
throw new Error('redirected');
@@ -342,17 +351,19 @@ describe('<ReduxAsyncConnect />', function suite() {
342351
const location = { pathname: '/multi' };
343352
const helpers = { eat };
344353

345-
return loadOnServer({ store, routes, location, helpers })
354+
return loadOnServer({
355+
store, routes, location, helpers,
356+
})
346357
.then(() => {
347358
const context = {};
348359

349-
const html = render(
360+
const html = render((
350361
<Provider store={store} key="provider">
351362
<StaticRouter location={location} context={context}>
352363
<ReduxAsyncConnect routes={routes} helpers={helpers} />
353364
</StaticRouter>
354365
</Provider>
355-
);
366+
));
356367

357368
if (context.url) {
358369
throw new Error('redirected');
@@ -411,7 +422,9 @@ describe('<ReduxAsyncConnect />', function suite() {
411422
);
412423
*/
413424
const immutableRoutes = [
414-
{ path: '/', exact: true, component: ImmutableWrappedApp, remap: 'on' },
425+
{
426+
path: '/', exact: true, component: ImmutableWrappedApp, remap: 'on',
427+
},
415428
{ path: '/notconnected', component: UnwrappedApp },
416429
];
417430

@@ -426,17 +439,19 @@ describe('<ReduxAsyncConnect />', function suite() {
426439
const helpers = { eat };
427440

428441
// Use the custom immutable routes
429-
return loadOnServer({ store, location, routes: immutableRoutes, helpers })
442+
return loadOnServer({
443+
store, location, routes: immutableRoutes, helpers,
444+
})
430445
.then(() => {
431446
const context = {};
432447

433-
const html = render(
448+
const html = render((
434449
<Provider store={store} key="provider">
435450
<StaticRouter location={location} context={context}>
436451
<ReduxAsyncConnect routes={immutableRoutes} helpers={helpers} />
437452
</StaticRouter>
438453
</Provider>
439-
);
454+
));
440455

441456
if (context.url) {
442457
throw new Error('redirected');

examples/api-redirect-err/src/components/NotFound.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export default class NotFound extends Component {
1515
</div>
1616
);
1717
}
18-
}
18+
}

modules/components/AsyncConnect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getMutableState } from '../helpers/state';
77

88
export class AsyncConnect extends Component {
99
static propTypes = {
10-
render: PropTypes.func.isRequired,
10+
render: PropTypes.func,
1111
beginGlobalLoad: PropTypes.func.isRequired,
1212
endGlobalLoad: PropTypes.func.isRequired,
1313
reloadOnPropsChange: PropTypes.func,

modules/containers/decorator.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import { getMutableState, getImmutableState } from '../helpers/state';
1010
*/
1111
function wrapWithDispatch(asyncItems) {
1212
return asyncItems.map((item) => {
13-
const key = item.key;
14-
if (!key) {
15-
return item;
16-
}
13+
const { key } = item;
14+
if (!key) return item;
1715

1816
return {
1917
...item,

modules/helpers/utils.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ export function isPromise(obj) {
1717
* @return {Promise}
1818
*/
1919
const mapSeries = Promise.mapSeries || function promiseMapSeries(iterable, iterator) {
20-
const length = iterable.length;
20+
const { length } = iterable;
2121
const results = new Array(length);
2222
let i = 0;
2323

24-
return Promise.resolve()
25-
.then(function iterateOverResults() {
26-
return iterator(iterable[i], i, iterable).then((result) => {
27-
results[i] = result;
28-
i += 1;
29-
if (i < length) {
30-
return iterateOverResults();
31-
}
24+
function iterateOverResults() {
25+
return iterator(iterable[i], i, iterable).then((result) => {
26+
results[i] = result;
27+
i += 1;
28+
if (i < length) {
29+
return iterateOverResults();
30+
}
3231

33-
return results;
34-
});
32+
return results;
3533
});
34+
}
35+
36+
return iterateOverResults();
3637
};
3738

3839
/**
@@ -95,7 +96,12 @@ export function filterComponents(branch) {
9596
* @param {Function} [data.filter] - filtering function
9697
* @return {Promise}
9798
*/
98-
export function loadAsyncConnect({ location, routes = [], filter = () => true, ...rest }) {
99+
export function loadAsyncConnect({
100+
location,
101+
routes = [],
102+
filter = () => true,
103+
...rest
104+
}) {
99105
const layered = filterComponents(matchRoutes(routes, location.pathname));
100106

101107
if (layered.length === 0) {
@@ -118,7 +124,12 @@ export function loadAsyncConnect({ location, routes = [], filter = () => true, .
118124
// get array of results
119125
results.push(...asyncItems.reduce((itemsResults, item) => {
120126
if (filter(item, component)) {
121-
let promiseOrResult = item.promise({ ...rest, ...routeParams, location, routes });
127+
let promiseOrResult = item.promise({
128+
...rest,
129+
...routeParams,
130+
location,
131+
routes,
132+
});
122133

123134
if (isPromise(promiseOrResult)) {
124135
promiseOrResult = promiseOrResult.catch(error => ({ error }));

package.json

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"main": "lib/index.js",
66
"repository": {
77
"type": "git",
8-
"url": "git+ssh://git@github.com/makeomatic/redux-connect.git"
8+
"url": "https://github.com/makeomatic/redux-connect"
99
},
1010
"scripts": {
1111
"build": "rm -rf ./lib; NODE_ENV=production babel ./modules -d lib --ignore '__tests__'",
1212
"lint": "eslint ./modules",
13-
"test": "npm run lint && jest",
13+
"pretest": "yarn lint",
14+
"test": "jest",
1415
"postversion": "npm publish && git push && git push --tags",
15-
"prepublish": "npm run lint && npm run build"
16+
"prepublish": "yarn lint && yarn build"
1617
},
1718
"keywords": [
1819
"redux",
@@ -21,7 +22,7 @@
2122
"async",
2223
"props"
2324
],
24-
"author": "Vitaly Aminev <v@makeomatic.ru>",
25+
"author": "Vitaly Aminev <v@makeomatic.ca>",
2526
"contributors": [
2627
"Rodion Salnik (http://brocoders.com)"
2728
],
@@ -40,23 +41,23 @@
4041
"devDependencies": {
4142
"babel-cli": "^6.26.0",
4243
"babel-core": "^6.26.0",
43-
"babel-eslint": "^8.0.1",
44-
"babel-jest": "^21.2.0",
44+
"babel-eslint": "^8.1.2",
45+
"babel-jest": "^22.0.4",
4546
"babel-plugin-transform-runtime": "^6.15.0",
4647
"babel-preset-es2015": "^6.18.0",
4748
"babel-preset-react": "^6.16.0",
4849
"babel-preset-react-optimize": "^1.0.1",
4950
"babel-preset-stage-0": "^6.16.0",
5051
"bluebird": "^3.5.1",
51-
"enzyme": "^3.0.0",
52-
"enzyme-adapter-react-16": "^1.0.0",
53-
"eslint": "^4.8.0",
54-
"eslint-config-airbnb": "^15.1.0",
52+
"enzyme": "^3.3.0",
53+
"enzyme-adapter-react-16": "^1.1.1",
54+
"eslint": "^4.14.0",
55+
"eslint-config-airbnb": "^16.1.0",
5556
"eslint-plugin-import": "^2.7.0",
56-
"eslint-plugin-jsx-a11y": "5.x.x",
57+
"eslint-plugin-jsx-a11y": "6.0.3",
5758
"eslint-plugin-react": "^7.4.0",
5859
"immutable": "^3.8.1",
59-
"jest-cli": "^21.2.1",
60+
"jest-cli": "^22.0.4",
6061
"prop-types": "^15.6.0",
6162
"raf": "^3.3.2",
6263
"react": "^16.0.0",
@@ -67,7 +68,7 @@
6768
"react-test-renderer": "^16.0.0",
6869
"redux": "^3.7.2",
6970
"redux-immutable": "^4.0.0",
70-
"sinon": "^4.0.0"
71+
"sinon": "^4.1.3"
7172
},
7273
"dependencies": {
7374
"babel-runtime": "^6.26.0",
@@ -82,5 +83,9 @@
8283
"setupFiles": [
8384
"raf/polyfill"
8485
]
85-
}
86+
},
87+
"files": [
88+
"modules/",
89+
"lib/"
90+
]
8691
}

0 commit comments

Comments
 (0)