From 83f4fc8ab07a7f4cd3bba8042d600d7a4543bcaf Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 23 Oct 2022 23:53:15 +0800 Subject: It's been a long time not developing this. Still need some time to get it work again. --- FrontEnd/.eslintignore | 2 +- FrontEnd/.eslintrc.cjs | 39 +++++++++++++++++++++++++++++++++++++++ FrontEnd/.eslintrc.js | 45 --------------------------------------------- FrontEnd/cspell.json | 4 ++++ FrontEnd/package.json | 22 ++++++++++++---------- FrontEnd/src/i18next.d.ts | 19 +++++++++++++++++++ FrontEnd/src/sw.ts | 2 -- FrontEnd/src/vite-env.d.ts | 1 + FrontEnd/tsconfig.json | 16 ++-------------- FrontEnd/vite.config.js | 5 ++--- 10 files changed, 80 insertions(+), 75 deletions(-) create mode 100644 FrontEnd/.eslintrc.cjs delete mode 100644 FrontEnd/.eslintrc.js create mode 100644 FrontEnd/cspell.json create mode 100644 FrontEnd/src/i18next.d.ts create mode 100644 FrontEnd/src/vite-env.d.ts (limited to 'FrontEnd') diff --git a/FrontEnd/.eslintignore b/FrontEnd/.eslintignore index f4f28252..21ea71eb 100644 --- a/FrontEnd/.eslintignore +++ b/FrontEnd/.eslintignore @@ -1,6 +1,6 @@ .yarn node_modules dist -.eslintrc.js +.eslintrc.cjs postcss.config.js vite.config.js diff --git a/FrontEnd/.eslintrc.cjs b/FrontEnd/.eslintrc.cjs new file mode 100644 index 00000000..62490975 --- /dev/null +++ b/FrontEnd/.eslintrc.cjs @@ -0,0 +1,39 @@ +module.exports = { + root: true, + env: { + browser: true, + es2022: true, + }, + extends: [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:prettier/recommended", + "plugin:react-hooks/recommended", + ], + parser: "@typescript-eslint/parser", + parserOptions: { + tsconfigRootDir: __dirname, + project: ["./tsconfig.json"], + }, + plugins: ["react", "@typescript-eslint", "react-hooks"], + settings: { + react: { + version: "detect", + }, + }, + rules: { + "react/prop-types": "off", + "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], + "@typescript-eslint/explicit-function-return-type": [ + "warn", + { + allowExpressions: true, + allowTypedFunctionExpressions: true, + allowHigherOrderFunctions: true, + }, + ], + }, +}; diff --git a/FrontEnd/.eslintrc.js b/FrontEnd/.eslintrc.js deleted file mode 100644 index 93b98978..00000000 --- a/FrontEnd/.eslintrc.js +++ /dev/null @@ -1,45 +0,0 @@ -module.exports = { - env: { - browser: true, - es2020: true, - }, - extends: [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:prettier/recommended", - "plugin:react-hooks/recommended", - ], - globals: { - Atomics: "readonly", - SharedArrayBuffer: "readonly", - }, - parser: "@typescript-eslint/parser", - parserOptions: { - project: ["./tsconfig.json"], - ecmaFeatures: { - jsx: true, - }, - sourceType: "module", - }, - plugins: ["react", "@typescript-eslint", "react-hooks"], - settings: { - react: { - version: "detect", - }, - }, - rules: { - "react/prop-types": "off", - "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], - "@typescript-eslint/explicit-function-return-type": [ - "warn", - { - allowExpressions: true, - allowTypedFunctionExpressions: true, - allowHigherOrderFunctions: true, - }, - ], - }, -}; diff --git a/FrontEnd/cspell.json b/FrontEnd/cspell.json new file mode 100644 index 00000000..3f746df6 --- /dev/null +++ b/FrontEnd/cspell.json @@ -0,0 +1,4 @@ +{ + "version": "0.2", + "ignorePaths": ["**/node_modules/**", "package-lock.json"] +} diff --git a/FrontEnd/package.json b/FrontEnd/package.json index 0a91d67d..6592fbeb 100644 --- a/FrontEnd/package.json +++ b/FrontEnd/package.json @@ -2,19 +2,20 @@ "name": "timeline", "version": "0.4.0", "private": true, - "homepage": "https://timeline.crupest.life", + "homepage": "https://crupest.space", "keywords": [], "description": "Timeline app.", + "type": "module", "dependencies": { "@microsoft/signalr": "^6.0.7", "@popperjs/core": "^2.11.5", - "axios": "^0.27.0", + "axios": "^1.1.3", "bootstrap": "^5.1.3", "bootstrap-icons": "^1.9.1", "classnames": "^2.3.1", "color": "^4.2.3", "core-js": "^3.23.4", - "i18next": "^21.8.13", + "i18next": "^22.0.2", "i18next-browser-languagedetector": "^6.1.4", "js-base64": "^3.7.2", "lodash": "^4.17.21", @@ -24,9 +25,9 @@ "react": "^18.0.0", "react-color": "^2.19.3", "react-dom": "^18.2.0", - "react-i18next": "^11.18.3", + "react-i18next": "^12.0.0", "react-popper": "^2.3.0", - "react-responsive": "^8.2.0", + "react-responsive": "^9.0.0", "react-router-dom": "^6.3.0", "react-transition-group": "^4.4.2", "regenerator-runtime": "^0.13.9", @@ -43,11 +44,12 @@ "start": "vite", "build": "tsc && vite build", "preview": "vite preview", - "typecheck": "tsc", + "type-check": "tsc", "lint": "eslint src/ --ext .js --ext .jsx --ext .ts --ext .tsx", "lint:fix": "eslint src/ --ext .js --ext .jsx --ext .ts --ext .tsx --fix" }, "devDependencies": { + "@tsconfig/vite-react": "^1.0.1", "@types/color": "^3.0.3", "@types/lodash": "^4.14.181", "@types/marked": "^4.0.3", @@ -59,15 +61,15 @@ "@types/react-transition-group": "^4.4.5", "@typescript-eslint/eslint-plugin": "^5.30.6", "@typescript-eslint/parser": "^5.30.6", - "@vitejs/plugin-react-refresh": "^1.3.6", + "@vitejs/plugin-react": "^2.1.0", "eslint": "^8.19.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "prettier": "^2.7.1", - "typescript": "^4.7.4", - "vite": "^2.9.14", - "vite-plugin-pwa": "^0.12.3" + "typescript": "^4.8.0", + "vite": "^3.1.8", + "vite-plugin-pwa": "^0.13.1" } } \ No newline at end of file diff --git a/FrontEnd/src/i18next.d.ts b/FrontEnd/src/i18next.d.ts new file mode 100644 index 00000000..761b22f3 --- /dev/null +++ b/FrontEnd/src/i18next.d.ts @@ -0,0 +1,19 @@ +// import the original type declarations +import "react-i18next"; +// import all namespaces (for the default language, only) +import admin from "./locales/en/admin.json"; +import translation from "./locales/en/translation.json"; + +// react-i18next versions higher than 11.11.0 +declare module "i18next" { + // and extend them! + interface CustomTypeOptions { + // custom namespace type if you changed it + defaultNS: "translation"; + // custom resources type + resources: { + admin: typeof admin; + translation: typeof translation; + }; + } +} diff --git a/FrontEnd/src/sw.ts b/FrontEnd/src/sw.ts index 0130e345..a43ff9e5 100644 --- a/FrontEnd/src/sw.ts +++ b/FrontEnd/src/sw.ts @@ -1,5 +1,3 @@ -/// -/// /// import { precacheAndRoute, matchPrecache } from "workbox-precaching"; diff --git a/FrontEnd/src/vite-env.d.ts b/FrontEnd/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/FrontEnd/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/FrontEnd/tsconfig.json b/FrontEnd/tsconfig.json index 6b691e0e..967f9dd6 100644 --- a/FrontEnd/tsconfig.json +++ b/FrontEnd/tsconfig.json @@ -1,22 +1,10 @@ { + "extends": "@tsconfig/vite-react/tsconfig.json", "compilerOptions": { - "target": "ESNext", - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "skipLibCheck": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "ESNext", - "moduleResolution": "Node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "react", - "noEmit": true, - "types": ["vite/client"], "baseUrl": "./", "paths": { "@/*": ["src/*"] } }, - "include": ["./src"] + "include": ["src"] } diff --git a/FrontEnd/vite.config.js b/FrontEnd/vite.config.js index 64e0457f..b8d15dbd 100644 --- a/FrontEnd/vite.config.js +++ b/FrontEnd/vite.config.js @@ -2,18 +2,17 @@ * @type {import('vite').UserConfig} */ -import reactRefresh from "@vitejs/plugin-react-refresh"; import { VitePWA } from "vite-plugin-pwa"; import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [ - reactRefresh(), + react(), VitePWA({ strategies: "injectManifest", srcDir: "src", filename: "sw.ts", - base: "/", manifest: false, includeAssets: "**", }), -- cgit v1.2.3