From 9fdc79cf2d0e0cd83707c8fcfa2a520b524a9e05 Mon Sep 17 00:00:00 2001 From: Jaewook Ahn Date: Fri, 21 Jun 2024 16:03:15 +0900 Subject: [PATCH] chore: configure absolute path import - delete background directory - move utils module to shared directory - update eslint config - add web extension polyfill dep --- .env | 2 -- .eslintrc.cjs | 1 + background/.eslintrc.js | 6 ---- background/index.ts | 1 - index.html | 2 +- package.json | 11 ++++--- src/index.tsx | 2 +- src/{ => shared}/utils.ts | 0 tsconfig.app.json | 7 ++++- vite.config.ts | 12 +++++--- yarn.lock | 61 +++++++++++++++++++++++++++++---------- 11 files changed, 69 insertions(+), 36 deletions(-) delete mode 100644 .env delete mode 100644 background/.eslintrc.js delete mode 100644 background/index.ts rename src/{ => shared}/utils.ts (100%) diff --git a/.env b/.env deleted file mode 100644 index f1635c6..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -PORT=1200 -INLINE_RUNTIME_CHUNK=false diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d0df1f6..f8623c4 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -26,5 +26,6 @@ module.exports = { semi: ["error", "always"], "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-explicit-any": "off", }, }; diff --git a/background/.eslintrc.js b/background/.eslintrc.js deleted file mode 100644 index bc22ecc..0000000 --- a/background/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - extends: "../.eslintrc.js", - parserOptions: { - project: "./background.tsconfig.json", - }, -}; diff --git a/background/index.ts b/background/index.ts deleted file mode 100644 index fdd3f43..0000000 --- a/background/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("background test"); diff --git a/index.html b/index.html index 2cd0f67..eea046d 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ - +
diff --git a/package.json b/package.json index 046edf4..8213ab0 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,13 @@ "devDependencies": { "@types/chrome": "^0.0.268", "@types/clipboard": "^2.0.1", - "@types/firefox-webext-browser": "^120.0.3", + "@types/firefox-webext-browser": "^120.0.4", "@types/fs-extra": "^11.0.4", "@types/node": "^18.6.5", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/styled-components": "^5.1.34", + "@types/webextension-polyfill": "^0.10.7", "@typescript-eslint/eslint-plugin": "^7.13.0", "@typescript-eslint/parser": "^7.13.0", "@vitejs/plugin-react": "^4.3.1", @@ -30,6 +31,8 @@ "chalk": "^4.1.0", "eslint": "^8", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.7", "fs-extra": "^10.1.0", "typescript": "^5.4.5", "vite": "^5.3.1" @@ -39,11 +42,11 @@ "antd": "^5.18.2", "axios": "^1.7.2", "copy-to-clipboard": "^3.3.3", - "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-react-refresh": "^0.4.7", "react": "^18.3.1", "react-dom": "^18.3.1", "react-icons": "^5.2.1", - "styled-components": "^6.1.11" + "recoil": "^0.7.7", + "styled-components": "^6.1.11", + "webextension-polyfill": "^0.12.0" } } diff --git a/src/index.tsx b/src/index.tsx index 3e50061..dd7928b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,7 +11,7 @@ import ReactDOM from "react-dom/client"; import { App } from "./App"; import { AddressManager } from "./AddressManager"; import { SettingsManager, Settings, DEFAULT_SETTINGS } from "./SettingsManager"; -import { isExtension, isProduction } from "./utils"; +import { isExtension, isProduction } from "./shared/utils"; window.dataLayer = window.dataLayer || []; if (isProduction()) { diff --git a/src/utils.ts b/src/shared/utils.ts similarity index 100% rename from src/utils.ts rename to src/shared/utils.ts diff --git a/tsconfig.app.json b/tsconfig.app.json index 1ad700f..7da4a1f 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -10,10 +10,15 @@ "target": "ES2020", "noEmit": true, "moduleResolution": "Bundler", + "baseUrl": ".", "allowImportingTsExtensions": true, "resolveJsonModule": true, + "paths": { + "@/*": ["src/*"] + }, "strict": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "types": ["vite/client"] }, "include": ["src"] } diff --git a/vite.config.ts b/vite.config.ts index 857089d..5fa8f00 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,14 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import { defineConfig } from "vite"; +import path from "path"; +import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], server: { port: 11200, - } -}) + }, + resolve: { + alias: [{ find: "@", replacement: path.join(__dirname, "src") }], + }, +}); diff --git a/yarn.lock b/yarn.lock index 7650305..0e500d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -826,21 +826,21 @@ integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== "@types/filesystem@*": - version "0.0.29" - resolved "https://registry.yarnpkg.com/@types/filesystem/-/filesystem-0.0.29.tgz#ee3748eb5be140dcf980c3bd35f11aec5f7a3748" - integrity sha512-85/1KfRedmfPGsbK8YzeaQUyV1FQAvMPMTuWFQ5EkLd2w7szhNO96bk3Rh/SKmOfd9co2rCLf0Voy4o7ECBOvw== + version "0.0.36" + resolved "https://registry.yarnpkg.com/@types/filesystem/-/filesystem-0.0.36.tgz#7227c2d76bfed1b21819db310816c7821d303857" + integrity sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA== dependencies: "@types/filewriter" "*" "@types/filewriter@*": - version "0.0.28" - resolved "https://registry.yarnpkg.com/@types/filewriter/-/filewriter-0.0.28.tgz#c054e8af4d9dd75db4e63abc76f885168714d4b3" - integrity sha1-wFTor02d11205jq8dviFFocU1LM= + version "0.0.33" + resolved "https://registry.yarnpkg.com/@types/filewriter/-/filewriter-0.0.33.tgz#d9d611db9d9cd99ae4e458de420eeb64ad604ea8" + integrity sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g== -"@types/firefox-webext-browser@^120.0.3": - version "120.0.3" - resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-120.0.3.tgz#d80f8d99a674102cd70cc3675490d4bc4771da61" - integrity sha512-APbBSxOvFMbKwXy/4YrEVa5Di6N0C9yl4w0WA0xzdkOrChAfPQ/KlcC8QLyhemHCHpF1CB/zHy52+oUQurViOg== +"@types/firefox-webext-browser@^120.0.4": + version "120.0.4" + resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-120.0.4.tgz#27eead781051b2e681a344dd2983735faadd4343" + integrity sha512-lBrpf08xhiZBigrtdQfUaqX1UauwZ+skbFiL8u2Tdra/rklkKadYmIzTwkNZSWtuZ7OKpFqbE2HHfDoFqvZf6w== "@types/fs-extra@^11.0.4": version "11.0.4" @@ -851,9 +851,9 @@ "@types/node" "*" "@types/har-format@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/har-format/-/har-format-1.2.4.tgz#3275842095abb60d14b47fa798cc9ff708dab6d4" - integrity sha512-iUxzm1meBm3stxUMzRqgOVHjj4Kgpgu5w9fm4X7kPRfSgVRzythsucEN7/jtOo8SQzm+HfcxWWzJS0mJDH/3DQ== + version "1.2.15" + resolved "https://registry.yarnpkg.com/@types/har-format/-/har-format-1.2.15.tgz#f352493638c2f89d706438a19a9eb300b493b506" + integrity sha512-RpQH4rXLuvTXKR0zqHq3go0RVXYv/YVqv4TnPH95VbwUxZdQlK1EtcMvQvMpDngHbt13Csh9Z4qT9AbkiQH5BA== "@types/hoist-non-react-statics@*": version "3.3.1" @@ -881,9 +881,11 @@ integrity sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ== "@types/node@^18.6.5": - version "18.6.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.6.5.tgz#06caea822caf9e59d5034b695186ee74154d2802" - integrity sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw== + version "18.19.36" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.36.tgz#c9861e84727e07ecf79a5ff6d0e14f91bab2b478" + integrity sha512-tX1BNmYSWEvViftB26VLNxT6mEr37M7+ldUtq7rlKnv4/2fKYsJIOmqJAjT6h1DNuwQjIKgw3VJ/Dtw3yiTIQw== + dependencies: + undici-types "~5.26.4" "@types/prop-types@*": version "15.7.4" @@ -933,6 +935,11 @@ resolved "https://registry.yarnpkg.com/@types/stylis/-/stylis-4.2.5.tgz#1daa6456f40959d06157698a653a9ab0a70281df" integrity sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw== +"@types/webextension-polyfill@^0.10.7": + version "0.10.7" + resolved "https://registry.yarnpkg.com/@types/webextension-polyfill/-/webextension-polyfill-0.10.7.tgz#de059250599733a60ed26c8a0c81e21e11183b90" + integrity sha512-10ql7A0qzBmFB+F+qAke/nP1PIonS0TXZAOMVOxEUsm+lGSW6uwVcISFNa0I4Oyj0884TZVWGGMIWeXOVSNFHw== + "@typescript-eslint/eslint-plugin@^7.13.0": version "7.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.0.tgz#3cdeb5d44d051b21a9567535dd90702b2a42c6ff" @@ -2204,6 +2211,11 @@ graphemer@^1.4.0: resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== +hamt_plus@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/hamt_plus/-/hamt_plus-1.0.2.tgz#e21c252968c7e33b20f6a1b094cd85787a265601" + integrity sha512-t2JXKaehnMb9paaYA7J0BX8QQAY8lwfQ9Gjf4pg/mk4krt+cmwmU652HOoWonf+7+EQV97ARPMhhVgU1ra2GhA== + has-bigints@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" @@ -3373,6 +3385,13 @@ readdir-glob@^1.0.0: dependencies: minimatch "^3.0.4" +recoil@^0.7.7: + version "0.7.7" + resolved "https://registry.yarnpkg.com/recoil/-/recoil-0.7.7.tgz#c5f2c843224384c9c09e4a62c060fb4c1454dc8e" + integrity sha512-8Og5KPQW9LwC577Vc7Ug2P0vQshkv1y3zG3tSSkWMqkWSwHmE+by06L8JtnGocjW6gcCvfwB3YtrJG6/tWivNQ== + dependencies: + hamt_plus "1.0.2" + regenerator-runtime@^0.13.4: version "0.13.9" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" @@ -3814,6 +3833,11 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" @@ -3850,6 +3874,11 @@ vite@^5.3.1: optionalDependencies: fsevents "~2.3.3" +webextension-polyfill@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.12.0.tgz#f62c57d2cd42524e9fbdcee494c034cae34a3d69" + integrity sha512-97TBmpoWJEE+3nFBQ4VocyCdLKfw54rFaJ6EVQYLBCXqCIpLSZkwGgASpv4oPt9gdKCJ80RJlcmNzNn008Ag6Q== + which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"