From c5a2c9c80135a6825e5f1867665699c3a2a0cbcb Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 30 Jul 2024 20:13:28 +0300 Subject: [PATCH] chore: add knip package (#25) * chore: add knip package * ci: test listing * ci: test listing * revert: prior info command * ci: test knip * ci: show warnings instead of errors * ci: test showing knip error * ci: test showing knip error * ci: test showing knip error * revert: prior plain state * chore: change script name * ci: remove on push main --- .github/workflows/check.yml | 8 +- .github/workflows/knip.yml | 48 +++++++ app/lib/types.ts | 2 +- app/loading.tsx | 2 +- app/sign-in/page.tsx | 2 +- app/ui/pagination/pagination-list.tsx | 2 +- app/ui/skeletons.tsx | 15 --- config/constants/navigation.ts | 2 - config/constants/routes.ts | 2 - package.json | 6 +- yarn.lock | 175 ++++++++++++++++++++++++-- 11 files changed, 222 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/knip.yml delete mode 100644 app/ui/skeletons.tsx diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b4f96a2..1aadfd0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -38,9 +38,9 @@ jobs: ${{ runner.os }}- - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} - name: List the state of node modules + name: Info the state of node modules continue-on-error: true - run: yarn list + run: yarn info --name-only - name: Install Dependencies run: yarn install --immutable @@ -75,9 +75,9 @@ jobs: ${{ runner.os }}- - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} - name: List the state of node modules + name: Info the state of node modules continue-on-error: true - run: yarn list + run: yarn info --name-only - name: Install Dependencies run: yarn install --immutable diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml new file mode 100644 index 0000000..92347d5 --- /dev/null +++ b/.github/workflows/knip.yml @@ -0,0 +1,48 @@ +# Find unused files, dependencies and exports in JavaScript and TypeScript projects. +name: Knip + +on: + workflow_dispatch: + pull_request: + types: + - opened + - synchronize + +env: + CACHE_NAME: cache-node-modules + +jobs: + knip: + name: Knip + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Cache node modules + id: cache-yarn + uses: actions/cache@v4 + with: + # Below is an another cache folder on ubuntu + # path: ~/.cache/yarn + path: ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} + key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}\ + -${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-build-${{ env.CACHE_NAME }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} + name: Info the state of node modules + continue-on-error: true + run: yarn info --name-only + + - name: Install Dependencies + run: yarn install --immutable + + - name: Run Knip + # continue-on-error: true + run: yarn knip diff --git a/app/lib/types.ts b/app/lib/types.ts index bd5c371..259fbf9 100644 --- a/app/lib/types.ts +++ b/app/lib/types.ts @@ -64,7 +64,7 @@ export type TBalanceProjection = ['amount', 'isIncome'] export type TGroupedTransactions = Record -export type TTotals = { +type TTotals = { income: number expense: number } diff --git a/app/loading.tsx b/app/loading.tsx index ad56eb7..3858933 100644 --- a/app/loading.tsx +++ b/app/loading.tsx @@ -1,4 +1,4 @@ -import { Spinner } from '@nextui-org/spinner' +import { Spinner } from '@nextui-org/react' export default function Loading() { return ( diff --git a/app/sign-in/page.tsx b/app/sign-in/page.tsx index eb9cc90..c305d28 100644 --- a/app/sign-in/page.tsx +++ b/app/sign-in/page.tsx @@ -5,7 +5,7 @@ import { NAV_TITLE } from '@/config/constants/navigation' import SignIn from '@/app/ui/sign-in/sign-in' export const metadata: Metadata = { - title: NAV_TITLE.SIGNOUT, + title: NAV_TITLE.SIGNIN, } export default function Page() { diff --git a/app/ui/pagination/pagination-list.tsx b/app/ui/pagination/pagination-list.tsx index 7a30aae..a404957 100644 --- a/app/ui/pagination/pagination-list.tsx +++ b/app/ui/pagination/pagination-list.tsx @@ -4,7 +4,7 @@ import { useCallback, useEffect } from 'react' import { usePathname, useRouter, useSearchParams } from 'next/navigation' -import { Pagination } from '@nextui-org/pagination' +import { Pagination } from '@nextui-org/react' import { SEARCH_PARAM } from '@/config/constants/navigation' diff --git a/app/ui/skeletons.tsx b/app/ui/skeletons.tsx deleted file mode 100644 index f52e29e..0000000 --- a/app/ui/skeletons.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Skeleton } from '@nextui-org/react' - -export function UserInfoSkeleton() { - return ( -
-
- -
-
- - -
-
- ) -} diff --git a/config/constants/navigation.ts b/config/constants/navigation.ts index b236697..29bd881 100644 --- a/config/constants/navigation.ts +++ b/config/constants/navigation.ts @@ -10,8 +10,6 @@ export const enum NAV_TITLE { FEEDBACK = 'Give Feedback', ISSUE = 'Report Issue', SIGNIN = 'Sign In', - SIGNOUT = 'Sign Out', - MOBILE_TEMPORARILY_NOT_ALLOWED = 'Mobile Temporarily Not Allowed', } export const enum SEARCH_PARAM { diff --git a/config/constants/routes.ts b/config/constants/routes.ts index 53284ab..c976a55 100644 --- a/config/constants/routes.ts +++ b/config/constants/routes.ts @@ -1,12 +1,10 @@ export const enum ROUTE { HOME = '/', SIGNIN = '/sign-in', - SIGNOUT = '/sign-out', MONTHLY_REPORT = '/monthly-report', CHART = '/chart', CATEGORIES = '/categories', SETTINGS = '/settings', FEEDBACK = '/feedback', ISSUE = '/issue', - MOBILE_TEMPORARILY_NOT_ALLOWED = '/mobile-temporarily-not-allowed', } diff --git a/package.json b/package.json index c7473d5..937c9dc 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "test:cov": "vitest --coverage", "prettier": "prettier --c .", "prettier:fix": "prettier --w .", - "prepare": "husky" + "prepare": "husky", + "knip": "knip" }, "dependencies": { "@ducanh2912/next-pwa": "^10.2.8", @@ -49,7 +50,7 @@ "@testing-library/dom": "^10.4.0", "@testing-library/react": "^16.0.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0", - "@types/node": "^20.14.13", + "@types/node": "^22.0.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-is": "^18.3.0", @@ -60,6 +61,7 @@ "eslint-config-prettier": "^9.1.0", "husky": "^9.1.3", "jsdom": "^24.1.1", + "knip": "^5.27.0", "lint-staged": "^15.2.7", "postcss": "^8.4.40", "prettier": "^3.3.3", diff --git a/yarn.lock b/yarn.lock index 4b08dca..d2fd213 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3504,7 +3504,7 @@ __metadata: languageName: node linkType: hard -"@nodelib/fs.walk@npm:^1.2.3, @nodelib/fs.walk@npm:^1.2.8": +"@nodelib/fs.walk@npm:1.2.8, @nodelib/fs.walk@npm:^1.2.3, @nodelib/fs.walk@npm:^1.2.8": version: 1.2.8 resolution: "@nodelib/fs.walk@npm:1.2.8" dependencies: @@ -5692,6 +5692,19 @@ __metadata: languageName: node linkType: hard +"@snyk/github-codeowners@npm:1.1.0": + version: 1.1.0 + resolution: "@snyk/github-codeowners@npm:1.1.0" + dependencies: + commander: "npm:^4.1.1" + ignore: "npm:^5.1.8" + p-map: "npm:^4.0.0" + bin: + github-codeowners: dist/cli.js + checksum: 10c0/92d860a904a1e67f8563d4ac4d540cc613f71193f7968933b4a4b1526e80a97f536f52d27762c158e3e39d48c2f3db4906ec78846309351c741abb1a28653af9 + languageName: node + linkType: hard + "@surma/rollup-plugin-off-main-thread@npm:^2.2.3": version: 2.2.3 resolution: "@surma/rollup-plugin-off-main-thread@npm:2.2.3" @@ -6017,12 +6030,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^20.14.13": - version: 20.14.13 - resolution: "@types/node@npm:20.14.13" +"@types/node@npm:^22.0.0": + version: 22.0.0 + resolution: "@types/node@npm:22.0.0" dependencies: - undici-types: "npm:~5.26.4" - checksum: 10c0/10bb3ece675308742301c652ab8c6cb88b1ebddebed22316103c58f94fe7eff131edd5f679e487c19077fadb6b5e6b1ad9a60a2cee2869aa1f20452b9761d570 + undici-types: "npm:~6.11.1" + checksum: 10c0/af26a8ec7266c857b0ced75dc3a93c6b65280d1fa40d1b4488c814d30831c5c752489c99ecb5698daec1376145b1a9ddd08350882dc2e07769917a5f22a460bc languageName: node linkType: hard @@ -7324,6 +7337,13 @@ __metadata: languageName: node linkType: hard +"clone@npm:^1.0.2": + version: 1.0.4 + resolution: "clone@npm:1.0.4" + checksum: 10c0/2176952b3649293473999a95d7bebfc9dc96410f6cbd3d2595cf12fd401f63a4bf41a7adbfd3ab2ff09ed60cb9870c58c6acdd18b87767366fabfc163700f13b + languageName: node + linkType: hard + "clsx@npm:^1.2.1": version: 1.2.1 resolution: "clsx@npm:1.2.1" @@ -7436,7 +7456,7 @@ __metadata: languageName: node linkType: hard -"commander@npm:^4.0.0": +"commander@npm:^4.0.0, commander@npm:^4.1.1": version: 4.1.1 resolution: "commander@npm:4.1.1" checksum: 10c0/84a76c08fe6cc08c9c93f62ac573d2907d8e79138999312c92d4155bc2325d487d64d13f669b2000c9f8caf70493c1be2dac74fec3c51d5a04f8bc3ae1830bab @@ -7874,6 +7894,15 @@ __metadata: languageName: node linkType: hard +"defaults@npm:^1.0.3": + version: 1.0.4 + resolution: "defaults@npm:1.0.4" + dependencies: + clone: "npm:^1.0.2" + checksum: 10c0/9cfbe498f5c8ed733775db62dfd585780387d93c17477949e1670bfcfb9346e0281ce8c4bf9f4ac1fc0f9b851113bd6dc9e41182ea1644ccd97de639fa13c35a + languageName: node + linkType: hard + "define-data-property@npm:^1.0.1, define-data-property@npm:^1.1.4": version: 1.1.4 resolution: "define-data-property@npm:1.1.4" @@ -8050,6 +8079,19 @@ __metadata: languageName: node linkType: hard +"easy-table@npm:1.2.0": + version: 1.2.0 + resolution: "easy-table@npm:1.2.0" + dependencies: + ansi-regex: "npm:^5.0.1" + wcwidth: "npm:^1.0.1" + dependenciesMeta: + wcwidth: + optional: true + checksum: 10c0/2d37937cd608586ba02e1ec479f90ccec581d366b3b0d1bb26b99ee6005f8d724e32a07a873759893461ca45b99e2d08c30326529d967ce9eedc1e9b68d4aa63 + languageName: node + linkType: hard + "editorconfig@npm:^1.0.4": version: 1.0.4 resolution: "editorconfig@npm:1.0.4" @@ -8776,7 +8818,7 @@ __metadata: "@testing-library/dom": "npm:^10.4.0" "@testing-library/react": "npm:^16.0.0" "@trivago/prettier-plugin-sort-imports": "npm:^4.3.0" - "@types/node": "npm:^20.14.13" + "@types/node": "npm:^22.0.0" "@types/react": "npm:^18.3.3" "@types/react-dom": "npm:^18.3.0" "@types/react-is": "npm:^18.3.0" @@ -8792,6 +8834,7 @@ __metadata: framer-motion: "npm:^11.3.19" husky: "npm:^9.1.3" jsdom: "npm:^24.1.1" + knip: "npm:^5.27.0" lint-staged: "npm:^15.2.7" mongoose: "npm:^8.5.1" mongoose-encryption-decryption: "npm:^1.2.1" @@ -8847,7 +8890,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:3.3.2, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0, fast-glob@npm:^3.3.1": +"fast-glob@npm:3.3.2, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0, fast-glob@npm:^3.3.1, fast-glob@npm:^3.3.2": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -9613,7 +9656,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.2.0": +"ignore@npm:^5.1.8, ignore@npm:^5.2.0": version: 5.3.1 resolution: "ignore@npm:5.3.1" checksum: 10c0/703f7f45ffb2a27fb2c5a8db0c32e7dee66b33a225d28e8db4e1be6474795f606686a6e3bcc50e1aa12f2042db4c9d4a7d60af3250511de74620fbed052ea4cd @@ -10270,7 +10313,7 @@ __metadata: languageName: node linkType: hard -"jiti@npm:^1.19.1, jiti@npm:^1.21.0": +"jiti@npm:^1.19.1, jiti@npm:^1.21.0, jiti@npm:^1.21.6": version: 1.21.6 resolution: "jiti@npm:1.21.6" bin: @@ -10518,6 +10561,36 @@ __metadata: languageName: node linkType: hard +"knip@npm:^5.27.0": + version: 5.27.0 + resolution: "knip@npm:5.27.0" + dependencies: + "@nodelib/fs.walk": "npm:1.2.8" + "@snyk/github-codeowners": "npm:1.1.0" + easy-table: "npm:1.2.0" + fast-glob: "npm:^3.3.2" + jiti: "npm:^1.21.6" + js-yaml: "npm:^4.1.0" + minimist: "npm:^1.2.8" + picocolors: "npm:^1.0.0" + picomatch: "npm:^4.0.1" + pretty-ms: "npm:^9.0.0" + resolve: "npm:^1.22.8" + smol-toml: "npm:^1.1.4" + strip-json-comments: "npm:5.0.1" + summary: "npm:2.1.0" + zod: "npm:^3.22.4" + zod-validation-error: "npm:^3.0.3" + peerDependencies: + "@types/node": ">=18" + typescript: ">=5.0.4" + bin: + knip: bin/knip.js + knip-bun: bin/knip-bun.js + checksum: 10c0/95d0ac1c46157d8315f12203e667235b82852107f7c6790a7c7b9882e16958206163933d201da930cc1b1f31ae428c6d20828d1721ffa2369ad93c1e1cb7c48c + languageName: node + linkType: hard + "language-subtag-registry@npm:^0.3.20": version: 0.3.23 resolution: "language-subtag-registry@npm:0.3.23" @@ -11797,6 +11870,13 @@ __metadata: languageName: node linkType: hard +"parse-ms@npm:^4.0.0": + version: 4.0.0 + resolution: "parse-ms@npm:4.0.0" + checksum: 10c0/a7900f4f1ebac24cbf5e9708c16fb2fd482517fad353aecd7aefb8c2ba2f85ce017913ccb8925d231770404780df46244ea6fec598b3bde6490882358b4d2d16 + languageName: node + linkType: hard + "parse5@npm:^7.1.2": version: 7.1.2 resolution: "parse5@npm:7.1.2" @@ -11959,6 +12039,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.1": + version: 4.0.2 + resolution: "picomatch@npm:4.0.2" + checksum: 10c0/7c51f3ad2bb42c776f49ebf964c644958158be30d0a510efd5a395e8d49cb5acfed5b82c0c5b365523ce18e6ab85013c9ebe574f60305892ec3fa8eee8304ccc + languageName: node + linkType: hard + "pidtree@npm:~0.6.0": version: 0.6.0 resolution: "pidtree@npm:0.6.0" @@ -12284,6 +12371,15 @@ __metadata: languageName: node linkType: hard +"pretty-ms@npm:^9.0.0": + version: 9.1.0 + resolution: "pretty-ms@npm:9.1.0" + dependencies: + parse-ms: "npm:^4.0.0" + checksum: 10c0/fd111aad8800a04dfd654e6016da69bdaa6fc6a4c280f8e727cffd8b5960558e94942f1a94d4aa6e4d179561a0fbb0366a9ebe0ccefbbb0f8ff853b129cdefb9 + languageName: node + linkType: hard + "proc-log@npm:^3.0.0": version: 3.0.0 resolution: "proc-log@npm:3.0.0" @@ -12806,7 +12902,7 @@ __metadata: languageName: node linkType: hard -"resolve@npm:1.22.8, resolve@npm:^1.1.7, resolve@npm:^1.14.2, resolve@npm:^1.22.1, resolve@npm:^1.22.2, resolve@npm:^1.22.4": +"resolve@npm:1.22.8, resolve@npm:^1.1.7, resolve@npm:^1.14.2, resolve@npm:^1.22.1, resolve@npm:^1.22.2, resolve@npm:^1.22.4, resolve@npm:^1.22.8": version: 1.22.8 resolution: "resolve@npm:1.22.8" dependencies: @@ -12832,7 +12928,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@npm%3A1.22.8#optional!builtin, resolve@patch:resolve@npm%3A^1.1.7#optional!builtin, resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.1#optional!builtin, resolve@patch:resolve@npm%3A^1.22.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin": +"resolve@patch:resolve@npm%3A1.22.8#optional!builtin, resolve@patch:resolve@npm%3A^1.1.7#optional!builtin, resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.1#optional!builtin, resolve@patch:resolve@npm%3A^1.22.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin, resolve@patch:resolve@npm%3A^1.22.8#optional!builtin": version: 1.22.8 resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=c3c19d" dependencies: @@ -13308,6 +13404,13 @@ __metadata: languageName: node linkType: hard +"smol-toml@npm:^1.1.4": + version: 1.3.0 + resolution: "smol-toml@npm:1.3.0" + checksum: 10c0/442b4d033236ff6dd05bf91d57695fd9070a8221af080a5b2782cb2d9fad8bc31f698c61de5308a351907c1200202ba3ee51d52c5704f5349149e7c374f5fe90 + languageName: node + linkType: hard + "socks-proxy-agent@npm:^8.0.3": version: 8.0.3 resolution: "socks-proxy-agent@npm:8.0.3" @@ -13642,6 +13745,13 @@ __metadata: languageName: node linkType: hard +"strip-json-comments@npm:5.0.1": + version: 5.0.1 + resolution: "strip-json-comments@npm:5.0.1" + checksum: 10c0/c9d9d55a0167c57aa688df3aa20628cf6f46f0344038f189eaa9d159978e80b2bfa6da541a40d83f7bde8a3554596259bf6b70578b2172356536a0e3fa5a0982 + languageName: node + linkType: hard + "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -13690,6 +13800,13 @@ __metadata: languageName: node linkType: hard +"summary@npm:2.1.0": + version: 2.1.0 + resolution: "summary@npm:2.1.0" + checksum: 10c0/2743c1f940fb303c496ef1b085e654704a6c16872957b6b76648c34bd32c8f0b7a3c5ec4e0f8bfb71dcb8473e34d172fef31026b85562af589cf220aa901698d + languageName: node + linkType: hard + "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" @@ -14212,6 +14329,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~6.11.1": + version: 6.11.1 + resolution: "undici-types@npm:6.11.1" + checksum: 10c0/d8f5739a8e6c779d72336c82deb49c56d5ac9f9f6e0eb2e8dd4d3f6929ae9db7cde370d2e46516fe6cad04ea53e790c5e16c4c75eed7cd0f9bd31b0763bb2fa3 + languageName: node + linkType: hard + "unicode-canonical-property-names-ecmascript@npm:^2.0.0": version: 2.0.0 resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.0" @@ -14586,6 +14710,15 @@ __metadata: languageName: node linkType: hard +"wcwidth@npm:^1.0.1": + version: 1.0.1 + resolution: "wcwidth@npm:1.0.1" + dependencies: + defaults: "npm:^1.0.3" + checksum: 10c0/5b61ca583a95e2dd85d7078400190efd452e05751a64accb8c06ce4db65d7e0b0cde9917d705e826a2e05cc2548f61efde115ffa374c3e436d04be45c889e5b4 + languageName: node + linkType: hard + "webidl-conversions@npm:^3.0.0": version: 3.0.1 resolution: "webidl-conversions@npm:3.0.1" @@ -15234,3 +15367,19 @@ __metadata: checksum: 10c0/cb287fe5e6acfa82690acb43c283de34e945c571a78a939774f6eaba7c285bacdf6c90fbc16ce530060863984c906d2b4c6ceb069c94d1e0a06d5f2b458e2a92 languageName: node linkType: hard + +"zod-validation-error@npm:^3.0.3": + version: 3.3.0 + resolution: "zod-validation-error@npm:3.3.0" + peerDependencies: + zod: ^3.18.0 + checksum: 10c0/a233dca6dc9a2237aa7b677cc8ce022c2b6f90894fd4d1e2c7b239d2aad38f36f3b84bf7f7cfaff5bf97fce31e1010d2736ca1ec539e0e8cb8bb9d05977911a2 + languageName: node + linkType: hard + +"zod@npm:^3.22.4": + version: 3.23.8 + resolution: "zod@npm:3.23.8" + checksum: 10c0/8f14c87d6b1b53c944c25ce7a28616896319d95bc46a9660fe441adc0ed0a81253b02b5abdaeffedbeb23bdd25a0bf1c29d2c12dd919aef6447652dd295e3e69 + languageName: node + linkType: hard