From e71da322d32bcdd3e9c6389a8a24f9b9c0056597 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 1 Nov 2021 21:13:36 -0500 Subject: [PATCH 1/7] frontend: re-order dependencies and whitespace Re-order the dependencies since all the npm tools keep re-ordering them and adjusting the whitespace. --- .../frontend/package.json | 18 +++++++++--------- .../frontend/tsconfig.json | 11 +++++++++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/{{cookiecutter.project_slug}}/frontend/package.json b/{{cookiecutter.project_slug}}/frontend/package.json index 14dd1f81..409dcda4 100644 --- a/{{cookiecutter.project_slug}}/frontend/package.json +++ b/{{cookiecutter.project_slug}}/frontend/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@material-ui/lab": "^4.0.0-alpha.54", + "jwt-decode": "^3.0.0", "ra-data-json-server": "^3.5.2", "ra-data-simple-rest": "^3.3.2", "react": "^16.13.1", @@ -11,9 +13,7 @@ "react-router-dom": "^5.1.2", "react-scripts": "3.4.3", "react-truncate": "^2.4.0", - "standard": "^14.3.3", - "jwt-decode": "^3.0.0", - "@material-ui/lab": "^4.0.0-alpha.54" + "standard": "^14.3.3" }, "scripts": { "start": "react-scripts start", @@ -37,26 +37,26 @@ ] }, "devDependencies": { - "typescript": "^4.0.2", "@testing-library/jest-dom": "^5.11.1", "@testing-library/react": "^11.0.4", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", "@testing-library/user-event": "^12.0.11", "@types/jest": "^26.0.3", + "@types/jwt-decode": "^2.2.1", "@types/node": "^14.0.1", "@types/react": "^16.9.19", "@types/react-dom": "^16.9.5", "@types/react-router-dom": "^5.1.3", - "@types/jwt-decode": "^2.2.1", + "@typescript-eslint/eslint-plugin": "^2.24.0", + "@typescript-eslint/parser": "^2.24.0", "eslint-config-airbnb": "^18.1.0", - "eslint-config-react-app": "^5.2.1", "eslint-plugin-flowtype": "^4.6.0", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.19.0", + "eslint-config-react-app": "^5.2.1", "eslint-plugin-react-hooks": "^2.5.1", "prettier": "^2.0.5", - "react-test-renderer": "^16.13.1" + "react-test-renderer": "^16.13.1", + "typescript": "^4.0.2" } } diff --git a/{{cookiecutter.project_slug}}/frontend/tsconfig.json b/{{cookiecutter.project_slug}}/frontend/tsconfig.json index 4a41017b..5cf4f349 100644 --- a/{{cookiecutter.project_slug}}/frontend/tsconfig.json +++ b/{{cookiecutter.project_slug}}/frontend/tsconfig.json @@ -1,7 +1,11 @@ { "compilerOptions": { "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -15,5 +19,8 @@ "noEmit": true, "jsx": "react" }, - "include": ["src", "decs.d.ts"] + "include": [ + "src", + "decs.d.ts" + ] } From ffbf8954973e2e9d6467dd86721447176f3e5095 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 1 Nov 2021 21:20:15 -0500 Subject: [PATCH 2/7] frontend: bump react-scripts to 4.0.3 for TypeScript 4.x Bumped react-scripts to 4.0.3 as well as any associated dependencies to have full TypeScript 4.x support. fixes #177 --- .../frontend/.eslintrc.js | 2 +- .../frontend/package.json | 15 ++++++++------- .../frontend/tsconfig.json | 3 ++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/{{cookiecutter.project_slug}}/frontend/.eslintrc.js b/{{cookiecutter.project_slug}}/frontend/.eslintrc.js index 428e4222..a56c47a2 100644 --- a/{{cookiecutter.project_slug}}/frontend/.eslintrc.js +++ b/{{cookiecutter.project_slug}}/frontend/.eslintrc.js @@ -21,7 +21,7 @@ let rules = { }; module.exports = { - extends: ['airbnb', 'plugin:prettier/recommended', 'prettier/react'], + extends: ['airbnb', 'plugin:prettier/recommended', 'prettier'], parser: 'babel-eslint', rules, env: { diff --git a/{{cookiecutter.project_slug}}/frontend/package.json b/{{cookiecutter.project_slug}}/frontend/package.json index 409dcda4..23b73026 100644 --- a/{{cookiecutter.project_slug}}/frontend/package.json +++ b/{{cookiecutter.project_slug}}/frontend/package.json @@ -11,9 +11,9 @@ "react-admin": "^3.5.2", "react-dom": "^16.13.1", "react-router-dom": "^5.1.2", - "react-scripts": "3.4.3", + "react-scripts": "4.0.3", "react-truncate": "^2.4.0", - "standard": "^14.3.3" + "standard": "^16.0.0" }, "scripts": { "start": "react-scripts start", @@ -46,15 +46,16 @@ "@types/react": "^16.9.19", "@types/react-dom": "^16.9.5", "@types/react-router-dom": "^5.1.3", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", + "@typescript-eslint/eslint-plugin": "^4.0.0", + "@typescript-eslint/parser": "^4.0.0", "eslint-config-airbnb": "^18.1.0", - "eslint-plugin-flowtype": "^4.6.0", + "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-config-prettier": "^8.3.0", "eslint-plugin-react": "^7.19.0", - "eslint-config-react-app": "^5.2.1", - "eslint-plugin-react-hooks": "^2.5.1", + "eslint-config-react-app": "^6.0.0", + "eslint-plugin-react-hooks": "^4.2.0", "prettier": "^2.0.5", "react-test-renderer": "^16.13.1", "typescript": "^4.0.2" diff --git a/{{cookiecutter.project_slug}}/frontend/tsconfig.json b/{{cookiecutter.project_slug}}/frontend/tsconfig.json index 5cf4f349..e8b99dec 100644 --- a/{{cookiecutter.project_slug}}/frontend/tsconfig.json +++ b/{{cookiecutter.project_slug}}/frontend/tsconfig.json @@ -17,7 +17,8 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react" + "jsx": "react-jsx", + "noFallthroughCasesInSwitch": true }, "include": [ "src", From 3344881c6ca6765a7cc84ffd62a6ee701cfeb5e9 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 1 Nov 2021 21:25:54 -0500 Subject: [PATCH 3/7] frontend: add missing dependencies TypeScript 4.x compile process complains about missing dependencies so add them in. --- {{cookiecutter.project_slug}}/frontend/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/{{cookiecutter.project_slug}}/frontend/package.json b/{{cookiecutter.project_slug}}/frontend/package.json index 23b73026..00301ddd 100644 --- a/{{cookiecutter.project_slug}}/frontend/package.json +++ b/{{cookiecutter.project_slug}}/frontend/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@material-ui/core": "^4.0.0", + "@material-ui/icons": "^4.0.0", "@material-ui/lab": "^4.0.0-alpha.54", "jwt-decode": "^3.0.0", "ra-data-json-server": "^3.5.2", @@ -10,6 +12,7 @@ "react": "^16.13.1", "react-admin": "^3.5.2", "react-dom": "^16.13.1", + "react-router": "^5.1.2", "react-router-dom": "^5.1.2", "react-scripts": "4.0.3", "react-truncate": "^2.4.0", From 48dc388b4f75a84a100a5d3d314bdfe39410db42 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 1 Nov 2021 21:28:55 -0500 Subject: [PATCH 4/7] frontend: fix compile error due to bad type This failed to compile due to a mis-match of types with TypeScript 4.x. fixes #168. --- {{cookiecutter.project_slug}}/frontend/src/views/Home.tsx | 2 +- {{cookiecutter.project_slug}}/frontend/src/views/Login.tsx | 2 +- {{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx index 123e827d..2a239743 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx @@ -20,7 +20,7 @@ export const Home: FC = () => { const message = await getMessage(); setMessage(message); } catch (err) { - setError(err); + setError(String(err)); } }; diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx index b791a2c1..26298c8a 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx @@ -51,7 +51,7 @@ export const Login: FC = () => { setError(err.message); } else { // handle errors thrown from backend - setError(err); + setError(String(err)); } } }; diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx index 140ee36f..0ede11ee 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx @@ -48,7 +48,7 @@ export const SignUp: FC = () => { setError(err.message); } else { // handle errors thrown from backend - setError(err); + setError(String(err)); } } } From a2c5d8da126279d69fbc0eff5a5f8116eeb71371 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Tue, 2 Nov 2021 19:01:33 -0500 Subject: [PATCH 5/7] frontend: fix missing default exports Fix the lint 'import/prefer-default-export' --- {{cookiecutter.project_slug}}/frontend/src/views/Home.tsx | 2 ++ {{cookiecutter.project_slug}}/frontend/src/views/Login.tsx | 2 ++ {{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx | 2 ++ 3 files changed, 6 insertions(+) diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx index 2a239743..48a332c0 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx @@ -64,3 +64,5 @@ export const Home: FC = () => { ); }; + +export default Home; diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx index 26298c8a..c7f358c9 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx @@ -149,3 +149,5 @@ export const Login: FC = () => { ); }; + +export default Login; diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx index 0ede11ee..1198fdfe 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx @@ -136,3 +136,5 @@ export const SignUp: FC = () => { ); }; + +export default SignUp; From 316b665e5853cf2389f38b7374eb6dd437c91b9a Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Tue, 2 Nov 2021 19:03:31 -0500 Subject: [PATCH 6/7] frontend: omit value for boolean attributes Fix the lint 'react/jsx-boolean-value' --- {{cookiecutter.project_slug}}/frontend/src/views/Login.tsx | 4 ++-- {{cookiecutter.project_slug}}/frontend/src/views/SignUp.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx index c7f358c9..a5497a10 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Login.tsx @@ -65,7 +65,7 @@ export const Login: FC = () => { - + { - + { - + { - + { - + Date: Tue, 2 Nov 2021 19:04:42 -0500 Subject: [PATCH 7/7] frontend: fix shadowing variable Fix the lint 'no-shadow'. --- {{cookiecutter.project_slug}}/frontend/src/views/Home.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx index 48a332c0..a82f9695 100644 --- a/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx +++ b/{{cookiecutter.project_slug}}/frontend/src/views/Home.tsx @@ -17,8 +17,8 @@ export const Home: FC = () => { const queryBackend = async () => { try { - const message = await getMessage(); - setMessage(message); + const msg = await getMessage(); + setMessage(msg); } catch (err) { setError(String(err)); }