From f6784a3d2db72993cda63328b6beb413aab6d250 Mon Sep 17 00:00:00 2001 From: Simo Jokela Date: Wed, 22 May 2019 11:01:02 +0300 Subject: [PATCH 1/3] Add new folders, move index.js and routes.js into it, and modify webpack configs to support having both old and new folder structure side by side. --- config/webpack.development.js | 6 ++--- config/webpack.production.js | 4 ++-- src/common/.empty | 0 src/domain/.empty | 0 {app => src}/index.js | 30 +++++++++++++------------ src/routes.js | 41 +++++++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 src/common/.empty create mode 100644 src/domain/.empty rename {app => src}/index.js (57%) create mode 100644 src/routes.js diff --git a/config/webpack.development.js b/config/webpack.development.js index 6b1f95cf9..b629cb891 100755 --- a/config/webpack.development.js +++ b/config/webpack.development.js @@ -13,7 +13,7 @@ module.exports = merge(common, { entry: [ '@babel/polyfill', 'webpack-hot-middleware/client', - path.resolve(__dirname, '../app/index.js'), + path.resolve(__dirname, '../src/index.js'), ], devtool: 'source-map', output: { @@ -26,7 +26,7 @@ module.exports = merge(common, { { enforce: 'pre', test: /\.(js|jsx)$/, - include: path.resolve(__dirname, '../app'), + include: [path.resolve(__dirname, '../app'), path.resolve(__dirname, '../src')], loader: 'eslint-loader', options: { configFile: path.resolve(__dirname, '../.eslintrc'), @@ -35,7 +35,7 @@ module.exports = merge(common, { }, { test: /\.(js|jsx)$/, - include: path.resolve(__dirname, '../app'), + include: [path.resolve(__dirname, '../app'), path.resolve(__dirname, '../src')], exclude: path.resolve(__dirname, '../node_modules'), options: { presets: ['@babel/preset-env', '@babel/preset-react'], diff --git a/config/webpack.production.js b/config/webpack.production.js index 50acfdbf0..f2b05f4bf 100755 --- a/config/webpack.production.js +++ b/config/webpack.production.js @@ -11,7 +11,7 @@ const autoprefixer = require('autoprefixer'); const common = require('./webpack.common'); module.exports = merge(common, { - entry: ['@babel/polyfill', path.resolve(__dirname, '../app/index.js')], + entry: ['@babel/polyfill', path.resolve(__dirname, '../src/index.js')], devtool: 'source-map', mode: 'production', output: { @@ -23,7 +23,7 @@ module.exports = merge(common, { rules: [ { test: /^(?!.*\.spec\.js$).*\.js$/, - include: path.resolve(__dirname, '../app'), + include: [path.resolve(__dirname, '../app'), path.resolve(__dirname, '../src')], loader: 'babel-loader', options: { presets: ['@babel/preset-env', '@babel/preset-react'], diff --git a/src/common/.empty b/src/common/.empty new file mode 100644 index 000000000..e69de29bb diff --git a/src/domain/.empty b/src/domain/.empty new file mode 100644 index 000000000..e69de29bb diff --git a/app/index.js b/src/index.js similarity index 57% rename from app/index.js rename to src/index.js index 18ad32e50..6174d0814 100644 --- a/app/index.js +++ b/src/index.js @@ -8,14 +8,14 @@ import { BrowserRouter as Router } from 'react-router-dom'; import { createStore } from 'redux'; import Immutable from 'seamless-immutable'; -import 'assets/styles/main.scss'; -import 'assets/styles/customization/espoo/customization.scss'; -import 'assets/styles/customization/vantaa/customization.scss'; -import { initI18n } from 'i18n'; -import configureStore from 'store/configureStore'; -import rootReducer from 'state/rootReducer'; +import '../app/assets/styles/main.scss'; +import '../app/assets/styles/customization/espoo/customization.scss'; +import '../app/assets/styles/customization/vantaa/customization.scss'; +import { initI18n } from '../app/i18n'; +import configureStore from '../app/store/configureStore'; +import rootReducer from '../app/state/rootReducer'; import getRoutes from './routes'; -import BrowserWarning from './pages/browser-warning'; +import BrowserWarning from '../app/pages/browser-warning'; const initialStoreState = createStore(rootReducer, {}).getState(); const initialServerState = window.INITIAL_STATE; @@ -27,10 +27,12 @@ const store = configureStore(finalState); const isIEBrowser = browserName === 'IE'; // TODO: Support IE11 in the future. -render(isIEBrowser ? - : ( - - {getRoutes()} - - ), -document.getElementById('root')); +render( + isIEBrowser ? + : ( + + {getRoutes()} + + ), + document.getElementById('root') +); diff --git a/src/routes.js b/src/routes.js new file mode 100644 index 000000000..46f52375e --- /dev/null +++ b/src/routes.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { Switch, Redirect } from 'react-router-dom'; + +import Route from '../app/shared/route'; +import PrivateRoute from '../app/shared/private-route'; +import AppContainer from '../app/pages/AppContainer'; +import AboutPage from '../app/pages/about'; +import AdminResourcesPage from '../app/pages/admin-resources'; +import HomePage from '../app/pages/home'; +import NotFoundPage from '../app/pages/not-found'; +import ReservationPage from '../app/pages/reservation'; +import ResourcePage from '../app/pages/resource'; +import SearchPage from '../app/pages/search'; +import UserReservationsPage from '../app/pages/user-reservations'; + +export default () => ( + + + + + + + + + + + + + + + + +); From 03cb4797d8d5ece9b8e9b895053f277b4de43917 Mon Sep 17 00:00:00 2001 From: Simo Jokela Date: Wed, 22 May 2019 11:56:58 +0300 Subject: [PATCH 2/3] Update eslint config --- .eslintrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 52055f849..809ded2bc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -41,6 +41,10 @@ } ], + "no-debugger": "warn", + + "no-unused-vars": "warn", + "import/prefer-default-export": "off", "new-cap": ["error", { "capIsNew": false, "newIsCap": true }], @@ -87,4 +91,4 @@ "comma-dangle": "off" } -} \ No newline at end of file +} From 192ac86c1a7ad89dc75e6d5c56dd67a1a92fca83 Mon Sep 17 00:00:00 2001 From: Simo Jokela Date: Thu, 23 May 2019 11:32:18 +0300 Subject: [PATCH 3/3] Remove routes.js from under old folder structure. --- app/routes.js | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 app/routes.js diff --git a/app/routes.js b/app/routes.js deleted file mode 100644 index 5322bde34..000000000 --- a/app/routes.js +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import { Switch, Redirect } from 'react-router-dom'; - -import Route from 'shared/route'; -import PrivateRoute from 'shared/private-route'; -import AppContainer from 'pages/AppContainer'; -import AboutPage from 'pages/about'; -import AdminResourcesPage from 'pages/admin-resources'; -import HomePage from 'pages/home'; -import NotFoundPage from 'pages/not-found'; -import ReservationPage from 'pages/reservation'; -import ResourcePage from 'pages/resource'; -import SearchPage from 'pages/search'; -import UserReservationsPage from 'pages/user-reservations'; - -export default () => ( - - - - - - - - - - - - - - - - -);