diff --git a/.gitignore b/.gitignore index ca324d052..31fc8882b 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ scripts/coverage # typescript packages/*/*.tsbuildinfo *.tsbuildinfo +packages/*/.tsc-lint-cache +.tsc-lint-cache # AI .sisyphus/ diff --git a/package.json b/package.json index 105c1c46b..fe2aec244 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,14 @@ "changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate", "create-release-branch": "create-release-branch --formatter oxfmt", "create-package": "tsx scripts/create-package", - "lint": "yarn lint:eslint && echo && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn readme-content:check", + "lint": "yarn lint:tsc && yarn lint:eslint && echo && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn readme-content:check", "lint:dependencies": "depcheck && yarn dedupe --check", "lint:dependencies:fix": "depcheck && yarn dedupe", "lint:eslint": "yarn build:only-clean && NODE_OPTIONS='--max-old-space-size=6144' yarn eslint", "lint:fix": "yarn lint:eslint --fix --prune-suppressions && echo && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix && yarn readme-content:update", "lint:misc": "oxfmt --ignore-path .gitignore", "lint:misc:check": "yarn lint:misc --check", + "lint:tsc": "tsc --build tsconfig.lint.json", "prepack": "./scripts/prepack.sh", "prepare-preview-builds": "./scripts/prepare-preview-builds.sh", "readme-content:check": "tsx scripts/update-readme-content.ts --check", diff --git a/packages/bitcoin-wallet-snap/CHANGELOG.md b/packages/bitcoin-wallet-snap/CHANGELOG.md index 570452d8e..801e1420c 100644 --- a/packages/bitcoin-wallet-snap/CHANGELOG.md +++ b/packages/bitcoin-wallet-snap/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Add a TypeScript project reference to `@metamask/snap-networks-utils` in `tsconfig.json`, mirroring the pattern used in `MetaMask/core`, for correct `tsc --build` ordering and editor go-to-source navigation ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) +- Add an explicit `@metamask/snap-networks-utils/*` subpath entry to the shared `paths` mapping and expand `tsconfig.lint.json`'s `include` pattern, so the `tsc --build` lint graph resolves the workspace source and covers `snap.manifest.json`/JSON test fixtures, matching `MetaMask/core`'s setup ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) + ## [2.0.1] ### Fixed diff --git a/packages/bitcoin-wallet-snap/tsconfig.json b/packages/bitcoin-wallet-snap/tsconfig.json index a8a6abb0f..34352b8df 100644 --- a/packages/bitcoin-wallet-snap/tsconfig.json +++ b/packages/bitcoin-wallet-snap/tsconfig.json @@ -15,5 +15,6 @@ "moduleResolution": "bundler", "types": ["jest"] }, + "references": [{ "path": "../snap-networks-utils" }], "include": ["**/*.ts", "**/*.tsx", "locales/*.json"] } diff --git a/packages/bitcoin-wallet-snap/tsconfig.lint.json b/packages/bitcoin-wallet-snap/tsconfig.lint.json new file mode 100644 index 000000000..31970fe83 --- /dev/null +++ b/packages/bitcoin-wallet-snap/tsconfig.lint.json @@ -0,0 +1,15 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + }, + "references": [{ "path": "../snap-networks-utils/tsconfig.lint.json" }], + "include": [ + "**/*.ts", + "**/*.tsx", + "locales/*.json", + "snap.manifest.json", + "src/**/*.json" + ] +} diff --git a/packages/sample-snap/tsconfig.lint.json b/packages/sample-snap/tsconfig.lint.json new file mode 100644 index 000000000..378ed1dce --- /dev/null +++ b/packages/sample-snap/tsconfig.lint.json @@ -0,0 +1,7 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + } +} diff --git a/packages/snap-networks-utils/CHANGELOG.md b/packages/snap-networks-utils/CHANGELOG.md index dac68b80a..880dce417 100644 --- a/packages/snap-networks-utils/CHANGELOG.md +++ b/packages/snap-networks-utils/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Add a `tsconfig.lint.json` (`outDir`/`tsBuildInfoFile` → `.tsc-lint-cache`) so this package participates in the repo's `tsc --build` lint graph, mirroring `MetaMask/core`'s setup ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) - **BREAKING** Replace the logger utilities with a configurable `Logger` class that requires a log level and supports level filtering, per-instance prefixes, and method decorators. - Bump `@metamask/utils` from `^11.9.0` to `^11.11.9` ([#161](https://github.com/MetaMask/internal-snaps/pull/161)) diff --git a/packages/snap-networks-utils/tsconfig.lint.json b/packages/snap-networks-utils/tsconfig.lint.json new file mode 100644 index 000000000..378ed1dce --- /dev/null +++ b/packages/snap-networks-utils/tsconfig.lint.json @@ -0,0 +1,7 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + } +} diff --git a/packages/solana-wallet-snap/CHANGELOG.md b/packages/solana-wallet-snap/CHANGELOG.md index ab6dd1dbf..aecf09600 100644 --- a/packages/solana-wallet-snap/CHANGELOG.md +++ b/packages/solana-wallet-snap/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Add a TypeScript project reference to `@metamask/snap-networks-utils` in `tsconfig.json`, mirroring the pattern used in `MetaMask/core`, for correct `tsc --build` ordering and editor go-to-source navigation ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) +- Add an explicit `@metamask/snap-networks-utils/*` subpath entry to the shared `paths` mapping and expand `tsconfig.lint.json`'s `include` pattern, so the `tsc --build` lint graph resolves the workspace source and covers `snap.manifest.json`/JSON test fixtures, matching `MetaMask/core`'s setup ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) - Extract Snap-owned assets domain logic into `SnapAssetsAdapter`; `AssetsService` is a thin facade that delegates metadata, market data, fetch, persist, and account asset reads through the adapter (no Core routing yet). ([#121](https://github.com/MetaMask/internal-snaps/pull/121)) - Align `AssetsService` read API with `snap-networks-utils` / AssetsController shapes by adding `getAccountAssetByID`, `getAccountAssetsByIDs`, `getAccountAssetsByScope`, and `getAccountAssets`, and routing Keyring and Send through them (still Snap-owned storage). ([#120](https://github.com/MetaMask/internal-snaps/pull/120)) diff --git a/packages/solana-wallet-snap/tsconfig.json b/packages/solana-wallet-snap/tsconfig.json index 3eb63f359..11f05f5bf 100644 --- a/packages/solana-wallet-snap/tsconfig.json +++ b/packages/solana-wallet-snap/tsconfig.json @@ -16,5 +16,6 @@ "moduleResolution": "bundler", "types": ["jest"] }, + "references": [{ "path": "../snap-networks-utils" }], "include": ["**/*.ts", "**/*.tsx", "locales/*.json"] } diff --git a/packages/solana-wallet-snap/tsconfig.lint.json b/packages/solana-wallet-snap/tsconfig.lint.json new file mode 100644 index 000000000..31970fe83 --- /dev/null +++ b/packages/solana-wallet-snap/tsconfig.lint.json @@ -0,0 +1,15 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + }, + "references": [{ "path": "../snap-networks-utils/tsconfig.lint.json" }], + "include": [ + "**/*.ts", + "**/*.tsx", + "locales/*.json", + "snap.manifest.json", + "src/**/*.json" + ] +} diff --git a/packages/stellar-wallet-snap/CHANGELOG.md b/packages/stellar-wallet-snap/CHANGELOG.md index e6268ac1d..2a3cb8f04 100644 --- a/packages/stellar-wallet-snap/CHANGELOG.md +++ b/packages/stellar-wallet-snap/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Set `baseUrl` in this package's `tsconfig.json` (matching every other package in the monorepo) and add an explicit `@metamask/snap-networks-utils/*` subpath entry to the shared `paths` mapping and expand `tsconfig.lint.json`'s `include` pattern, so the `tsc --build` lint graph resolves the workspace source and covers `snap.manifest.json`/JSON test fixtures, matching `MetaMask/core`'s setup ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) - This package was migrated from [snap-stellar-wallet](https://github.com/MetaMask/snap-stellar-wallet). See the source repository for the original [changelog](https://github.com/MetaMask/snap-stellar-wallet/blob/main/packages/snap/CHANGELOG.md) ([#161](https://github.com/MetaMask/internal-snaps/pull/161)) ### Fixed diff --git a/packages/stellar-wallet-snap/tsconfig.json b/packages/stellar-wallet-snap/tsconfig.json index df5a8f6b6..226043f20 100644 --- a/packages/stellar-wallet-snap/tsconfig.json +++ b/packages/stellar-wallet-snap/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.packages.json", "compilerOptions": { + "baseUrl": "./", "resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */, "jsx": "react-jsx", "jsxImportSource": "@metamask/snaps-sdk", diff --git a/packages/stellar-wallet-snap/tsconfig.lint.json b/packages/stellar-wallet-snap/tsconfig.lint.json new file mode 100644 index 000000000..577502c34 --- /dev/null +++ b/packages/stellar-wallet-snap/tsconfig.lint.json @@ -0,0 +1,14 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + }, + "include": [ + "**/*.ts", + "**/*.tsx", + "locales/*.json", + "snap.manifest.json", + "src/**/*.json" + ] +} diff --git a/packages/tron-wallet-snap/CHANGELOG.md b/packages/tron-wallet-snap/CHANGELOG.md index 733239f5e..1f2ffce67 100644 --- a/packages/tron-wallet-snap/CHANGELOG.md +++ b/packages/tron-wallet-snap/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Add a TypeScript project reference to `@metamask/snap-networks-utils` in `tsconfig.json`, mirroring the pattern used in `MetaMask/core`, for correct `tsc --build` ordering and editor go-to-source navigation ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) +- Set `baseUrl` in this package's `tsconfig.json` (matching every other package in the monorepo) and add an explicit `@metamask/snap-networks-utils/*` subpath entry to the shared `paths` mapping and expand `tsconfig.lint.json`'s `include` pattern, so the `tsc --build` lint graph resolves the workspace source and covers `snap.manifest.json`/JSON test fixtures, matching `MetaMask/core`'s setup ([#170](https://github.com/MetaMask/internal-snaps/pull/170)) - Extract shared asset util functions and inject `SnapAssetsAdapter` from `context` into `AssetsService` ([#143](https://github.com/MetaMask/internal-snaps/pull/143)) - Rename `getByKeyringAccountId` to `getAccountAssets` (with essential-asset synthesis) and update keyring callers ([#143](https://github.com/MetaMask/internal-snaps/pull/143)) diff --git a/packages/tron-wallet-snap/tsconfig.json b/packages/tron-wallet-snap/tsconfig.json index df5a8f6b6..aa6bd53f5 100644 --- a/packages/tron-wallet-snap/tsconfig.json +++ b/packages/tron-wallet-snap/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.packages.json", "compilerOptions": { + "baseUrl": "./", "resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */, "jsx": "react-jsx", "jsxImportSource": "@metamask/snaps-sdk", @@ -15,5 +16,6 @@ "moduleResolution": "bundler", "types": ["jest"] }, + "references": [{ "path": "../snap-networks-utils" }], "include": ["**/*.ts", "**/*.tsx", "locales/*.json"] } diff --git a/packages/tron-wallet-snap/tsconfig.lint.json b/packages/tron-wallet-snap/tsconfig.lint.json new file mode 100644 index 000000000..31970fe83 --- /dev/null +++ b/packages/tron-wallet-snap/tsconfig.lint.json @@ -0,0 +1,15 @@ +{ + "extends": ["./tsconfig.json", "../../tsconfig.packages.lint.json"], + "compilerOptions": { + "outDir": "./.tsc-lint-cache", + "tsBuildInfoFile": "./.tsc-lint-cache/tsconfig.tsbuildinfo" + }, + "references": [{ "path": "../snap-networks-utils/tsconfig.lint.json" }], + "include": [ + "**/*.ts", + "**/*.tsx", + "locales/*.json", + "snap.manifest.json", + "src/**/*.json" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 8555d5148..23df98f6d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,8 +9,23 @@ "skipLibCheck": true }, "references": [ + { + "path": "./packages/bitcoin-wallet-snap" + }, + { + "path": "./packages/sample-snap" + }, { "path": "./packages/snap-networks-utils" + }, + { + "path": "./packages/solana-wallet-snap" + }, + { + "path": "./packages/stellar-wallet-snap" + }, + { + "path": "./packages/tron-wallet-snap" } ], "files": [], diff --git a/tsconfig.lint.json b/tsconfig.lint.json new file mode 100644 index 000000000..754f4e7c2 --- /dev/null +++ b/tsconfig.lint.json @@ -0,0 +1,30 @@ +{ + /** + * This configuration incrementally enables repository-wide type checking. + */ + "extends": "./tsconfig.json", + "compilerOptions": { + "skipLibCheck": true, + "tsBuildInfoFile": "./.tsc-lint-cache/lint.tsbuildinfo" + }, + "references": [ + { + "path": "./packages/bitcoin-wallet-snap/tsconfig.lint.json" + }, + { + "path": "./packages/sample-snap/tsconfig.lint.json" + }, + { + "path": "./packages/snap-networks-utils/tsconfig.lint.json" + }, + { + "path": "./packages/solana-wallet-snap/tsconfig.lint.json" + }, + { + "path": "./packages/stellar-wallet-snap/tsconfig.lint.json" + }, + { + "path": "./packages/tron-wallet-snap/tsconfig.lint.json" + } + ] +} diff --git a/tsconfig.packages.json b/tsconfig.packages.json index a655abc1f..d17e3697d 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -12,6 +12,7 @@ * `jest.config.packages.js`. */ "paths": { + "@metamask/snap-networks-utils/*": ["../snap-networks-utils/src/*"], "@metamask/*": ["../*/src"] } } diff --git a/tsconfig.packages.lint.json b/tsconfig.packages.lint.json new file mode 100644 index 000000000..9d6e40495 --- /dev/null +++ b/tsconfig.packages.lint.json @@ -0,0 +1,9 @@ +{ + /** + * This configuration is extended by each package's `tsconfig.lint.json` configuration. + */ + "compilerOptions": { + "emitDeclarationOnly": true, + "skipLibCheck": true + } +}