diff --git a/.babelrc b/.babelrc index 0b7f2e0e..3f1b07bd 100644 --- a/.babelrc +++ b/.babelrc @@ -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 } diff --git a/.eslintrc b/.eslintrc index 34db16b9..68be79d7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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" ], @@ -19,6 +30,7 @@ "env": { "es6": true, "node": true, - "browser": true + "browser": true, + "mocha": true } } diff --git a/app/client/actions/index.js b/app/client/actions/index.js deleted file mode 100644 index f531c7d5..00000000 --- a/app/client/actions/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import user from './user'; - -export default { - user -}; diff --git a/app/client/main.js b/app/client/main.js index 6fdf973a..3e8748c3 100644 --- a/app/client/main.js +++ b/app/client/main.js @@ -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( diff --git a/app/client/reducers/index.js b/app/client/reducers/index.js deleted file mode 100644 index 54574635..00000000 --- a/app/client/reducers/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import user from './user'; - -export default { - user -}; diff --git a/app/client/store/default.js b/app/client/store/default.js new file mode 100644 index 00000000..0c5e2702 --- /dev/null +++ b/app/client/store/default.js @@ -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); +} diff --git a/app/main.js b/app/main.js index 4aa26693..d06954d3 100644 --- a/app/main.js +++ b/app/main.js @@ -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'); @@ -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}`); + } } }; diff --git a/init.js b/init.js index 377991a4..5e446f8b 100644 --- a/init.js +++ b/init.js @@ -1,3 +1 @@ -var path = require('path'); - require('electron-compile').init(__dirname, './app/main'); diff --git a/package.json b/package.json index a6cc2d9f..7249e87f 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } } diff --git a/scripts/serve.js b/scripts/serve.js index 5282a0ad..e9cc78d0 100644 --- a/scripts/serve.js +++ b/scripts/serve.js @@ -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', @@ -42,7 +42,7 @@ bsync.init({ stdio: 'inherit' }); - proc.on('close', (code) => { + child.on('close', () => { process.exit(); });