Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .depcheckrc.json

This file was deleted.

15 changes: 15 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
ignores:
- '@arethetypeswrong/cli'
- '@lavamoat/allow-scripts'
- '@lavamoat/preinstall-always-fail'
- '@metamask/auto-changelog'
- '@ts-bridge/cli'
- '@ts-bridge/shims'
- '@types/jest'
- '@types/node'
- '@yarnpkg/*'
- 'jest-silent-reporter'
- 'prettier-plugin-*'
- 'ts-jest'
- 'typedoc'
118 changes: 92 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,116 @@
module.exports = {
root: true,

extends: ['@metamask/eslint-config'],
extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],

parserOptions: {
tsconfigRootDir: __dirname,
},

env: {
'shared-node-browser': true,
},

ignorePatterns: [
'!.eslintrc.js',
'!jest.config.js',
'node_modules',
'**/dist',
'**/docs',
'**/coverage',
],

rules: {
// This prevents importing Node.js builtins. We currently use them in
// our codebase, so this rule is disabled. This rule should be disabled
// in `@metamask/eslint-config-nodejs` in the future.
'import/no-nodejs-modules': 'off',

// This prevents using Node.js and/or browser specific globals. We
// currently use both in our codebase, so this rule is disabled.
'no-restricted-globals': 'off',
},

overrides: [
{
files: ['*.js'],
parserOptions: {
sourceType: 'script',
ecmaVersion: '2020',
},
},

{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.packages.json'],
},
rules: {
// Enable rules that are disabled in `@metamask/eslint-config-typescript`
'@typescript-eslint/no-explicit-any': 'error',

// TODO: auto-fix breaks stuff
'@typescript-eslint/promise-function-async': 'off',

// Without the `allowAny` option, this rule causes a lot of false
// positives.
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: true,
allowBoolean: true,
allowNumber: true,
},
],
},
},

{
files: ['*.js'],
parserOptions: {
sourceType: 'script',
files: ['*.d.ts'],
rules: {
'import/unambiguous': 'off',
},
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ['yarn.config.cjs'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2020,
files: ['scripts/*.ts'],
rules: {
// All scripts will have shebangs.
'n/shebang': 'off',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},

{
files: ['**/jest.environment.js'],
rules: {
// These files run under Node, and thus `require(...)` is expected.
'n/global-require': 'off',
},
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ['*.test.ts', '*.test.js'],
extends: [
'@metamask/eslint-config-jest',
'@metamask/eslint-config-nodejs',
],
files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'],
extends: ['@metamask/eslint-config-jest'],
rules: {
'@typescript-eslint/no-shadow': [
'error',
{ allow: ['describe', 'expect', 'it'] },
],
},
},
],

ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'dist/',
'docs/',
'.yarn/',
{
// These files are test helpers, not tests. We still use the Jest ESLint
// config here to ensure that ESLint expects a test-like environment, but
// various rules meant just to apply to tests have been disabled.
files: ['**/tests/**/*.{ts,js}', '!*.test.{ts,js}'],
rules: {
'jest/no-export': 'off',
'jest/require-top-level-describe': 'off',
'jest/no-if': 'off',
},
},
],
};
84 changes: 47 additions & 37 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,47 @@ jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/checkout@v4
- name: Use Node.js and install dependencies
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install Yarn dependencies
- name: Install dependencies via Yarn
run: yarn --immutable

build:
name: Build
needs: prepare
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [20.x]
steps:
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/checkout@v4
- name: Use Node.js
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- name: Install dependencies via Yarn
run: yarn --immutable --immutable-cache
- run: yarn build
- name: Require clean working directory
shell: bash
Expand All @@ -53,23 +59,26 @@ jobs:

lint:
name: Lint
needs: prepare
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [20.x]
steps:
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/checkout@v4
- name: Use Node.js
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- name: Install dependencies via Yarn
run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
Expand All @@ -87,26 +96,26 @@ jobs:

test:
name: Test
needs: prepare
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- name: Install dependencies via Yarn
run: yarn --immutable --immutable-cache
- run: yarn test
- name: Require clean working directory
shell: bash
Expand All @@ -118,31 +127,32 @@ jobs:

compatibility-test:
name: Compatibility test
needs: prepare
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Install Node.js ${{ matrix.node-version }} and restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
- name: Install dependencies via Yarn
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
- run: yarn test
- name: Restore lockfile
run: git restore yarn.lock
- name: Require clean working directory
shell: bash
run: |
git restore yarn.lock
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
# We check out the specified branch, which will be used as the base
# branch for all git operations and the release PR.
ref: ${{ github.event.inputs.base-branch }}
- name: Setup Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- uses: MetaMask/action-create-release-pr@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release-type: ${{ github.event.inputs.release-type }}
release-version: ${{ github.event.inputs.release-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 9 additions & 4 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ jobs:
- name: Ensure `destination_dir` is not empty
if: ${{ inputs.destination_dir == '' }}
run: exit 1
- name: Checkout the repository
uses: actions/checkout@v4
- name: Use Node.js
- uses: actions/checkout@v4
- name: Install Corepack via Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install npm dependencies
- name: Install dependencies via Yarn
run: yarn --immutable
- name: Run build script
run: yarn build:docs
Expand Down
Loading