Skip to content

Commit 44bdbde

Browse files
committed
Initial commit
1 parent 61b0717 commit 44bdbde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+18902
-0
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# node_modules is ignored by default
2+
build/
3+
dist/
4+
docs/

.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// For jest and gatsby config, see https://github.com/d4rekanguok/gatsby-typescript/blob/master/.eslintrc.js
2+
module.exports = {
3+
overrides: [
4+
{
5+
// Plain JavaScript
6+
files: ['*.{js,jsx}'],
7+
extends: ['airbnb', 'airbnb/hooks', 'prettier', 'prettier/react'],
8+
plugins: ['prettier'],
9+
},
10+
{
11+
// Typescript
12+
// See https://github.com/toshi-toma/eslint-config-airbnb-typescript-prettier/blob/master/index.js
13+
files: ['*.{ts,tsx}'],
14+
extends: ['airbnb-typescript-prettier'],
15+
},
16+
],
17+
rules: {
18+
'max-len': [
19+
'error',
20+
{
21+
code: 120,
22+
ignoreUrls: true,
23+
},
24+
],
25+
},
26+
};

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
.eslintcache
21+
.vscode
22+
vscode
23+
24+
npm-debug.log*
25+

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/fermium

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
dist/
3+
node_modules/

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
printWidth: 120,
3+
singleQuote: true,
4+
trailingComma: 'all',
5+
};

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# A Modern React SPA Browser App to Ring In 2021
2+
3+
This application is further described [here](docs/app-creation.md).
4+
5+
## Getting Started with Create React App
6+
7+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
8+
9+
## Available Scripts
10+
11+
In the project directory, you can run:
12+
13+
### `npm start`
14+
15+
Runs the app in the development mode.\
16+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
17+
18+
The page will reload if you make edits.\
19+
You will also see any lint errors in the console.
20+
21+
### `npm test`
22+
23+
Launches the test runner in the interactive watch mode.\
24+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
25+
26+
### `npm run build`
27+
28+
Builds the app for production to the `build` folder.\
29+
It correctly bundles React in production mode and optimizes the build for the best performance.
30+
31+
The build is minified and the filenames include the hashes.\
32+
Your app is ready to be deployed!
33+
34+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
35+
36+
### `npm run eject`
37+
38+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
39+
40+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
41+
42+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
43+
44+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
45+
46+
## Learn More
47+
48+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
49+
50+
To learn React, check out the [React documentation](https://reactjs.org/).
51+
52+
### Code Splitting
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
55+
56+
### Analyzing the Bundle Size
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
59+
60+
### Making a Progressive Web App
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
63+
64+
### Advanced Configuration
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
67+
68+
### Deployment
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
71+
72+
### `npm run build` fails to minify
73+
74+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

docs/app-creation.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Introduction
2+
3+
This React 17-based single page application (SPA) for browsers (not React Native) was built using create-react-app in November 2020.
4+
5+
## Acknowledgements
6+
7+
This app was made possible by the contributions of many voices. I regret that not every reference has been cited but here is a [list of references](tech-references.md) that were invaluable to this project.
8+
9+
## Features
10+
11+
- React Hooks
12+
- Typescript
13+
- [Prettier and ESLint using Airbnb Style Guide](https://terrislinenbach.medium.com/formatting-and-linting-a-modern-react-typescript-project-fa127e6426f)
14+
- [Material-UI](https://material-ui.com/) version 5 components (still alpha)
15+
- Page transitions via [React Router](https://reactrouter.com/)
16+
- External data retrieval via [react-query](https://react-query.tanstack.com/) version 3
17+
- Tabular data display via [react-table](https://react-table.tanstack.com/)
18+
- Global state management via [Recoil](https://recoiljs.org/)
19+
- "Loading" feedback via [React Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html)
20+
- Translations via [i18next](https://www.i18next.com/)
21+
- [CORS workaround proxy](https://terrislinenbach.medium.com/an-advanced-cors-workaround-for-react-apps-40dec1a4a0cd)
22+
- A default error page
23+
- A custom 404 page
24+
- Testing with Jest and React Testing Library
25+
- A sample test invokes an external service
26+
- Because the example uses the proxy, you must start the app (npm run start) prior to running tests
27+
28+
## How this app was created
29+
30+
1. [Install nvm](https://heynode.com/tutorial/install-nodejs-locally-nvm)
31+
2. `nvm i lts/fermium`
32+
3. `npx create-react-app react-spa --typescript`
33+
4. `cd react-spa`
34+
5. `echo lts/fermium > .nvmrc`
35+
36+
6.
37+
38+
```shell
39+
npm i --save-dev eslint prettier eslint-config-airbnb-typescript-prettier typescript
40+
41+
npm i --save \
42+
i18next i18next-browser-languagedetector i18next-http-backend react-i18next \
43+
react-loader-spinner @types/react-loader-spinner \
44+
recoil \
45+
react-dom @types/react-dom \
46+
react-router @types/react-router \
47+
react-router-dom @types/react-router-dom \
48+
react-query @types/react-query \
49+
react-table @types/react-table \
50+
jest-localstorage-mock \
51+
request
52+
53+
# Material-UI 5
54+
npm i --save \
55+
typeface-roboto \
56+
@material-ui/lab @emotion/react @emotion/styled @material-ui/core@next typeface-roboto
57+
```
58+
59+
7. Create .eslintrc.js
60+
61+
```js
62+
// For gatsby config, see https://github.com/d4rekanguok/gatsby-typescript/blob/master/.eslintrc.js
63+
module.exports = {
64+
overrides: [
65+
{
66+
// Plain JavaScript
67+
files: ['*.{js,jsx}'],
68+
extends: ['airbnb', 'airbnb/hooks', 'prettier', 'prettier/react', 'react-app', 'react-app/jest'],
69+
plugins: ['prettier'],
70+
},
71+
{
72+
// Typescript
73+
// See https://github.com/toshi-toma/eslint-config-airbnb-typescript-prettier/blob/master/index.js
74+
files: ['*.{ts,tsx}'],
75+
extends: ['airbnb-typescript-prettier', 'react-app', 'react-app/jest'],
76+
},
77+
],
78+
rules: {
79+
'max-len': [
80+
'error',
81+
{
82+
code: 120,
83+
ignoreUrls: true,
84+
},
85+
],
86+
},
87+
};
88+
```
89+
90+
8. Create .eslintignore
91+
92+
```js
93+
# node_modules is ignored by default
94+
build/
95+
dist/
96+
docs/
97+
```
98+
99+
9. Create .prettierrc.js
100+
101+
```js
102+
module.exports = {
103+
printWidth: 120,
104+
singleQuote: true,
105+
trailingComma: 'all',
106+
};
107+
```
108+
109+
10. Create .prettierignore
110+
111+
```js
112+
build/
113+
dist/
114+
node_modules/
115+
```
116+
117+
11. Modify package.json
118+
119+
11.1 Remove eslint section
120+
121+
11.2 Add format and lint scripts
122+
123+
```js
124+
"scripts": {
125+
"lint": "tsc --noEmit && eslint --fix '*.{js,jsx,ts,tsx}'"
126+
"format": "prettier . --write",
127+
```
128+
129+
12. Edit tsconfig.json
130+
131+
- set compilerOptions.target to esnext
132+
133+
## Appendix
134+
135+
### Should @types/\* appear in devDependencies?
136+
137+
Because React applications are bundled, it doesn't matter whether you use devDependencies. All dependencies are considered at build time. Modules that aren't needed are discarded. If you're building a reusable library, not including a @types module can cause issues for the module's users. [Reference](https://github.com/facebook/create-react-app/issues/6180#issuecomment-453640473).

0 commit comments

Comments
 (0)