diff --git a/config/webpack-config/resolvers.js b/config/webpack-config/resolvers.js index 5cabbe85..aed623b4 100644 --- a/config/webpack-config/resolvers.js +++ b/config/webpack-config/resolvers.js @@ -8,5 +8,8 @@ module.exports = { api$: `${paths.srcApp}/api/api.js`, '@': paths.srcApp, styles: `${paths.srcApp}/assets/scss`, + // @link https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977 + 'react-dom$': 'react-dom/profiling', + 'scheduler/tracing': 'scheduler/tracing-profiling', }, }; diff --git a/package.json b/package.json index 0d2113a5..f5ef2eae 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,7 @@ "start": "cross-env NODE_ENV=development node scripts/start.js", "start:analyzer": "webpack-bundle-analyzer build/client/static/bundle-stats.json", "test": "node scripts/test.js --env=jsdom", - "test:update": "yarn test --updateSnapshot", "flow-typed": "node_modules/.bin/flow-typed", - "lint:js": "eslint src/**/*.{js}", "semantic-release": "semantic-release" }, "config": { diff --git a/src/app/components/core/Footer/Footer.js b/src/app/components/core/Footer/Footer.js index 390235c4..ae52d73d 100755 --- a/src/app/components/core/Footer/Footer.js +++ b/src/app/components/core/Footer/Footer.js @@ -3,7 +3,7 @@ import React from 'react'; // $FlowIgnore import { useSelector } from 'react-redux'; -import { getFooter } from '@/store/reducers/footer'; +import { getFooter } from '@/store/modules/footer/selectors'; import type { FooterType } from '@/store/types/FooterType'; import Icon from '@/components/base/Icon/Icon'; diff --git a/src/app/components/core/UserMenu/UserMenu.js b/src/app/components/core/UserMenu/UserMenu.js index 03262f5f..6b8d6f05 100644 --- a/src/app/components/core/UserMenu/UserMenu.js +++ b/src/app/components/core/UserMenu/UserMenu.js @@ -5,7 +5,7 @@ import { useSelector } from 'react-redux'; import Icon from '@/components/base/Icon/Icon'; import { useLazy } from '@/hooks/useLazy'; -import { getCart } from '@/store/reducers/cart'; +import { getCart } from '@/store/modules/cart/selectors'; import type { CartType } from '@/store/types/CartType'; diff --git a/src/app/pages/Home/Home.js b/src/app/pages/Home/Home.js index 3d838206..e1a7cecd 100644 --- a/src/app/pages/Home/Home.js +++ b/src/app/pages/Home/Home.js @@ -4,8 +4,8 @@ import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import Spinner from '@/components/base/Spinner/Spinner'; -import { fetchProducts } from '@/store/actions'; -import { getProducts } from '@/store/selectors/getProducts'; +import { fetchProducts } from '@/store/modules/products/actions'; +import { getProducts } from '@/store/modules/products/selectors'; import type { ProductsType } from '@/store/types/ProductsType'; import ProductCard from '@/components/shared/ProductCard/ProductCard'; diff --git a/src/app/store/actions/index.js b/src/app/store/actions/index.js deleted file mode 100644 index 466a3db4..00000000 --- a/src/app/store/actions/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow strict - -export { fetchProducts } from './fetchProducts'; -export { footerData } from './footerData'; diff --git a/src/app/store/configureStore.js b/src/app/store/config/configureStore.js similarity index 93% rename from src/app/store/configureStore.js rename to src/app/store/config/configureStore.js index d9a19614..e20110f1 100644 --- a/src/app/store/configureStore.js +++ b/src/app/store/config/configureStore.js @@ -8,12 +8,12 @@ import type { Actions } from '@/store/types/Actions'; // import throttle from 'lodash.throttle'; // Middleware is the suggested way to extend Redux with custom functionality. -import middlewares from '@/store/middlewares'; +import middlewares from '@/store/config/middlewares'; // import all reducers import reducer from '@/store/reducers'; -// import { saveState, loadState } from './localStorage'; +// import { saveState, loadState } from './storage'; // Get the state from localStorage // const persistedState = loadState(); diff --git a/src/app/store/middlewares/apiMiddleware/apiMiddleware.js b/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js similarity index 100% rename from src/app/store/middlewares/apiMiddleware/apiMiddleware.js rename to src/app/store/config/middlewares/apiMiddleware/apiMiddleware.js diff --git a/src/app/store/middlewares/apiMiddleware/apiMiddleware.test.js b/src/app/store/config/middlewares/apiMiddleware/apiMiddleware.test.js similarity index 100% rename from src/app/store/middlewares/apiMiddleware/apiMiddleware.test.js rename to src/app/store/config/middlewares/apiMiddleware/apiMiddleware.test.js diff --git a/src/app/store/middlewares/apiMiddleware/index.js b/src/app/store/config/middlewares/apiMiddleware/index.js similarity index 100% rename from src/app/store/middlewares/apiMiddleware/index.js rename to src/app/store/config/middlewares/apiMiddleware/index.js diff --git a/src/app/store/middlewares/index.js b/src/app/store/config/middlewares/index.js similarity index 100% rename from src/app/store/middlewares/index.js rename to src/app/store/config/middlewares/index.js diff --git a/src/app/store/middlewares/logger/index.js b/src/app/store/config/middlewares/logger/index.js similarity index 100% rename from src/app/store/middlewares/logger/index.js rename to src/app/store/config/middlewares/logger/index.js diff --git a/src/app/store/middlewares/logger/logger.js b/src/app/store/config/middlewares/logger/logger.js similarity index 100% rename from src/app/store/middlewares/logger/logger.js rename to src/app/store/config/middlewares/logger/logger.js diff --git a/src/app/store/middlewares/logger/logger.test.js b/src/app/store/config/middlewares/logger/logger.test.js similarity index 100% rename from src/app/store/middlewares/logger/logger.test.js rename to src/app/store/config/middlewares/logger/logger.test.js diff --git a/src/app/store/localStorage.js b/src/app/store/config/storage.js similarity index 100% rename from src/app/store/localStorage.js rename to src/app/store/config/storage.js diff --git a/src/app/store/reducers/createReducer.js b/src/app/store/helpers/createReducer/createReducer.js similarity index 100% rename from src/app/store/reducers/createReducer.js rename to src/app/store/helpers/createReducer/createReducer.js diff --git a/src/app/store/reducers/createReducer.test.js b/src/app/store/helpers/createReducer/createReducer.test.js similarity index 100% rename from src/app/store/reducers/createReducer.test.js rename to src/app/store/helpers/createReducer/createReducer.test.js diff --git a/src/app/store/helpers/createReducer/index.js b/src/app/store/helpers/createReducer/index.js new file mode 100644 index 00000000..6c4a5c71 --- /dev/null +++ b/src/app/store/helpers/createReducer/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as createReducer } from './createReducer'; diff --git a/src/app/store/helpers/makeActionCreator/index.js b/src/app/store/helpers/makeActionCreator/index.js new file mode 100644 index 00000000..0e4bc5fd --- /dev/null +++ b/src/app/store/helpers/makeActionCreator/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as makeActionCreator } from './makeActionCreator'; diff --git a/src/app/store/actions/makeActionCreator.js b/src/app/store/helpers/makeActionCreator/makeActionCreator.js similarity index 100% rename from src/app/store/actions/makeActionCreator.js rename to src/app/store/helpers/makeActionCreator/makeActionCreator.js diff --git a/src/app/store/actions/makeActionCreator.test.js b/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js similarity index 100% rename from src/app/store/actions/makeActionCreator.test.js rename to src/app/store/helpers/makeActionCreator/makeActionCreator.test.js diff --git a/src/app/store/index.js b/src/app/store/index.js index 4964b0c1..934f17c1 100644 --- a/src/app/store/index.js +++ b/src/app/store/index.js @@ -1,6 +1,6 @@ // @flow strict -import configureStore from './configureStore'; +import configureStore from './config/configureStore'; const store = configureStore(); diff --git a/src/app/store/actions/cartAction/cartAction.js b/src/app/store/modules/cart/actions/cartAction.js similarity index 63% rename from src/app/store/actions/cartAction/cartAction.js rename to src/app/store/modules/cart/actions/cartAction.js index ecdfd728..16c910ca 100644 --- a/src/app/store/actions/cartAction/cartAction.js +++ b/src/app/store/modules/cart/actions/cartAction.js @@ -1,6 +1,6 @@ // @flow strict import * as types from '@/store/ActionTypes'; -import makeActionCreator from '@/store/actions/makeActionCreator'; +import { makeActionCreator } from '@/store/helpers/makeActionCreator'; export default makeActionCreator(types.CART_DATA, 'cart'); diff --git a/src/app/store/actions/cartAction/cartAction.test.js b/src/app/store/modules/cart/actions/cartAction.test.js similarity index 100% rename from src/app/store/actions/cartAction/cartAction.test.js rename to src/app/store/modules/cart/actions/cartAction.test.js diff --git a/src/app/store/actions/cartAction/index.js b/src/app/store/modules/cart/actions/index.js similarity index 100% rename from src/app/store/actions/cartAction/index.js rename to src/app/store/modules/cart/actions/index.js diff --git a/src/app/store/reducers/cart/cart.js b/src/app/store/modules/cart/reducers/cart.js similarity index 83% rename from src/app/store/reducers/cart/cart.js rename to src/app/store/modules/cart/reducers/cart.js index ec0e3426..6e866043 100644 --- a/src/app/store/reducers/cart/cart.js +++ b/src/app/store/modules/cart/reducers/cart.js @@ -4,7 +4,7 @@ import type { CartType, CartActionType } from '@/store/types/CartType'; import { CART_DATA } from '@/store/ActionTypes'; -import createReducer from '../createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; const initialState = { quantity: 0, diff --git a/src/app/store/reducers/cart/cart.test.js b/src/app/store/modules/cart/reducers/cart.test.js similarity index 100% rename from src/app/store/reducers/cart/cart.test.js rename to src/app/store/modules/cart/reducers/cart.test.js diff --git a/src/app/store/modules/cart/reducers/index.js b/src/app/store/modules/cart/reducers/index.js new file mode 100644 index 00000000..87116b93 --- /dev/null +++ b/src/app/store/modules/cart/reducers/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as cart } from './cart'; diff --git a/src/app/store/reducers/cart/index.js b/src/app/store/modules/cart/selectors/getCart.js similarity index 67% rename from src/app/store/reducers/cart/index.js rename to src/app/store/modules/cart/selectors/getCart.js index 3e32ec3b..3e84f29a 100644 --- a/src/app/store/reducers/cart/index.js +++ b/src/app/store/modules/cart/selectors/getCart.js @@ -1,9 +1,5 @@ // @flow strict import type { State } from '@/store/types/State'; - -import cart from './cart'; - -export default cart; - +// eslint-disable-next-line import/prefer-default-export export const getCart = (state: State) => state.cart; diff --git a/src/app/store/modules/cart/selectors/index.js b/src/app/store/modules/cart/selectors/index.js new file mode 100644 index 00000000..9796ba6d --- /dev/null +++ b/src/app/store/modules/cart/selectors/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { getCart } from './getCart'; diff --git a/src/app/store/actions/footerData/footerData.js b/src/app/store/modules/footer/actions/footerData.js similarity index 64% rename from src/app/store/actions/footerData/footerData.js rename to src/app/store/modules/footer/actions/footerData.js index 33aee116..71fddd7b 100644 --- a/src/app/store/actions/footerData/footerData.js +++ b/src/app/store/modules/footer/actions/footerData.js @@ -1,6 +1,6 @@ // @flow strict import * as types from '@/store/ActionTypes'; -import makeActionCreator from '@/store/actions/makeActionCreator'; +import { makeActionCreator } from '@/store/helpers/makeActionCreator'; export default makeActionCreator(types.FOOTER_DATA, 'footer'); diff --git a/src/app/store/actions/footerData/footerData.test.js b/src/app/store/modules/footer/actions/footerData.test.js similarity index 100% rename from src/app/store/actions/footerData/footerData.test.js rename to src/app/store/modules/footer/actions/footerData.test.js diff --git a/src/app/store/actions/footerData/index.js b/src/app/store/modules/footer/actions/index.js similarity index 100% rename from src/app/store/actions/footerData/index.js rename to src/app/store/modules/footer/actions/index.js diff --git a/src/app/store/reducers/footer/footer.js b/src/app/store/modules/footer/reducers/footer.js similarity index 72% rename from src/app/store/reducers/footer/footer.js rename to src/app/store/modules/footer/reducers/footer.js index 790202b6..73f849c3 100644 --- a/src/app/store/reducers/footer/footer.js +++ b/src/app/store/modules/footer/reducers/footer.js @@ -3,9 +3,8 @@ import type { FooterType, FooterActionType } from '@/store/types/FooterType'; import { FOOTER_DATA } from '@/store/ActionTypes'; -import type { State } from '@/store/types/State'; -import createReducer from '../createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; const initialState = { social: [ @@ -20,5 +19,3 @@ export default createReducer(initialState, { }; }, }); - -export const getFooter = ({ footer }: State) => footer; diff --git a/src/app/store/reducers/footer/footer.test.js b/src/app/store/modules/footer/reducers/footer.test.js similarity index 100% rename from src/app/store/reducers/footer/footer.test.js rename to src/app/store/modules/footer/reducers/footer.test.js diff --git a/src/app/store/modules/footer/reducers/index.js b/src/app/store/modules/footer/reducers/index.js new file mode 100644 index 00000000..43ad8f8b --- /dev/null +++ b/src/app/store/modules/footer/reducers/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { default as footer } from './footer'; diff --git a/src/app/store/reducers/footer/index.js b/src/app/store/modules/footer/selectors/getFooter.js similarity index 68% rename from src/app/store/reducers/footer/index.js rename to src/app/store/modules/footer/selectors/getFooter.js index dada2c50..d20f5760 100644 --- a/src/app/store/reducers/footer/index.js +++ b/src/app/store/modules/footer/selectors/getFooter.js @@ -1,9 +1,5 @@ // @flow strict import type { State } from '@/store/types/State'; - -import footer from './footer'; - -export default footer; - +// eslint-disable-next-line import/prefer-default-export export const getFooter = (state: State) => state.footer; diff --git a/src/app/store/modules/footer/selectors/index.js b/src/app/store/modules/footer/selectors/index.js new file mode 100644 index 00000000..c3c80af3 --- /dev/null +++ b/src/app/store/modules/footer/selectors/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { getFooter } from './getFooter'; diff --git a/src/app/store/actions/fetchProducts/fetchProducts.js b/src/app/store/modules/products/actions/fetchProducts.js similarity index 92% rename from src/app/store/actions/fetchProducts/fetchProducts.js rename to src/app/store/modules/products/actions/fetchProducts.js index 987ac466..9d8971aa 100644 --- a/src/app/store/actions/fetchProducts/fetchProducts.js +++ b/src/app/store/modules/products/actions/fetchProducts.js @@ -8,7 +8,7 @@ import type { State } from '@/store/types/State'; import type { AsyncAction } from '@/store/types/Actions'; import type { ProductsType } from '@/store/types/ProductsType'; -import { getProducts } from '@/store/selectors/getProducts'; +import { getProducts } from '@/store/modules/products/selectors'; export default function fetchProducts(query: string = ''): AsyncAction { return { diff --git a/src/app/store/actions/fetchProducts/fetchProducts.test.js b/src/app/store/modules/products/actions/fetchProducts.test.js similarity index 100% rename from src/app/store/actions/fetchProducts/fetchProducts.test.js rename to src/app/store/modules/products/actions/fetchProducts.test.js diff --git a/src/app/store/actions/fetchProducts/index.js b/src/app/store/modules/products/actions/index.js similarity index 100% rename from src/app/store/actions/fetchProducts/index.js rename to src/app/store/modules/products/actions/index.js diff --git a/src/app/store/reducers/products/index.js b/src/app/store/modules/products/reducers/index.js similarity index 100% rename from src/app/store/reducers/products/index.js rename to src/app/store/modules/products/reducers/index.js diff --git a/src/app/store/reducers/products/products.js b/src/app/store/modules/products/reducers/products.js similarity index 89% rename from src/app/store/reducers/products/products.js rename to src/app/store/modules/products/reducers/products.js index 0c798959..997ed916 100644 --- a/src/app/store/reducers/products/products.js +++ b/src/app/store/modules/products/reducers/products.js @@ -1,13 +1,13 @@ // @flow strict import type { ProductsType, ProductActionType } from '@/store/types/ProductsType'; -import createReducer from '../createReducer'; +import { createReducer } from '@/store/helpers/createReducer'; import { GET_PRODUCTS_FAILURE, GET_PRODUCTS_REQUEST, GET_PRODUCTS_SUCCESS, -} from '../../ActionTypes'; +} from '@/store/ActionTypes'; const initialState = { error: null, diff --git a/src/app/store/reducers/products/products.test.js b/src/app/store/modules/products/reducers/products.test.js similarity index 100% rename from src/app/store/reducers/products/products.test.js rename to src/app/store/modules/products/reducers/products.test.js diff --git a/src/app/store/selectors/getProducts.js b/src/app/store/modules/products/selectors/getProducts.js similarity index 100% rename from src/app/store/selectors/getProducts.js rename to src/app/store/modules/products/selectors/getProducts.js diff --git a/src/app/store/modules/products/selectors/index.js b/src/app/store/modules/products/selectors/index.js new file mode 100644 index 00000000..9b035d52 --- /dev/null +++ b/src/app/store/modules/products/selectors/index.js @@ -0,0 +1,3 @@ +// @flow strict +// eslint-disable-next-line import/prefer-default-export +export { getProducts } from './getProducts'; diff --git a/src/app/store/reducers/index.js b/src/app/store/reducers/index.js index 4c7c91aa..9bb6be95 100644 --- a/src/app/store/reducers/index.js +++ b/src/app/store/reducers/index.js @@ -1,15 +1,12 @@ // @flow strict -/** - * @module reducers - */ import { combineReducers } from 'redux'; import type { Actions } from '@/store/types/Actions'; -import cart from './cart'; -import footer from './footer'; -import { products } from './products'; +import { footer } from '@/store/modules/footer/reducers'; +import { cart } from '@/store/modules/cart/reducers'; +import { products } from '@/store/modules/products/reducers'; export default combineReducers<{}, Actions>({ cart, diff --git a/src/app/store/types/Actions.js b/src/app/store/types/Actions.js index ba8464c9..6596bdc3 100644 --- a/src/app/store/types/Actions.js +++ b/src/app/store/types/Actions.js @@ -18,5 +18,5 @@ export type AsyncAction = { export type MiddlewareAction = { type: string, - ...AsyncAction + ...$Exact> };