From 1669ac0be22909eda7acdf3d12d4029b6b7c3a91 Mon Sep 17 00:00:00 2001 From: Lucas Werey Date: Mon, 28 Oct 2024 11:29:29 +0100 Subject: [PATCH] :technologist:(lld) migrate to knip --- .github/workflows/build-and-test-pr.yml | 14 +-- .github/workflows/test-desktop-reusable.yml | 2 +- .github/workflows/test-mobile-reusable.yml | 2 +- CODEOWNERS | 4 +- apps/ledger-live-desktop/.unimportedrc.json | 39 ------- apps/ledger-live-desktop/package.json | 4 +- apps/ledger-live-mobile/.unimportedrc.json | 45 -------- apps/ledger-live-mobile/package.json | 2 +- knip.json | 109 ++++++++++++++++++ libs/env/.unimportedrc.json | 5 - libs/env/package.json | 2 +- .../.unimportedrc.json | 4 - libs/hw-ledger-key-ring-protocol/package.json | 2 +- .../.unimportedrc.json | 16 --- libs/ledger-key-ring-protocol/package.json | 2 +- .../.unimportedrc.json | 4 - libs/live-countervalues-react/package.json | 2 +- libs/live-countervalues/.unimportedrc.json | 4 - libs/live-countervalues/package.json | 2 +- libs/live-hooks/.unimportedrc.json | 5 - libs/live-hooks/package.json | 2 +- libs/live-nft-react/.unimportedrc.json | 4 - libs/live-nft-react/package.json | 2 +- libs/live-nft/.unimportedrc.json | 4 - libs/live-nft/package.json | 2 +- libs/live-wallet/.unimportedrc.json | 19 --- libs/live-wallet/package.json | 2 +- package.json | 2 + pnpm-lock.yaml | 92 +++++++++++++++ turbo.json | 3 + 30 files changed, 229 insertions(+), 172 deletions(-) delete mode 100644 apps/ledger-live-desktop/.unimportedrc.json delete mode 100644 apps/ledger-live-mobile/.unimportedrc.json create mode 100644 knip.json delete mode 100644 libs/env/.unimportedrc.json delete mode 100644 libs/hw-ledger-key-ring-protocol/.unimportedrc.json delete mode 100644 libs/ledger-key-ring-protocol/.unimportedrc.json delete mode 100644 libs/live-countervalues-react/.unimportedrc.json delete mode 100644 libs/live-countervalues/.unimportedrc.json delete mode 100644 libs/live-hooks/.unimportedrc.json delete mode 100644 libs/live-nft-react/.unimportedrc.json delete mode 100644 libs/live-nft/.unimportedrc.json delete mode 100644 libs/live-wallet/.unimportedrc.json diff --git a/.github/workflows/build-and-test-pr.yml b/.github/workflows/build-and-test-pr.yml index 7aea53bd2b01..dc085c530423 100644 --- a/.github/workflows/build-and-test-pr.yml +++ b/.github/workflows/build-and-test-pr.yml @@ -15,7 +15,7 @@ jobs: determine-affected: name: "Turbo Affected" if: ${{!github.event.pull_request.head.repo.fork }} - uses: LedgerHQ/ledger-live/.github/workflows/turbo-affected-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/turbo-affected-reusable.yml@chore/knip # removed after test with: head_branch: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }} base_branch: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }} @@ -25,14 +25,14 @@ jobs: name: "Build Desktop" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'ledger-live-desktop') && !github.event.pull_request.head.repo.fork }} - uses: LedgerHQ/ledger-live/.github/workflows/build-desktop-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/build-desktop-reusable.yml@chore/knip # removed after test secrets: inherit test-desktop: name: "Test Desktop" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'ledger-live-desktop') && !github.event.pull_request.head.repo.fork}} - uses: LedgerHQ/ledger-live/.github/workflows/test-desktop-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/test-desktop-reusable.yml@chore/knip # removed after test secrets: inherit # LLM @@ -40,21 +40,21 @@ jobs: name: "Build Mobile" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'ledger-live-mobile') && !github.event.pull_request.head.repo.fork}} - uses: LedgerHQ/ledger-live/.github/workflows/build-mobile-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/build-mobile-reusable.yml@chore/knip # removed after test secrets: inherit test-mobile: name: "Test Mobile" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'ledger-live-mobile') && !github.event.pull_request.head.repo.fork}} - uses: LedgerHQ/ledger-live/.github/workflows/test-mobile-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/test-mobile-reusable.yml@chore/knip # removed after test secrets: inherit test-mobile-e2e: name: "Test Mobile E2E" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'ledger-live-mobile') && !github.event.pull_request.head.repo.fork}} - uses: LedgerHQ/ledger-live/.github/workflows/test-mobile-e2e-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/test-mobile-e2e-reusable.yml@chore/knip # removed after test secrets: inherit # Tests @@ -62,7 +62,7 @@ jobs: name: "Test Libraries" needs: determine-affected if: ${{contains(needs.determine-affected.outputs.paths, 'libs') && !github.event.pull_request.head.repo.fork}} - uses: LedgerHQ/ledger-live/.github/workflows/test-libs-reusable.yml@develop + uses: LedgerHQ/ledger-live/.github/workflows/test-libs-reusable.yml@chore/knip # removed after test secrets: inherit test-design-system: diff --git a/.github/workflows/test-desktop-reusable.yml b/.github/workflows/test-desktop-reusable.yml index ed11840cfe59..ef97e5e9be8d 100644 --- a/.github/workflows/test-desktop-reusable.yml +++ b/.github/workflows/test-desktop-reusable.yml @@ -68,7 +68,7 @@ jobs: name: lint-desktop path: ${{ github.workspace }}/apps/ledger-live-desktop/lint-desktop.json - name: check for dead code - run: pnpm desktop unimported + run: pnpm desktop knip-check shell: bash unit-tests: diff --git a/.github/workflows/test-mobile-reusable.yml b/.github/workflows/test-mobile-reusable.yml index 8f55389d423f..db126e93fb13 100644 --- a/.github/workflows/test-mobile-reusable.yml +++ b/.github/workflows/test-mobile-reusable.yml @@ -53,7 +53,7 @@ jobs: - name: Run linter run: pnpm lint --filter="live-mobile" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" -- --format="json" -o="lint-mobile.json" - name: check for dead code - run: pnpm mobile unimported + run: pnpm mobile knip-check shell: bash - name: Run code checkers run: pnpm typecheck --filter="live-mobile" --api="http://127.0.0.1:${{ steps.toolchain.outputs.port }}" --token="${{ secrets.TURBOREPO_SERVER_TOKEN }}" --team="foo" diff --git a/CODEOWNERS b/CODEOWNERS index edd3ed1398a5..71b7d641d551 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -29,8 +29,8 @@ libs/live-countervalues-react/ @ledgerhq/live-hub libs/live-nft/ @ledgerhq/live-hub libs/live-nft-react/ @ledgerhq/live-hub libs/live-wallet/ @ledgerhq/live-hub -libs/trustchain/ @ledgerhq/live-hub -libs/hw-trustchain/ @ledgerhq/live-hub +libs/ledger-key-ring-protocol/ @ledgerhq/live-hub +libs/hw-ledger-key-ring-protocol/ @ledgerhq/live-hub # Blockchain team .github/**/bot-*.yml @ledgerhq/live-blockchain-support diff --git a/apps/ledger-live-desktop/.unimportedrc.json b/apps/ledger-live-desktop/.unimportedrc.json deleted file mode 100644 index 4ea42c55028b..000000000000 --- a/apps/ledger-live-desktop/.unimportedrc.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "entry": [ - "src/index.ts", - "src/renderer/index.ts", - "src/preloader/index.ts", - "src/renderer/webworkers/workers/*.ts", - "src/webviewPreloader/dappPreloader.ts", - "src/webviewPreloader/index.ts" - ], - "extensions": [".ts", ".js", ".jsx", ".tsx"], - "ignorePatterns": ["**/node_modules/**"], - "ignoreUnresolved": ["../../../../release-notes.json", "unzip-crx-3"], - "ignoreUnimported": [ - "**/*.test.*", - "**/*.spec.*", - "**/*.d.ts", - "**/types.js", - "**/types.*", - "node_modules/**", - "src/generate-cryptoassets-md.test.ts", - "src/generate-cryptoassets-md.ts", - - "src/newArch/features/Collectibles/**", - "src/newArch/features/WalletSync/__tests__/shared.tsx", - "src/renderer/DesktopStorageProvider.ts" - ], - "ignoreUnused": [ - "@types/semver", - "@types/qrcode", - "@types/react-key-handler", - "prop-types", - "allure-commandline", - "msw", - "undici" - ], - "aliases": { - "~/*": ["./src/*"] - } -} diff --git a/apps/ledger-live-desktop/package.json b/apps/ledger-live-desktop/package.json index fe7d8f764616..8eb9c6f6c3dd 100644 --- a/apps/ledger-live-desktop/package.json +++ b/apps/ledger-live-desktop/package.json @@ -48,8 +48,8 @@ "test:playwright:clean": "git clean -fdX tests/artifacts", "typecheck": "node scripts/typecheck.js", "check": "pnpm lint; pnpm typecheck", - "unimported": "unimported", - "assets:replace": "zx ./scripts/replace-assets.mjs" + "assets:replace": "zx ./scripts/replace-assets.mjs", + "knip-check": "pnpm knip --directory ../.. -W apps/ledger-live-desktop" }, "dependencies": { "@braze/web-sdk": "4.10.2", diff --git a/apps/ledger-live-mobile/.unimportedrc.json b/apps/ledger-live-mobile/.unimportedrc.json deleted file mode 100644 index 812172f14cf7..000000000000 --- a/apps/ledger-live-mobile/.unimportedrc.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "entry": ["index.js"], - "extensions": [".ts", ".js", ".jsx", ".tsx", ".d.ts"], - "ignorePatterns": ["**/node_modules/**"], - "ignoreUnresolved": [], - "ignoreUnimported": [ - "**/*.test.*", - "**/*.spec.*", - "**/*.d.ts", - "src/__test__/*", - "src/__tests__/*", - "src/**/__mocks__/*", - "src/**/*.android.*", - "src/**/*.ios.*", - "src/components/RootNavigator/types.ts", - "src/logic/keyboardVisible.ts", - "src/contentCards/cards/vertical/*", - "src/**/__integrations__/*.tsx", - "src/MobileStorageProvider.ts", - "src/newArch/features/WalletSync/components/Error/index.tsx", - "src/newArch/features/WalletSync/screens/Synchronize/PinCodeDisplay.tsx", - "src/newArch/features/WalletSync/screens/Synchronize/PinCodeInput.tsx" - ], - "ignoreUnused": [ - "@react-native-masked-view/masked-view", - "@react-native/gradle-plugin", - "@react-native/metro-config", - "@segment/sovran-react-native", - "expo-file-system", - "expo-image-loader", - "expo-modules-autolinking", - "expo-modules-core", - "expo-crypto", - "prop-types", - "react-native-codegen", - "react-native-fast-pbkdf2", - "react-native-level-fs", - "react-native-navigation-bar-color", - "react-native-os", - "react-native-randombytes", - "react-native-tcp", - "react-native-tcp-socket", - "react-native-udp" - ] -} diff --git a/apps/ledger-live-mobile/package.json b/apps/ledger-live-mobile/package.json index 626b4592e7a0..c755b0955fe4 100644 --- a/apps/ledger-live-mobile/package.json +++ b/apps/ledger-live-mobile/package.json @@ -68,7 +68,7 @@ "download-hermes-profile": "zx ./scripts/download-hermes-profile.mjs", "e2e:loadConfig": "ts-node ./e2e/bridge/start-server.ts", "check": "pnpm lint; pnpm typecheck", - "unimported": "unimported", + "knip-check": "pnpm knip --directory ../.. -W apps/ledger-live-mobile", "assets:replace": "zx ./scripts/replace-assets.mjs" }, "dependencies": { diff --git a/knip.json b/knip.json new file mode 100644 index 000000000000..8b7ba55ca38f --- /dev/null +++ b/knip.json @@ -0,0 +1,109 @@ +{ + "$schema": "https://unpkg.com/knip@5/schema.json", + "rules": { + "binaries": "off", + "classMembers": "off", + "dependencies": "error", + "devDependencies": "off", + "optionalPeerDependencies": "off", + "duplicates": "warn", + "enumMembers": "warn", + "exports": "warn", + "files": "error", + "nsExports": "off", + "nsTypes": "off", + "types": "warn", + "unlisted": "off", + "unresolved": "off" + }, + "ignoreExportsUsedInFile": true, + "project": ["src/**"], + + "ignore": [ + "**/__integrations__/*", + "**/*.test.*", + "**/*.spec.*", + "**/tests/**", + "**/__test__/**", + "**/__tests__/**", + "**/__mocks__/**", + "**/e2e/**", + "**/*.config.*" + ], + + "workspaces": { + "./apps/ledger-live-desktop": { + "entry": [ + "src/index.ts", + "src/renderer/index.ts", + "src/preloader/index.ts", + "src/renderer/webworkers/workers/*.ts", + "src/webviewPreloader/dappPreloader.ts", + "src/webviewPreloader/index.ts" + ], + "ignore": ["src/newArch/features/Collectibles/**", "**/types.*"], + "ignoreBinaries": ["eslint", "knip", "prettier", "zx", "lint"], + "ignoreDependencies": ["prop-types", "allure-commandline", "msw"] + }, + "./apps/ledger-live-mobile": { + "entry": ["index.js", "src/families/**"], + "ignore": ["src/**/*.android.*", "src/**/*.ios.*", "src/logic/keyboardVisible.ts"], + "ignoreDependencies": [ + "@react-native-masked-view/masked-view", + "@react-native/gradle-plugin", + "@react-native/metro-config", + "asyncstorage-down", + "buffer", + "expo-crypto", + "expo-file-system", + "expo-image-loader", + "expo-modules-autolinking", + "expo-modules-core", + "prop-types", + "react-native-fast-pbkdf2", + "react-native-level-fs", + "react-native-navigation-bar-color", + "react-native-randombytes", + "react-native-tcp-socket", + "react-native-udp" + ] + }, + "./libs/live-nft-react": { + "entry": ["src/index.ts", "src/tools/*", "src/hooks/*"] + }, + "./libs/live-nft": { + "entry": ["src/api/index.ts", "src/index.ts", "src/index.test.ts", "src/types.ts"] + }, + "./libs/env": { + "entry": ["src/index.ts"] + }, + "./libs/live-hooks": { + "entry": ["src/useDebounce.ts", "src/useThrottledFunction.ts"] + }, + "./libs/live-countervalues": { + "entry": ["src/logic.ts", "src/api/index.ts", "src/types.ts", "src/portfolio.ts"] + }, + "./libs/live-countervalues-react": { + "entry": ["src/index.tsx", "src/portfolio.tsx"] + }, + "./libs/live-wallet": { + "entry": [ + "src/walletsync/index.ts", + "src/cloudsync/index.ts", + "src/liveqr/cross.ts", + "src/liveqr/importAccounts.ts", + "src/ordering.ts", + "src/addAccounts.ts", + "src/store.ts", + "src/accountName.ts" + ] + }, + "./libs/ledger-key-ring-protocol": { + "entry": ["src/index.ts", "src/store.ts", "src/qrcode/index.ts"] + }, + "./libs/hw-ledger-key-ring-protocol": { + "entry": ["src/index.ts"], + "ignoreDependencies": ["@ledgerhq/logs", "@ledgerhq/live-env"] + } + } +} diff --git a/libs/env/.unimportedrc.json b/libs/env/.unimportedrc.json deleted file mode 100644 index cbe49f21aaf0..000000000000 --- a/libs/env/.unimportedrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "entry": ["src/index.ts"], - "ignoreUnimported": [], - "ignoreUnresolved": [] -} diff --git a/libs/env/package.json b/libs/env/package.json index 9d044a31ae73..f9938b945a6d 100644 --- a/libs/env/package.json +++ b/libs/env/package.json @@ -37,6 +37,6 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported" + "unimported": "pnpm knip --directory ../.. -W libs/env" } } diff --git a/libs/hw-ledger-key-ring-protocol/.unimportedrc.json b/libs/hw-ledger-key-ring-protocol/.unimportedrc.json deleted file mode 100644 index 3ee80ec81306..000000000000 --- a/libs/hw-ledger-key-ring-protocol/.unimportedrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/index.ts"], - "ignoreUnused": ["@ledgerhq/logs", "@ledgerhq/live-env"] -} diff --git a/libs/hw-ledger-key-ring-protocol/package.json b/libs/hw-ledger-key-ring-protocol/package.json index 5c041f2cace0..44a8a699338d 100644 --- a/libs/hw-ledger-key-ring-protocol/package.json +++ b/libs/hw-ledger-key-ring-protocol/package.json @@ -41,7 +41,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/hw-ledger-key-ring-protocol", "test": "jest" }, "typesVersions": { diff --git a/libs/ledger-key-ring-protocol/.unimportedrc.json b/libs/ledger-key-ring-protocol/.unimportedrc.json deleted file mode 100644 index 15af0c544900..000000000000 --- a/libs/ledger-key-ring-protocol/.unimportedrc.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "entry": ["src/index.ts", "src/store.ts", "src/qrcode/index.ts"], - "ignorePatterns": [ - "**/node_modules/**", - "**/*.test.ts", - "**/__tests__/**", - "**/test-scenarios/**", - "**/test-helpers/**" - ], - "ignoreUnused": [ - "@ledgerhq/hw-transport-mocker", - "@ledgerhq/speculos-transport", - "@ledgerhq/types-devices", - "@ledgerhq/live-env" - ] -} diff --git a/libs/ledger-key-ring-protocol/package.json b/libs/ledger-key-ring-protocol/package.json index 7e4cc770a5a5..cc1121083235 100644 --- a/libs/ledger-key-ring-protocol/package.json +++ b/libs/ledger-key-ring-protocol/package.json @@ -84,7 +84,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/ledger-key-ring-protocol", "test": "jest", "e2e": "ts-node scripts/e2e.ts" } diff --git a/libs/live-countervalues-react/.unimportedrc.json b/libs/live-countervalues-react/.unimportedrc.json deleted file mode 100644 index 206907d69c3f..000000000000 --- a/libs/live-countervalues-react/.unimportedrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/index.tsx", "src/portfolio.tsx"], - "ignoreUnused": ["@ledgerhq/cryptoassets"] -} diff --git a/libs/live-countervalues-react/package.json b/libs/live-countervalues-react/package.json index 24b85b7f0394..9d3bd801e158 100644 --- a/libs/live-countervalues-react/package.json +++ b/libs/live-countervalues-react/package.json @@ -50,7 +50,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-countervalues-react", "test": "jest" }, "typesVersions": { diff --git a/libs/live-countervalues/.unimportedrc.json b/libs/live-countervalues/.unimportedrc.json deleted file mode 100644 index d118f08853dc..000000000000 --- a/libs/live-countervalues/.unimportedrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/logic.ts", "src/api/index.ts", "src/types.ts", "src/portfolio.ts"], - "ignoreUnused": ["@ledgerhq/cryptoassets"] -} diff --git a/libs/live-countervalues/package.json b/libs/live-countervalues/package.json index cc2e2c4404c8..a638c8349e37 100644 --- a/libs/live-countervalues/package.json +++ b/libs/live-countervalues/package.json @@ -44,7 +44,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-countervalues", "test": "jest" }, "typesVersions": { diff --git a/libs/live-hooks/.unimportedrc.json b/libs/live-hooks/.unimportedrc.json deleted file mode 100644 index 3cf5f8f13486..000000000000 --- a/libs/live-hooks/.unimportedrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "entry": ["src/useDebounce.ts", "src/useThrottledFunction.ts"], - "ignoreUnimported": [], - "ignoreUnresolved": [] -} diff --git a/libs/live-hooks/package.json b/libs/live-hooks/package.json index c16aa78068a1..0299a630a078 100644 --- a/libs/live-hooks/package.json +++ b/libs/live-hooks/package.json @@ -41,7 +41,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-hooks", "test": "jest" }, "typesVersions": { diff --git a/libs/live-nft-react/.unimportedrc.json b/libs/live-nft-react/.unimportedrc.json deleted file mode 100644 index 187a263de59b..000000000000 --- a/libs/live-nft-react/.unimportedrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/index.ts", "src/tools/*", "src/hooks/*"], - "ignoreUnused": ["@ledgerhq/coin-framework/nft/nftId"] -} diff --git a/libs/live-nft-react/package.json b/libs/live-nft-react/package.json index 31b0ac11b3fe..639c3ea6a66c 100644 --- a/libs/live-nft-react/package.json +++ b/libs/live-nft-react/package.json @@ -50,7 +50,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-nft-react", "test": "jest" }, "typesVersions": { diff --git a/libs/live-nft/.unimportedrc.json b/libs/live-nft/.unimportedrc.json deleted file mode 100644 index b6725fd9c9e7..000000000000 --- a/libs/live-nft/.unimportedrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "entry": ["src/api/*", "src/index.ts", "src/index.test.ts", "src/types.ts"], - "ignoreUnused": [] -} diff --git a/libs/live-nft/package.json b/libs/live-nft/package.json index 2fe250533fe9..18bc6f6407b7 100644 --- a/libs/live-nft/package.json +++ b/libs/live-nft/package.json @@ -42,7 +42,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-nft", "test": "jest" }, "typesVersions": { diff --git a/libs/live-wallet/.unimportedrc.json b/libs/live-wallet/.unimportedrc.json deleted file mode 100644 index 38730cf69452..000000000000 --- a/libs/live-wallet/.unimportedrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "entry": [ - "src/walletsync/index.ts", - "src/cloudsync/index.ts", - "src/liveqr/cross.ts", - "src/liveqr/importAccounts.ts", - "src/ordering.ts", - "src/addAccounts.ts", - "src/store.ts", - "src/accountName.ts" - ], - "ignoreUnresolved": ["bufferutil", "utf-8-validate"], - "ignorePatterns": [ - "**/node_modules/**", - "**/__tests__/**", - "**/*.test.ts", - "walletsync/__mocks__/**" - ] -} diff --git a/libs/live-wallet/package.json b/libs/live-wallet/package.json index 794e1fbc4f2e..039d4964a4a2 100644 --- a/libs/live-wallet/package.json +++ b/libs/live-wallet/package.json @@ -60,7 +60,7 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "typecheck": "tsc --noEmit", - "unimported": "unimported", + "unimported": "pnpm knip --directory ../.. -W libs/live-wallet", "test": "jest" }, "typesVersions": { diff --git a/package.json b/package.json index 51f212be3c46..0ecab27003b2 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "lint": "pnpm turbo lint --no-daemon", "lint:fix": "pnpm turbo lint:fix --no-daemon", "typecheck": "pnpm turbo typecheck --no-daemon", + "knip-check": "pnpm turbo knip-check --no-daemon", "unimported": "pnpm turbo unimported", "desktop": "pnpm --filter ledger-live-desktop", "cli": "pnpm --filter live-cli", @@ -171,6 +172,7 @@ "eslint-config-prettier": "9.1.0", "eslint-plugin-json": "3.1.0", "eslint-plugin-prettier": "5.1.3", + "knip": "5.34.1", "nyc": "15.1.0", "prettier": "3.2.5", "rimraf": "4.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d24efb66089f..3bb72f8add70 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,6 +102,9 @@ importers: eslint-plugin-prettier: specifier: 5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.2.5) + knip: + specifier: 5.34.1 + version: 5.34.1(typescript@5.4.3) nyc: specifier: 15.1.0 version: 15.1.0 @@ -13179,6 +13182,11 @@ packages: resolution: {integrity: sha512-OU0YllH51/CxD8iyr3UHSMwYqTGTyuxFdCMH/0F978t+iDmJseC/ttrWPb22zmYkhkrjqtipzC1xaMuax5QKIA==} engines: {node: '>=16.0.0'} + '@snyk/github-codeowners@1.1.0': + resolution: {integrity: sha512-lGFf08pbkEac0NYgVf4hdANpAgApRjNByLXB+WBip3qj1iendOIyAwP2GKkKbQMNVy2r1xxDf0ssfWscoiC+Vw==} + engines: {node: '>=8.10'} + hasBin: true + '@soda/friendly-errors-webpack-plugin@1.8.1': resolution: {integrity: sha512-h2ooWqP8XuFqTXT+NyAFbrArzfQA7R6HTezADrvD9Re8fxMLTPPniLdqVTdDaO0eIoLaAwKT+d6w+5GeTk7Vbg==} engines: {node: '>=8.0.0'} @@ -19001,6 +19009,9 @@ packages: resolution: {integrity: sha512-wK2sCs4feiiJeFXn3zvY0p41mdU5VUgbgs1rNsc/y5ngFUijdWd+iIN8eoyuZHKB8xN6BL4PdWmzqFmxNg6V2w==} engines: {node: '>=6.0.0'} + easy-table@1.2.0: + resolution: {integrity: sha512-OFzVOv03YpvtcWGe5AayU5G2hgybsg3iqA6drU8UaoZyB9jLGMTrz9+asnLp/E+6qPh88yEI1gvyZFZ41dmgww==} + ecc-jsbn@0.1.2: resolution: {integrity: sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==} @@ -22610,6 +22621,10 @@ packages: resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} hasBin: true + jiti@2.3.3: + resolution: {integrity: sha512-EX4oNDwcXSivPrw2qKH2LB5PoFxEvgtv2JgwW0bU858HoLQ+kutSvjLMUqBd0PeJYEinLWhoI9Ol0eYMqj/wNQ==} + hasBin: true + jmespath@0.15.0: resolution: {integrity: sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w==} engines: {node: '>= 0.6.0'} @@ -22946,6 +22961,14 @@ packages: resolution: {integrity: sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==} engines: {node: '>= 8'} + knip@5.34.1: + resolution: {integrity: sha512-MwQjEWBxsi7MnTL3JpLJwYRhqD1262Fv+TylMYDyZRAVJMmEs4y0qie5zv8VjU5DBSGoEs35Ssu7I/2klNOQgw==} + engines: {node: '>=18.6.0'} + hasBin: true + peerDependencies: + '@types/node': '>=18' + typescript: '>=5.0.4' + known-css-properties@0.26.0: resolution: {integrity: sha512-5FZRzrZzNTBruuurWpvZnvP9pum+fe0HcK8z/ooo+U+Hmp4vtbyp1/QDsqmufirXy4egGzbaH/y2uCZf+6W5Kg==} @@ -25074,6 +25097,10 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parse-ms@4.0.0: + resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} + engines: {node: '>=18'} + parse-numeric-range@1.3.0: resolution: {integrity: sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==} @@ -25900,6 +25927,10 @@ packages: resolution: {integrity: sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==} engines: {node: '>= 0.8'} + pretty-ms@9.1.0: + resolution: {integrity: sha512-o1piW0n3tgKIKCwk2vpM/vOV13zjJzvP37Ioze54YlTHE06m4tjEbzg9WsKkvTuyYln2DHjo5pY4qrZGI0otpw==} + engines: {node: '>=18'} + probot@13.2.2: resolution: {integrity: sha512-wx8VoNb0ujn2k3nq0MSIUd4r7/RUn2Di3ZY07F6O5IYm3z3HNGDDX2XEreJnaZDOFjQaZ6XJbYGmiaD4SovAVQ==} engines: {node: '>=18'} @@ -27772,6 +27803,10 @@ packages: resolution: {integrity: sha512-Tv3AVvZD9sjEwBvsm1jc8to96FwmZMOYt5UL7qu3vAuA/3F/hqKe9gdRSlkvpRO4ttUAUrDKRpjM0vUnXZQhqA==} hasBin: true + smol-toml@1.3.0: + resolution: {integrity: sha512-tWpi2TsODPScmi48b/OQZGi2lgUmBCHy6SZrhi/FdnnHiU1GwebbCfuQuxsC3nHaLwtYeJGPrDZDIeodDOc4pA==} + engines: {node: '>= 18'} + smoldot@2.0.22: resolution: {integrity: sha512-B50vRgTY6v3baYH6uCgL15tfaag5tcS2o/P5q1OiXcKGv1axZDfz2dzzMuIkVpyMR2ug11F6EAtQlmYBQd292g==} @@ -28326,6 +28361,9 @@ packages: resolution: {integrity: sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==} engines: {node: '>= 8.0'} + summary@2.1.0: + resolution: {integrity: sha512-nMIjMrd5Z2nuB2RZCKJfFMjgS3fygbeyGk9PxPPaJR1RIcyN9yn4A63Isovzm3ZtQuEkLBVgMdPup8UeLH7aQw==} + superagent@6.1.0: resolution: {integrity: sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==} engines: {node: '>= 7.0.0'} @@ -30622,6 +30660,12 @@ packages: peerDependencies: zod: ^3.18.0 + zod-validation-error@3.4.0: + resolution: {integrity: sha512-ZOPR9SVY6Pb2qqO5XHt+MkkTRxGXb4EVtnjc9JpXUOtUB1T9Ru7mZOT361AN3MsetVe7R0a1KZshJDZdgp9miQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + zod: ^3.18.0 + zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} @@ -40787,6 +40831,12 @@ snapshots: '@smithy/types': 3.4.0 tslib: 2.6.2 + '@snyk/github-codeowners@1.1.0': + dependencies: + commander: 4.1.1 + ignore: 5.3.1 + p-map: 4.0.0 + '@soda/friendly-errors-webpack-plugin@1.8.1(webpack@5.94.0)': dependencies: chalk: 3.0.0 @@ -49426,6 +49476,12 @@ snapshots: easy-stack@1.0.1: {} + easy-table@1.2.0: + dependencies: + ansi-regex: 5.0.1 + optionalDependencies: + wcwidth: 1.0.1 + ecc-jsbn@0.1.2: dependencies: jsbn: 0.1.1 @@ -55247,6 +55303,8 @@ snapshots: jiti@1.21.0: {} + jiti@2.3.3: {} + jmespath@0.15.0: {} joi@17.12.2: @@ -55753,6 +55811,26 @@ snapshots: klona@2.0.6: {} + knip@5.34.1(typescript@5.4.3): + dependencies: + '@nodelib/fs.walk': 1.2.8 + '@snyk/github-codeowners': 1.1.0 + easy-table: 1.2.0 + enhanced-resolve: 5.17.1 + fast-glob: 3.3.2 + jiti: 2.3.3 + js-yaml: 4.1.0 + minimist: 1.2.8 + picocolors: 1.0.0 + picomatch: 4.0.2 + pretty-ms: 9.1.0 + smol-toml: 1.3.0 + strip-json-comments: 5.0.1 + summary: 2.1.0 + typescript: 5.4.3 + zod: 3.23.8 + zod-validation-error: 3.4.0(zod@3.23.8) + known-css-properties@0.26.0: {} koa-bodyparser@4.4.1: @@ -58868,6 +58946,8 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parse-ms@4.0.0: {} + parse-numeric-range@1.3.0: {} parse-path@7.0.0: @@ -59916,6 +59996,10 @@ snapshots: pretty-hrtime@1.0.3: {} + pretty-ms@9.1.0: + dependencies: + parse-ms: 4.0.0 + probot@13.2.2: dependencies: '@octokit/core': 5.1.0 @@ -62492,6 +62576,8 @@ snapshots: transitivePeerDependencies: - supports-color + smol-toml@1.3.0: {} + smoldot@2.0.22: dependencies: ws: 8.17.1 @@ -63275,6 +63361,8 @@ snapshots: transitivePeerDependencies: - supports-color + summary@2.1.0: {} + superagent@6.1.0: dependencies: component-emitter: 1.3.1 @@ -66853,6 +66941,10 @@ snapshots: dependencies: zod: 3.23.8 + zod-validation-error@3.4.0(zod@3.23.8): + dependencies: + zod: 3.23.8 + zod@3.22.4: {} zod@3.23.8: {} diff --git a/turbo.json b/turbo.json index 10083face441..b20a1090b618 100644 --- a/turbo.json +++ b/turbo.json @@ -81,6 +81,9 @@ "unimported": { "cache": false }, + "knip-check": { + "cache": false + }, "android:apk:local": { "dependsOn": ["^build"] },