From 7cd906c46d9a196221993d58dcd2a95fba497d29 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/test-desktop-reusable.yml | 2 +- .github/workflows/test-mobile-reusable.yml | 2 +- CODEOWNERS | 10 +- 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 | 112 ++++++++++++++++++ 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 +- libs/promise/.unimportedrc.json | 5 - libs/promise/package.json | 2 +- package.json | 2 + pnpm-lock.yaml | 104 +++++++++++++++- turbo.json | 3 + 31 files changed, 233 insertions(+), 182 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 delete mode 100644 libs/promise/.unimportedrc.json 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..487735fc58c9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -23,14 +23,9 @@ libs/live-nft-react/ @ledgerhq/live-hub libs/live-nft/ @ledgerhq/live-hub libs/promise/ @ledgerhq/live-hub libs/ui/ @ledgerhq/live-hub -libs/live-hooks/ @ledgerhq/live-hub -libs/live-countervalues/ @ledgerhq/live-hub -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 @@ -77,6 +72,7 @@ libs/ledger-live-common/src/exchange/ @ledgerhq/p libs/exchange-module/ @ledgerhq/ptx libs/wallet-api-acre-module/ @ledgerhq/ptx libs/ledgerjs/packages/hw-app-exchange/ @ledgerhq/ptx + # Wallet API team **/PlatformAppProviderWrapper.tsx @ledgerhq/wallet-api **/Web3AppWebview/ @ledgerhq/wallet-api 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 fe5228c266d4..85662fd51056 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 a6775cb7f42a..b17e855b9eb4 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..8fa93bfc396a --- /dev/null +++ b/knip.json @@ -0,0 +1,112 @@ +{ + "$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.*", + "**/scripts/**", + "**/tools/**" + ], + + "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"] + }, + "./libs/promise": { "entry": ["src/index.ts"] } + } +} 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 880eee1f3249..28f457fff87b 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 55bed1a9ab12..11565e5d6253 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 f4b2f65afc28..30d1f7320847 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 417a9b1373e8..c272a8dc00d9 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 acf45f5b0c72..44a0d791d4b7 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/libs/promise/.unimportedrc.json b/libs/promise/.unimportedrc.json deleted file mode 100644 index cbe49f21aaf0..000000000000 --- a/libs/promise/.unimportedrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "entry": ["src/index.ts"], - "ignoreUnimported": [], - "ignoreUnresolved": [] -} diff --git a/libs/promise/package.json b/libs/promise/package.json index 64098bd689ed..83fc8a0f17c9 100644 --- a/libs/promise/package.json +++ b/libs/promise/package.json @@ -36,6 +36,6 @@ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", "lint:fix": "pnpm lint --fix", "test": "jest", - "unimported": "unimported" + "unimported": "pnpm knip --directory ../.. -W libs/promise" } } diff --git a/package.json b/package.json index 51f212be3c46..2565d4b35504 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", "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 0cbfcedb0e61..6a4db72917dc 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 @@ -13271,6 +13274,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'} @@ -19110,6 +19118,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==} @@ -22726,6 +22737,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'} @@ -23062,6 +23077,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==} @@ -25197,6 +25220,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==} @@ -26026,6 +26053,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'} @@ -27903,6 +27934,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==} @@ -28457,6 +28492,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'} @@ -30795,6 +30833,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==} @@ -32166,7 +32210,7 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 chalk: 2.4.2 js-tokens: 4.0.0 - picocolors: 1.0.0 + picocolors: 1.1.1 '@babel/parser@7.24.1': dependencies: @@ -41008,6 +41052,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.95.0)': dependencies: chalk: 3.0.0 @@ -46459,7 +46509,7 @@ snapshots: caniuse-lite: 1.0.30001600 fraction.js: 4.3.7 normalize-range: 0.1.2 - picocolors: 1.0.0 + picocolors: 1.1.1 postcss: 8.4.32 postcss-value-parser: 4.2.0 @@ -46469,7 +46519,7 @@ snapshots: caniuse-lite: 1.0.30001600 fraction.js: 4.3.7 normalize-range: 0.1.2 - picocolors: 1.0.0 + picocolors: 1.1.1 postcss: 8.4.38 postcss-value-parser: 4.2.0 @@ -49689,6 +49739,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 @@ -55511,6 +55567,8 @@ snapshots: jiti@1.21.0: {} + jiti@2.3.3: {} + jmespath@0.15.0: {} joi@17.12.2: @@ -56017,6 +56075,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.1.1 + 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: @@ -56142,7 +56220,7 @@ snapshots: launch-editor@2.8.0: dependencies: - picocolors: 1.0.0 + picocolors: 1.1.1 shell-quote: 1.8.1 layout-base@1.0.2: {} @@ -59142,6 +59220,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: @@ -60192,6 +60272,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 @@ -62790,6 +62874,8 @@ snapshots: transitivePeerDependencies: - supports-color + smol-toml@1.3.0: {} + smoldot@2.0.22: dependencies: ws: 8.17.1 @@ -63569,6 +63655,8 @@ snapshots: transitivePeerDependencies: - supports-color + summary@2.1.0: {} + superagent@6.1.0: dependencies: component-emitter: 1.3.1 @@ -65217,7 +65305,7 @@ snapshots: dependencies: browserslist: 4.23.0 escalade: 3.1.2 - picocolors: 1.0.0 + picocolors: 1.1.1 update-browserslist-db@1.1.1(browserslist@4.24.2): dependencies: @@ -66109,7 +66197,7 @@ snapshots: gzip-size: 6.0.0 html-escaper: 2.0.2 opener: 1.5.2 - picocolors: 1.0.0 + picocolors: 1.1.1 sirv: 2.0.4 ws: 7.5.10 transitivePeerDependencies: @@ -67163,6 +67251,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"] },