Skip to content

Commit

Permalink
Develop (#13)
Browse files Browse the repository at this point in the history
* - 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
  • Loading branch information
Jordan Schroter authored and pronebird committed Jan 31, 2017
1 parent 0bf64c2 commit 2ea1059
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-decorators-legacy", "transform-runtime"]
"plugins": ["transform-decorators-legacy", "transform-runtime"],
"sourceMaps": "inline",
"retainLines": true
}
16 changes: 14 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"extends": "eslint-config-airbnb",
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"plugins": [ "react" ],
"rules": {
"indent": [ 2, 2 ],
"quotes": [ 2, "single" ],
Expand All @@ -19,6 +30,7 @@
"env": {
"es6": true,
"node": true,
"browser": true
"browser": true,
"mocha": true
}
}
5 changes: 0 additions & 5 deletions app/client/actions/index.js

This file was deleted.

15 changes: 2 additions & 13 deletions app/client/main.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { compose, createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import App from './containers/App';
import reducers from './reducers';
import actionCreators from './actions';
import configureStore from './store/default';

const initialState = {};

const composeEnhancers = (() => {
const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
if(process.env.NODE_ENV === 'development' && compose_) {
return compose_({ actionCreators });
}
return compose;
})();

const store = createStore(combineReducers(reducers), initialState, composeEnhancers());
const store = configureStore(initialState);
const rootElement = document.querySelector(document.currentScript.getAttribute('data-container'));

ReactDOM.render(
Expand Down
5 changes: 0 additions & 5 deletions app/client/reducers/index.js

This file was deleted.

30 changes: 30 additions & 0 deletions app/client/store/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import thunk from 'redux-thunk';

import user from '../reducers/user';
import userActions from '../actions/user';

const actionCreators = {
...userActions
};

const reducers = {
user
};

const middlewares = [thunk];

const composeEnhancers = (() => {
const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
if(process.env.NODE_ENV === 'development' && compose_) {
return compose_({ actionCreators });
}
return compose;
})();

const enhancer = composeEnhancers(applyMiddleware(...middlewares));
const rootReducer = combineReducers(reducers);

export default function configureStore(initialState) {
return createStore(rootReducer, initialState, enhancer);
}
6 changes: 4 additions & 2 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {app, crashReporter, BrowserWindow, Menu} from 'electron';
import path from 'path';
import url from 'url';
import {app, crashReporter, BrowserWindow, Menu} from 'electron';

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

Expand All @@ -17,7 +17,9 @@ const installExtensions = async () => {
for (const name of extensions) {
try {
await installer.default(installer[name], forceDownload);
} catch (e) {}
} catch (e) {
console.log(`Error installing ${name} extension: ${e.message}`);
}
}
};

Expand Down
2 changes: 0 additions & 2 deletions init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
var path = require('path');

require('electron-compile').init(__dirname, './app/main');
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"react-dom": "^15.4.2",
"react-redux": "^5.0.2",
"redux": "^3.0.0",
"redux-actions": "^1.2.1"
"redux-actions": "^1.2.1",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-cli": "^6.22.2",
Expand All @@ -30,15 +31,13 @@
"electron-devtools-installer": "^2.1.0",
"electron-packager": "^8.5.1",
"eslint": "^3.14.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-react": "^6.9.0",
"mocha": "^3.2.0",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.2.0"
"mocha": "^3.2.0"
},
"scripts": {
"serve": "babel-node scripts/serve.js",
"pack": "babel-node scripts/pack.js",
"test": "mocha -R spec --compilers js:babel-core/register"
"test": "mocha -R spec --compilers js:babel-core/register",
"lint": "eslint --no-ignore scripts app test *.js"
}
}
4 changes: 2 additions & 2 deletions scripts/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bsync.init({
}, (err, bs) => {
if (err) return console.error(err);

const proc = spawn(electron, ['.'], {
const child = spawn(electron, ['.'], {
env: {
...{
NODE_ENV: 'development',
Expand All @@ -42,7 +42,7 @@ bsync.init({
stdio: 'inherit'
});

proc.on('close', (code) => {
child.on('close', () => {
process.exit();
});

Expand Down

0 comments on commit 2ea1059

Please sign in to comment.