Skip to content

Commit eff1b66

Browse files
authored
chore: Replace Prettier with Oxfmt (#304)
* Replace Prettier with Oxfmt * Fix lint errors * Add `prettier` to `depcheck` ignores * Bump `@metamask/auto-changelog` to `^6.1.0` and enable Oxfmt * Update `MetaMask/action-create-release-pr` to `v5` * Bump `oxfmt` * Revert release-type change * Completely remove Prettier * Remove `prettier` from Depcheck config
1 parent c576761 commit eff1b66

8 files changed

Lines changed: 266 additions & 130 deletions

File tree

.depcheckrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"eslint-config-*",
1414
"eslint-import-resolver-typescript",
1515
"eslint-plugin-*",
16-
"prettier-plugin-packagejson",
1716
"ts-node",
1817
"typedoc",
1918
"typescript-eslint",

.github/workflows/create-release-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ jobs:
3434
# branch for all git operations and the release PR.
3535
ref: ${{ github.event.inputs.base-branch }}
3636

37-
- uses: MetaMask/action-create-release-pr@v4
37+
- uses: MetaMask/action-create-release-pr@v5
3838
with:
3939
release-type: ${{ github.event.inputs.release-type }}
4040
release-version: ${{ github.event.inputs.release-version }}
41+
formatter: 'oxfmt'
4142
env:
4243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.oxfmtrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": [".yarnrc.yml"],
4+
"printWidth": 80,
5+
"quoteProps": "as-needed",
6+
"singleQuote": true,
7+
"sortImports": {
8+
"newlinesBetween": false,
9+
"groups": [
10+
["builtin", "external"],
11+
{ "newlinesBetween": true },
12+
["internal", "parent", "sibling", "index", "unknown"]
13+
]
14+
},
15+
"tabWidth": 2,
16+
"trailingComma": "all"
17+
}

.prettierrc.mjs

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

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,28 @@ Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and
6363
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.
6464

6565
1. Choose a release version.
66-
6766
- 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.
6867

6968
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).
70-
7169
- 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.
7270

7371
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.
74-
7572
- 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).
7673
- This should trigger the [`action-create-release-pr`](https://github.com/MetaMask/action-create-release-pr) workflow to create the release PR.
7774

7875
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.
79-
8076
- 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.).
8177
- Try to explain each change in terms that users of the package would understand (e.g. avoid referencing internal variables/concepts).
8278
- Consolidate related changes into one change entry if it makes it easier to explain.
8379
- Run `yarn auto-changelog validate --rc` to check that the changelog is correctly formatted.
8480

8581
5. Review and QA the release.
86-
8782
- 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.
8883

8984
6. Squash & Merge the release.
90-
9185
- 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.
9286

9387
7. Publish the release on npm.
94-
9588
- Wait for the `publish-release` GitHub Action workflow to finish. This should trigger a second job (`publish-npm`), which will wait for a run approval by the [`npm publishers`](https://github.com/orgs/MetaMask/teams/npm-publishers) team.
9689
- Approve the `publish-npm` job (or ask somebody on the npm publishers team to approve it for you).
9790
- Once the `publish-npm` job has finished, check npm to verify that it has been published.

eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ const config = createConfig([
2323
},
2424
},
2525

26+
{
27+
rules: {
28+
// Handled by Oxfmt.
29+
'prettier/prettier': 'off',
30+
'import-x/order': 'off',
31+
},
32+
},
33+
2634
{
2735
files: ['**/*.ts'],
2836
extends: typescript,

package.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
"type": "git",
1111
"url": "https://github.com/MetaMask/metamask-module-template.git"
1212
},
13+
"files": [
14+
"dist"
15+
],
1316
"sideEffects": false,
17+
"main": "./dist/index.cjs",
18+
"module": "./dist/index.mjs",
19+
"types": "./dist/index.d.cts",
1420
"exports": {
1521
".": {
1622
"import": {
@@ -24,23 +30,21 @@
2430
},
2531
"./package.json": "./package.json"
2632
},
27-
"main": "./dist/index.cjs",
28-
"module": "./dist/index.mjs",
29-
"types": "./dist/index.d.cts",
30-
"files": [
31-
"dist"
32-
],
33+
"publishConfig": {
34+
"access": "public",
35+
"registry": "https://registry.npmjs.org/"
36+
},
3337
"scripts": {
3438
"build": "ts-bridge --project tsconfig.build.json --clean",
3539
"build:docs": "typedoc",
3640
"lint": "yarn lint:eslint && yarn lint:constraints && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog",
37-
"lint:changelog": "auto-changelog validate --prettier",
41+
"lint:changelog": "auto-changelog validate --formatter oxfmt",
3842
"lint:constraints": "yarn constraints",
3943
"lint:dependencies": "depcheck && yarn dedupe --check",
4044
"lint:dependencies:fix": "depcheck && yarn dedupe",
4145
"lint:eslint": "eslint .",
42-
"lint:fix": "yarn lint:eslint --fix && yarn lint:constraints --fix && yarn lint:misc --write && yarn lint:dependencies:fix && yarn lint:changelog",
43-
"lint:misc": "prettier '**/*.json' '**/*.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
46+
"lint:fix": "yarn lint:eslint --fix && yarn lint:constraints --fix && yarn lint:misc --write && yarn lint:dependencies:fix && yarn lint:changelog --fix",
47+
"lint:misc": "oxfmt --ignore-path .gitignore",
4448
"prepack": "./scripts/prepack.sh",
4549
"test": "vitest && attw --pack",
4650
"test:watch": "vitest --watch"
@@ -49,7 +53,7 @@
4953
"@arethetypeswrong/cli": "^0.15.3",
5054
"@lavamoat/allow-scripts": "^3.0.4",
5155
"@lavamoat/preinstall-always-fail": "^2.0.0",
52-
"@metamask/auto-changelog": "^5.3.0",
56+
"@metamask/auto-changelog": "^6.1.0",
5357
"@metamask/eslint-config": "^15.0.0",
5458
"@metamask/eslint-config-nodejs": "^15.0.0",
5559
"@metamask/eslint-config-typescript": "^15.0.0",
@@ -69,23 +73,18 @@
6973
"eslint-plugin-n": "^17.10.3",
7074
"eslint-plugin-prettier": "^5.2.1",
7175
"eslint-plugin-promise": "^7.1.0",
72-
"prettier": "^3.3.3",
73-
"prettier-plugin-packagejson": "^2.5.8",
76+
"oxfmt": "^0.45.0",
7477
"ts-node": "^10.7.0",
7578
"typedoc": "^0.26.11",
7679
"typescript": "~5.7.3",
7780
"typescript-eslint": "^8.48.1",
7881
"vite": "^8.0.8",
7982
"vitest": "^4.1.4"
8083
},
81-
"packageManager": "yarn@4.10.3",
8284
"engines": {
8385
"node": "^20 || ^22 || >=24"
8486
},
85-
"publishConfig": {
86-
"access": "public",
87-
"registry": "https://registry.npmjs.org/"
88-
},
87+
"packageManager": "yarn@4.10.3",
8988
"lavamoat": {
9089
"allowScripts": {
9190
"@lavamoat/preinstall-always-fail": false,

0 commit comments

Comments
 (0)