Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
90 changes: 45 additions & 45 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
// @ts-check

import metamaskConfig from '@metamask/eslint-config';
import metamaskConfig, { createConfig } from '@metamask/eslint-config';
import metamaskNodeConfig from '@metamask/eslint-config-nodejs';
import metamaskTypescriptConfig from '@metamask/eslint-config-typescript';
import metamaskVitestConfig from '@metamask/eslint-config-vitest';
import globals from 'globals';

/** @type {import('eslint').Linter.Config[]} */
const config = [
...metamaskConfig,
...metamaskNodeConfig,
...metamaskTypescriptConfig.map((options) => ({
...options,
files: ['**/*.{ts,mts,cts}'],
})),
...metamaskVitestConfig.map((options) => ({
...options,
files: ['**/*.test.{ts,js}'],
})),
const config = createConfig([
{
extends: [metamaskConfig, metamaskNodeConfig],
},

{
ignores: ['node_modules', '**/dist', '**/docs', '**/coverage'],
},

{
files: ['**/*.{js,mjs}'],
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
sourceType: 'module',
},
Expand All @@ -40,41 +32,15 @@ const config = [
{
languageOptions: {
parserOptions: {
tsconfigRootDir: new URL('.', import.meta.url).pathname,
},
globals: {
...globals['shared-node-browser'],
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'import-x/no-useless-path-segments': [
'error',
{
// Enabling this causes false errors in ESM files.
noUselessIndex: false,
},
],

// We have been hoisted by our own petard in the past.
'import-x/no-cycle': ['error', { ignoreExternal: true, maxDepth: 3 }],

// This is not compatible with ESM.
'import-x/extensions': 'off',

// We use unassigned imports for e.g. `import '@ocap/shims/endoify'`.
'import-x/no-unassigned-import': 'off',

// This prevents pretty formatting of comments with multi-line lists entries.
'jsdoc/check-indentation': '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',
},
},

{
files: ['**/*.{ts,mts,cts}'],
files: ['**/*.ts', '**/*.mts', '**/*.cts'],
extends: [metamaskTypescriptConfig],
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
Expand All @@ -96,6 +62,7 @@ const config = [

{
files: ['**/*.test.ts'],
extends: [metamaskVitestConfig],
rules: {
// This causes false positives in tests especially.
'@typescript-eslint/unbound-method': 'off',
Expand All @@ -115,6 +82,39 @@ const config = [
},
},

{
languageOptions: {
globals: {
...globals['shared-node-browser'],
},
},
rules: {
'import-x/no-useless-path-segments': [
'error',
{
// Enabling this causes false errors in ESM files.
noUselessIndex: false,
},
],

// We have been hoisted by our own petard in the past.
'import-x/no-cycle': ['error', { ignoreExternal: true, maxDepth: 3 }],

// This is not compatible with ESM.
'import-x/extensions': 'off',

// We use unassigned imports for e.g. `import '@ocap/shims/endoify'`.
'import-x/no-unassigned-import': 'off',

// This prevents pretty formatting of comments with multi-line lists entries.
'jsdoc/check-indentation': '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',
},
},

// ////////////////////////// //
// Package-specific overrides //
// ////////////////////////// //
Expand All @@ -125,6 +125,6 @@ const config = [
globals: { lockdown: 'readonly' },
},
},
];
]);

export default config;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
"postinstall": "simple-git-hooks",
"prepack": "./scripts/prepack.sh",
"test": "yarn workspaces foreach --all --parallel --verbose run test",
"test:ts": "yarn workspaces foreach --all --parallel --verbose run test:ts",
"test:clean": "yarn workspaces foreach --all --parallel --verbose run test:clean && yarn test",
"test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose",
"why:batch": "./scripts/why-batch.sh"
},
"simple-git-hooks": {
"pre-commit": "yarn lint-staged && yarn dedupe --check"
"pre-commit": "yarn lint-staged && yarn test:ts && yarn dedupe --check"
},
"lint-staged": {
"*.{js,mjs,cjs,ts,mts,cts}": [
Expand Down
1 change: 1 addition & 0 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path ../../.gitignore",
"publish:preview": "yarn npm publish --tag preview",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
"test:verbose": "yarn test --reporter verbose",
Expand Down
7 changes: 4 additions & 3 deletions packages/errors/src/BaseError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';

import { BaseError } from './BaseError.js';
import { ErrorCode } from './constants.js';
import { unmarshalErrorOptions } from './marshal/unmarshalError.js';
import type { MarshaledOcapError } from './types.js';

describe('BaseError', () => {
Expand Down Expand Up @@ -57,9 +58,9 @@ describe('BaseError', () => {
});

it('throws an error when unmarshal is called', () => {
expect(() => BaseError.unmarshal({} as MarshaledOcapError)).toThrow(
'Unmarshal method not implemented',
);
expect(() =>
BaseError.unmarshal({} as MarshaledOcapError, unmarshalErrorOptions),
).toThrow('Unmarshal method not implemented');
});

it('initializes the stack property automatically if not provided', () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/errors/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
1 change: 1 addition & 0 deletions packages/errors/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import path from 'path';
import { defineConfig, mergeConfig } from 'vite';

// @ts-expect-error - no declaration for module
import { getDefaultConfig } from '../../vitest.config.packages.js';

const defaultConfig = getDefaultConfig();
Expand Down
1 change: 1 addition & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"publish:preview": "yarn npm publish --tag preview",
"start": "yarn build:vite:dev --watch",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:build": "node ./test/build-tests.mjs",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"./vite-plugins/*.ts",
"./test/**/*.ts",
"./vite.config.ts",
"./vitest.config.ts"
"./vitest.config.ts",
"./scripts/build-constants.mjs"
]
}
8 changes: 8 additions & 0 deletions packages/extension/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src", "./test", "./scripts"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
4 changes: 2 additions & 2 deletions packages/extension/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
buildDir,
jsTrustedPreludes,
} from './scripts/build-constants.mjs';
import { htmlTrustedPrelude } from './vite-plugins/html-trusted-prelude';
import { jsTrustedPrelude } from './vite-plugins/js-trusted-prelude';
import { htmlTrustedPrelude } from './vite-plugins/html-trusted-prelude.js';
import { jsTrustedPrelude } from './vite-plugins/js-trusted-prelude.js';

/**
* Files that need to be statically copied to the destination directory.
Expand Down
1 change: 1 addition & 0 deletions packages/kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path ../../.gitignore",
"publish:preview": "yarn npm publish --tag preview",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
"test:verbose": "yarn test --reporter verbose",
Expand Down
8 changes: 8 additions & 0 deletions packages/kernel/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src", "./test"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
1 change: 1 addition & 0 deletions packages/shims/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path ../../.gitignore",
"publish:preview": "yarn npm publish --tag preview",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
"test:verbose": "yarn test --reporter verbose",
Expand Down
8 changes: 8 additions & 0 deletions packages/shims/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
1 change: 1 addition & 0 deletions packages/streams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path ../../.gitignore",
"publish:preview": "yarn npm publish --tag preview",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
"test:verbose": "yarn test --reporter verbose",
Expand Down
8 changes: 8 additions & 0 deletions packages/streams/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src", "./test"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path ../../.gitignore",
"publish:preview": "yarn npm publish --tag preview",
"test": "vitest run --config vitest.config.ts",
"test:ts": "tsc --project tsconfig.test.json --noEmit",
"test:clean": "yarn test --no-cache --coverage.clean",
"test:dev": "yarn test --coverage false",
"test:verbose": "yarn test --reporter verbose",
Expand Down
8 changes: 8 additions & 0 deletions packages/utils/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["./src"],
"exclude": ["./vite.config.ts", "./vitest.config.ts"]
}
4 changes: 2 additions & 2 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ module.exports = defineConfig({
);
expectWorkspaceField(
workspace,
'scripts.test',
'vitest run --config vitest.config.ts',
'scripts.test:ts',
'tsc --project tsconfig.test.json --noEmit',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was duplicated so I added the new one here

);
expectWorkspaceField(
workspace,
Expand Down