Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
htdangkhoa committed Jun 5, 2020
2 parents 8445a7a + 9077ca0 commit b10280e
Show file tree
Hide file tree
Showing 14 changed files with 4,379 additions and 4,199 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"no-underscore-dangle": "warn",
"import/prefer-default-export": "off",
"import/no-cycle": "off",
"import/no-unresolved": "off",
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
}
}
26 changes: 24 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[ignore]
tests
node_modules

[include]

Expand All @@ -8,15 +10,35 @@ src/types/globals.js
[lints]

[options]
suppress_comment= \\(.\\|\n\\)*\\@flow-disabled

esproposal.optional_chaining=enable
esproposal.decorators=ignore
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src
module.system.node.resolve_dirname=src/client

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.woff
module.file_ext=.woff2
module.file_ext=.ttf
module.file_ext=.eot
module.file_ext=.svg
module.file_ext=.gif
module.file_ext=.png
module.file_ext=.jpg
module.file_ext=.jpeg
module.file_ext=.webp
module.file_ext=.css
module.file_ext=.scss
module.file_ext=.sass

module.name_mapper='^pages\/\(.*\)$' -> '<PROJECT_ROOT>/src/client/pages/\1'
module.name_mapper='^components\/\(.*\)$' -> '<PROJECT_ROOT>/src/client/components/\1'
module.name_mapper='^assets\/\(.*\)$' -> '<PROJECT_ROOT>/src/client/assets/\1'
module.name_mapper='^utils\/\(.*\)$' -> '<PROJECT_ROOT>/src/utils/\1'
module.name_mapper='^types\/\(.*\)$' -> '<PROJECT_ROOT>/src/types/\1'
module.name_mapper='^models\/\(.*\)$' -> '<PROJECT_ROOT>/src/models/\1'
module.name_mapper='^store\/\(.*\)$' -> '<PROJECT_ROOT>/src/store/\1'

[strict]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ stats.json

__snapshots__/

.vscode/settings.json

public/*
!public/assets
!public/locales
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<img src='https://david-dm.org/htdangkhoa/erb/dev-status.svg' alt='devDependency status' />
</a>

<a href='https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base'>
<img src='https://img.shields.io/badge/ESLint-airbnb-4B32C3.svg' alt='ESLint: airbnb-base' />
</a>

<a href='https://github.com/prettier/prettier'>
<img src='https://img.shields.io/badge/code_style-prettier-ff69b4.svg' alt='code style: prettier' />
</a>
Expand Down Expand Up @@ -156,7 +160,7 @@ $ yarn build

---

> **NOTE**: You can change environment variables in `.env.development` for Development mode or `.env.production` for Production mode.
> **NOTE**: You can change environment variables in `.env-cmdrc.json` file.
## Scripts

Expand Down
174 changes: 94 additions & 80 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "express-react-boilerplate",
"description": "Express react boilerplate",
"version": "3.0.0",
"description": "Express react boilerplate",
"main": "dist/index.js",
"license": "MIT",
"author": "htdangkhoa <huynhtran.dangkhoa@gmail.com> (https://github.com/htdangkhoa)",
Expand Down Expand Up @@ -39,26 +39,37 @@
"progressive web app",
"offline"
],
"homepage": "https://github.com/htdangkhoa/erb",
"bugs": {
"url": "https://github.com/htdangkhoa/erb/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/htdangkhoa/erb.git"
},
"license": "MIT",
"author": "htdangkhoa <huynhtran.dangkhoa@gmail.com> (https://github.com/htdangkhoa)",
"contributors": [
"huynhtran.dangkhoa@gmail.com"
],
"main": "dist/index.js",
"bin": {
"erb-gen": "./bin/index.js"
},
"scripts": {
"start": "env-cmd -e production node dist/index.js",
"dev": "env-cmd -e development nodemon --inspect=0.0.0.0:58585 src/index.js --exec babel-node",
"build": "BABEL_ENV=production babel --minified --no-comments src -D -d dist && npm run wp",
"preanalyze": "npm run stats",
"analyze": "webpack-bundle-analyzer stats.json",
"prebuild": "del dist",
"build": "BABEL_ENV=production babel --minified --no-comments src -D -d dist && npm run wp",
"postbuild": "del dist/**/__tests__",
"wp": "env-cmd -e production babel-node ./node_modules/.bin/webpack --config src/tools/webpack.config.js --progress --colors --bail",
"prewp": "npm run clean",
"clean": "del \"public/*\" \"!public/assets\" \"!public/locales\" \"!public/robots.txt\" \"!public/googledb37d62693032295.html\"",
"dev": "env-cmd -e development nodemon --trace-warnings --inspect=0.0.0.0:58585 src/index.js --exec babel-node",
"start": "env-cmd -e production node dist/index.js",
"stats": "env-cmd -e production babel-node ./node_modules/.bin/webpack --config src/tools/webpack.config.js --progress --colors --bail --json > stats.json",
"analyze": "webpack-bundle-analyzer stats.json",
"preanalyze": "npm run stats",
"storybook": "start-storybook --ci",
"test": "jest -u",
"clean": "del \"public/*\" \"!public/assets\" \"!public/locales\" \"!public/robots.txt\" \"!public/googledb37d62693032295.html\""
},
"engines": {
"node": ">=10.13.0"
"prewp": "npm run clean",
"wp": "env-cmd -e production babel-node ./node_modules/.bin/webpack --config src/tools/webpack.config.js --progress --colors --bail"
},
"nodemonConfig": {
"ignore": [
Expand All @@ -68,15 +79,6 @@
"src/store"
]
},
"jest": {
"moduleNameMapper": {
"\\.(css|less|scss|sss|styl)$": "<rootDir>/src/tools/jest/styles-mock.js",
".*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/tools/jest/assets-mock.js"
},
"globals": {
"__DEV__": false
}
},
"browserslist": {
"production": [
"ie 11",
Expand All @@ -91,60 +93,14 @@
"last 1 safari version"
]
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.2.2",
"@babel/node": "^7.6.3",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.7.4",
"@babel/plugin-transform-spread": "^7.6.2",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.6.3",
"@babel/runtime": "^7.6.3",
"@loadable/babel-plugin": "^5.11.0",
"@loadable/webpack-plugin": "^5.7.1",
"@storybook/react": "^5.2.8",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-module-resolver": "^4.0.0",
"compression-webpack-plugin": "^3.0.0",
"css-loader": "^3.2.0",
"del-cli": "^3.0.0",
"eslint": "^6.5.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.5.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-plugin-flowtype": "^4.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^23.1.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"flow-bin": "^0.121.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"imagemin-webpack-plugin": "^2.4.2",
"jest": "^25.1.0",
"jest-css-modules": "^2.1.0",
"lodash-webpack-plugin": "^0.11.5",
"mini-css-extract-plugin": "^0.9.0",
"nodemon": "^2.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss": "^7.0.25",
"postcss-loader": "^3.0.0",
"prettier": "^2.0.2",
"react-test-renderer": "^16.12.0",
"sass-loader": "^8.0.0",
"terser-webpack-plugin": "^2.2.1",
"url-loader": "^4.0.0",
"webpack": "^4.29.0",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.2.1",
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0",
"webpack-pwa-manifest": "^4.2.0",
"webpackbar": "^4.0.0"
"jest": {
"globals": {
"__DEV__": false
},
"moduleNameMapper": {
"\\.(css|less|scss|sss|styl)$": "<rootDir>/src/tools/jest/styles-mock.js",
".*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/tools/jest/assets-mock.js"
}
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.12.0",
Expand Down Expand Up @@ -175,7 +131,7 @@
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"moment-timezone": "^0.5.27",
"mongodb": "^3.3.3",
"mongodb": "^3.5.8",
"node-sass": "^4.13.0",
"offline-plugin": "^5.0.7",
"passport": "^0.4.0",
Expand All @@ -186,20 +142,19 @@
"react-dev-utils": "^10.0.0",
"react-dom": "^16.11.0",
"react-emoji-render": "^1.2.0",
"react-helmet": "^5.2.1",
"react-helmet": "^6.0.0",
"react-hot-loader": "^4.12.15",
"react-html-parser": "^2.0.2",
"react-i18next": "^11.0.0",
"react-mde": "^8.0.1",
"react-mde": "^10.0.3",
"react-paginate": "^6.3.2",
"react-redux": "^7.1.1",
"react-router": "^5.1.2",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.1.2",
"react-router-last-location": "^2.0.1",
"react-spinners": "^0.8.0",
"react-switch": "^5.0.1",
"react-toastify": "^5.4.0",
"react-toastify": "^6.0.5",
"reactstrap": "^8.1.1",
"redux": "^4.0.4",
"redux-devtools-extension": "^2.13.8",
Expand All @@ -210,5 +165,64 @@
"showdown": "^1.9.1",
"universal-cookie": "^4.0.2",
"validator": "^13.0.0"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.2.2",
"@babel/node": "^7.6.3",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.7.4",
"@babel/plugin-transform-spread": "^7.6.2",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.6.3",
"@babel/runtime": "^7.6.3",
"@loadable/babel-plugin": "^5.11.0",
"@loadable/webpack-plugin": "^5.7.1",
"@storybook/react": "^5.2.8",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-module-resolver": "^4.0.0",
"compression-webpack-plugin": "^4.0.0",
"css-loader": "^3.2.0",
"del-cli": "^3.0.0",
"eslint": "^7.1.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.5.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-plugin-flowtype": "^5.1.3",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^23.1.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"flow-bin": "^0.126.1",
"friendly-errors-webpack-plugin": "^1.7.0",
"imagemin-webpack-plugin": "^2.4.2",
"jest": "^26.0.1",
"jest-css-modules": "^2.1.0",
"lodash-webpack-plugin": "^0.11.5",
"mini-css-extract-plugin": "^0.9.0",
"nodemon": "^2.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss": "^7.0.25",
"postcss-loader": "^3.0.0",
"prettier": "^2.0.2",
"react-test-renderer": "^16.12.0",
"sass-loader": "^8.0.0",
"tcp-port-used": "^1.0.1",
"terser-webpack-plugin": "^3.0.3",
"url-loader": "^4.0.0",
"webpack": "^4.29.0",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.2.1",
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0",
"webpack-pwa-manifest": "^4.2.0",
"webpackbar": "^4.0.0"
},
"engines": {
"node": ">=10.13.0"
}
}
5 changes: 2 additions & 3 deletions src/client/components/Layout/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Helmet } from 'react-helmet';
import { Redirect, withRouter } from 'react-router';
import { NavLink, Link } from 'react-router-dom';
import { Redirect, withRouter, NavLink, Link } from 'react-router-dom';
import {
useLastLocation,
RedirectWithoutLastLocation,
Expand Down Expand Up @@ -240,7 +239,7 @@ const Layout = (props) => {

if (pathname === '/login' && accessToken) {
return (
<RedirectWithoutLastLocation to={lastLocation.pathname || returnPath} />
<RedirectWithoutLastLocation to={lastLocation?.pathname || returnPath} />
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Post/CreatePost/action.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */
import { Dispatch } from 'redux';
import { ApiDataType } from 'types';
import type { ApiDataType } from 'types';
import { actionGenerator } from 'utils';
import { requestAction } from 'utils/request';

Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Post/CreatePost/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow */
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router';
import { Redirect } from 'react-router-dom';
import ReactMde from 'react-mde';
import { toast } from 'react-toastify';

Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/Post/CreatePost/reducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @flow */
import { ActionType } from 'types';
import type { ActionType } from 'types';
import { CREATE_POST, DELETE_LOCAL_POST } from './action';

const initialState = {
Expand Down
Loading

0 comments on commit b10280e

Please sign in to comment.