Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit fde4083

Browse files
authored
refactor!: Synchronize dev toolchain with module template and core monorepo (#351)
Synchronizes package meta-files with [MetaMask/metamask-module-template](https://github.com/MetaMask/metamask-module-template) and [MetaMask/core](https://github.com/MetaMask/core). Changes exclude source code and other published files with the following exceptions: - `package.json`, most notably its `exports` field - This is due to adding fields expected by our Yarn constraints and migrating to `ts-bridge` for builds. - Published files are split into `.cjs` and `.mjs` trees per `ts-bridge` In detail (all changes per module template unless otherwise specified): - Use `ts-bridge` - Bump `eslint`, `prettier`, and related dependencies - Add `eslint.config.mjs` - Preserve previous lint configuration to the greatest extent possible - Some changes are made to test files - `index.ts` and `PollingBlockTracker.ts` received some non-behavioral, type-related lint modifications - Add and use `@arethetypeswrong/cli` - Add and use `typedoc` - Update `.yarnrc.yml` and add `yarn.config.cjs` - Update `package.json` - Bump `typescript` from `4.x` to `~5.2.2` - Downgrade `jest` and related dependencies from `^29` to `^27` - Update `tsconfig` files per `ts-bridge` conventions - Lint all files per updated config - Set the following rules to `warn`: - `@typescript-eslint/prefer-nullish-coalescing`, to avoid behavioral changes - `@typescript-eslint/explicit-function-return-type`, because too many violations to fix right now Work intentionally avoided in this PR: - Update `package.json#engines` - Migrate to `vitest` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is generating a summary for commit 58e0693. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 7b12694 commit fde4083

25 files changed

+3421
-2394
lines changed

.depcheckrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"ignores": [
3+
"@arethetypeswrong/cli",
4+
"@lavamoat/allow-scripts",
5+
"@lavamoat/preinstall-always-fail",
6+
"@metamask/auto-changelog",
7+
"@metamask/eslint-config",
8+
"@metamask/eslint-config-*",
9+
"@types/*",
10+
"@typescript-eslint/utils",
11+
"@vitest/coverage-istanbul",
12+
"@vitest/eslint-plugin",
13+
"@yarnpkg/types",
14+
"eslint-config-*",
15+
"eslint-import-resolver-typescript",
16+
"eslint-plugin-*",
17+
"prettier-plugin-packagejson",
18+
"ts-node",
19+
"typedoc",
20+
"typescript-eslint"
21+
]
22+
}

.eslintrc.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
* text=auto
22

33
yarn.lock linguist-generated=false
4+
5+
# yarn v3
6+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
7+
/.yarn/releases/** binary
8+
/.yarn/plugins/** binary

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:
3+
4+
* What is the current state of things and why does it need to change?
5+
* What is the solution your changes offer and how does it work?
6+
7+
Are there any issues or other links reviewers should consult to understand this pull request better? For instance:
8+
9+
* Fixes #12345
10+
* See: #67890
11+
-->

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
dist/
33
coverage/
4+
docs/
45

56
# Logs
67
logs
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// All of these are defaults except singleQuote, but we specify them
22
// for explicitness
3-
module.exports = {
3+
const config = {
44
quoteProps: 'as-needed',
55
singleQuote: true,
66
tabWidth: 2,
77
trailingComma: 'all',
8+
plugins: ['prettier-plugin-packagejson'],
89
};
10+
11+
export default config;

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ nodeLinker: node-modules
1414

1515
plugins:
1616
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
17-
spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js'
17+
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **BREAKING:** Distribute separate CommonJS and ESM files ([#351](https://github.com/MetaMask/eth-block-tracker/pull/351))
13+
- Use the `exports` field of `package.json`, breaking some previously valid imports.
14+
1015
## [12.2.1]
1116

1217
### Fixed

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,28 @@ Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and
106106
The project follows the same release process as the other libraries in the MetaMask organization. The GitHub Actions [`action-create-release-pr`](https://github.com/MetaMask/action-create-release-pr) and [`action-publish-release`](https://github.com/MetaMask/action-publish-release) are used to automate the release process; see those repositories for more information about how they work.
107107

108108
1. Choose a release version.
109-
110109
- The release version should be chosen according to SemVer. Analyze the changes to see whether they include any breaking changes, new features, or deprecations, then choose the appropriate SemVer version. See [the SemVer specification](https://semver.org/) for more information.
111110

112111
2. If this release is backporting changes onto a previous release, then ensure there is a major version branch for that version (e.g. `1.x` for a `v1` backport release).
113-
114112
- The major version branch should be set to the most recent release with that major version. For example, when backporting a `v1.0.2` release, you'd want to ensure there was a `1.x` branch that was set to the `v1.0.1` tag.
115113

116114
3. Trigger the [`workflow_dispatch`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch) event [manually](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow) for the `Create Release Pull Request` action to create the release PR.
117-
118115
- For a backport release, the base branch should be the major version branch that you ensured existed in step 2. For a normal release, the base branch should be the main branch for that repository (which should be the default value).
119116
- This should trigger the [`action-create-release-pr`](https://github.com/MetaMask/action-create-release-pr) workflow to create the release PR.
120117

121118
4. Update the changelog to move each change entry into the appropriate change category ([See here](https://keepachangelog.com/en/1.0.0/#types) for the full list of change categories, and the correct ordering), and edit them to be more easily understood by users of the package.
122-
123119
- Generally any changes that don't affect consumers of the package (e.g. lockfile changes or development environment changes) are omitted. Exceptions may be made for changes that might be of interest despite not having an effect upon the published package (e.g. major test improvements, security improvements, improved documentation, etc.).
124120
- Try to explain each change in terms that users of the package would understand (e.g. avoid referencing internal variables/concepts).
125121
- Consolidate related changes into one change entry if it makes it easier to explain.
126122
- Run `yarn auto-changelog validate --rc --prettier` to check that the changelog is correctly formatted.
127123

128124
5. Review and QA the release.
129-
130125
- If changes are made to the base branch, the release branch will need to be updated with these changes and review/QA will need to restart again. As such, it's probably best to avoid merging other PRs into the base branch while review is underway.
131126

132127
6. Squash & Merge the release.
133-
134128
- This should trigger the [`action-publish-release`](https://github.com/MetaMask/action-publish-release) workflow to tag the final release commit and publish the release on GitHub.
135129

136130
7. Publish the release on npm.
137-
138131
- Be very careful to use a clean local environment to publish the release, and follow exactly the same steps used during CI.
139132
- Use `npm publish --dry-run` to examine the release contents to ensure the correct files are included. Compare to previous releases if necessary (e.g. using `https://unpkg.com/browse/[package name]@[package version]/`).
140133
- Once you are confident the release contents are correct, publish the release using `npm publish`.

eslint.config.mjs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import base, { createConfig } from '@metamask/eslint-config';
2+
import jest from '@metamask/eslint-config-jest';
3+
import nodejs from '@metamask/eslint-config-nodejs';
4+
import typescript from '@metamask/eslint-config-typescript';
5+
6+
const config = createConfig([
7+
{
8+
ignores: ['dist/', 'docs/', '.yarn/'],
9+
},
10+
11+
{
12+
extends: base,
13+
14+
languageOptions: {
15+
sourceType: 'module',
16+
parserOptions: {
17+
tsconfigRootDir: import.meta.dirname,
18+
project: ['./tsconfig.json'],
19+
},
20+
},
21+
22+
settings: {
23+
'import-x/extensions': ['.js', '.mjs'],
24+
},
25+
},
26+
27+
{
28+
files: ['**/*.ts'],
29+
extends: typescript,
30+
rules: {
31+
// TODO: These should perhaps be enabled
32+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
33+
'no-restricted-syntax': 'off',
34+
// TODO: Thise should definitely be enabled
35+
'@typescript-eslint/naming-convention': 'warn',
36+
'@typescript-eslint/unbound-method': 'warn',
37+
'@typescript-eslint/consistent-type-definitions': 'warn',
38+
'@typescript-eslint/explicit-function-return-type': 'warn',
39+
},
40+
},
41+
42+
{
43+
files: ['**/*.js', '**/*.cjs'],
44+
extends: nodejs,
45+
46+
languageOptions: {
47+
sourceType: 'script',
48+
},
49+
},
50+
51+
{
52+
files: ['./test/**/*', '**/*.test.ts', '**/*.test.js'],
53+
extends: [jest, nodejs],
54+
rules: {
55+
'import-x/no-nodejs-modules': 'off',
56+
},
57+
},
58+
]);
59+
60+
export default config;

0 commit comments

Comments
 (0)