Skip to content

Commit 2ea1059

Browse files
Jordan Schroterpronebird
Jordan Schroter
authored andcommitted
Develop (#13)
* - Add redux-thunk - Move store configuration into separate file - Purge unused redux-devtools-* packages * Enable inline source maps * Remove unused import * Drop eslint-config-airbnb due to unmet peer dependencies See airbnb/javascript#1283 * Update ESLint to use recommended settings and react plugin * Add mocha: true to suppress undefined describe/it functions * - Rename store/configureStore to store/default - Add missing import for redux.compose * Print extension installation errors * - Add --no-ignore flag to suppress warnings for ignored files - Remove --format option * Add scripts to eslint
1 parent 0bf64c2 commit 2ea1059

File tree

10 files changed

+60
-38
lines changed

10 files changed

+60
-38
lines changed

.babelrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"presets": ["es2015", "stage-0", "react"],
3-
"plugins": ["transform-decorators-legacy", "transform-runtime"]
3+
"plugins": ["transform-decorators-legacy", "transform-runtime"],
4+
"sourceMaps": "inline",
5+
"retainLines": true
46
}

.eslintrc

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{
2-
"extends": "eslint-config-airbnb",
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:react/recommended"
5+
],
6+
"parser": "babel-eslint",
7+
"parserOptions": {
8+
"ecmaFeatures": {
9+
"jsx": true,
10+
"modules": true
11+
}
12+
},
13+
"plugins": [ "react" ],
314
"rules": {
415
"indent": [ 2, 2 ],
516
"quotes": [ 2, "single" ],
@@ -19,6 +30,7 @@
1930
"env": {
2031
"es6": true,
2132
"node": true,
22-
"browser": true
33+
"browser": true,
34+
"mocha": true
2335
}
2436
}

app/client/actions/index.js

-5
This file was deleted.

app/client/main.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { compose, createStore, combineReducers } from 'redux';
43
import { Provider } from 'react-redux';
54
import App from './containers/App';
6-
import reducers from './reducers';
7-
import actionCreators from './actions';
5+
import configureStore from './store/default';
86

97
const initialState = {};
10-
11-
const composeEnhancers = (() => {
12-
const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
13-
if(process.env.NODE_ENV === 'development' && compose_) {
14-
return compose_({ actionCreators });
15-
}
16-
return compose;
17-
})();
18-
19-
const store = createStore(combineReducers(reducers), initialState, composeEnhancers());
8+
const store = configureStore(initialState);
209
const rootElement = document.querySelector(document.currentScript.getAttribute('data-container'));
2110

2211
ReactDOM.render(

app/client/reducers/index.js

-5
This file was deleted.

app/client/store/default.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
2+
import thunk from 'redux-thunk';
3+
4+
import user from '../reducers/user';
5+
import userActions from '../actions/user';
6+
7+
const actionCreators = {
8+
...userActions
9+
};
10+
11+
const reducers = {
12+
user
13+
};
14+
15+
const middlewares = [thunk];
16+
17+
const composeEnhancers = (() => {
18+
const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
19+
if(process.env.NODE_ENV === 'development' && compose_) {
20+
return compose_({ actionCreators });
21+
}
22+
return compose;
23+
})();
24+
25+
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
26+
const rootReducer = combineReducers(reducers);
27+
28+
export default function configureStore(initialState) {
29+
return createStore(rootReducer, initialState, enhancer);
30+
}

app/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {app, crashReporter, BrowserWindow, Menu} from 'electron';
21
import path from 'path';
32
import url from 'url';
3+
import {app, crashReporter, BrowserWindow, Menu} from 'electron';
44

55
const isDevelopment = (process.env.NODE_ENV === 'development');
66

@@ -17,7 +17,9 @@ const installExtensions = async () => {
1717
for (const name of extensions) {
1818
try {
1919
await installer.default(installer[name], forceDownload);
20-
} catch (e) {}
20+
} catch (e) {
21+
console.log(`Error installing ${name} extension: ${e.message}`);
22+
}
2123
}
2224
};
2325

init.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
var path = require('path');
2-
31
require('electron-compile').init(__dirname, './app/main');

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"react-dom": "^15.4.2",
1313
"react-redux": "^5.0.2",
1414
"redux": "^3.0.0",
15-
"redux-actions": "^1.2.1"
15+
"redux-actions": "^1.2.1",
16+
"redux-thunk": "^2.2.0"
1617
},
1718
"devDependencies": {
1819
"babel-cli": "^6.22.2",
@@ -30,15 +31,13 @@
3031
"electron-devtools-installer": "^2.1.0",
3132
"electron-packager": "^8.5.1",
3233
"eslint": "^3.14.1",
33-
"eslint-config-airbnb": "^14.0.0",
3434
"eslint-plugin-react": "^6.9.0",
35-
"mocha": "^3.2.0",
36-
"redux-devtools-dock-monitor": "^1.1.1",
37-
"redux-devtools-log-monitor": "^1.2.0"
35+
"mocha": "^3.2.0"
3836
},
3937
"scripts": {
4038
"serve": "babel-node scripts/serve.js",
4139
"pack": "babel-node scripts/pack.js",
42-
"test": "mocha -R spec --compilers js:babel-core/register"
40+
"test": "mocha -R spec --compilers js:babel-core/register",
41+
"lint": "eslint --no-ignore scripts app test *.js"
4342
}
4443
}

scripts/serve.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bsync.init({
3131
}, (err, bs) => {
3232
if (err) return console.error(err);
3333

34-
const proc = spawn(electron, ['.'], {
34+
const child = spawn(electron, ['.'], {
3535
env: {
3636
...{
3737
NODE_ENV: 'development',
@@ -42,7 +42,7 @@ bsync.init({
4242
stdio: 'inherit'
4343
});
4444

45-
proc.on('close', (code) => {
45+
child.on('close', () => {
4646
process.exit();
4747
});
4848

0 commit comments

Comments
 (0)