Skip to content

Commit 2f0afe3

Browse files
committed
Merge latest changes from 'json-rpc-engine/main' into migrate-json-rpc-engine-repo
2 parents 4334115 + 67c7fee commit 2f0afe3

5 files changed

Lines changed: 311 additions & 47 deletions

File tree

Lines changed: 117 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,134 @@
11
module.exports = {
22
root: true,
3-
4-
extends: ['@metamask/eslint-config'],
5-
3+
extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],
4+
ignorePatterns: [
5+
'!.eslintrc.js',
6+
'!jest.config.js',
7+
'node_modules',
8+
'dist',
9+
'docs',
10+
'coverage',
11+
],
612
overrides: [
713
{
8-
files: ['*.ts'],
9-
extends: ['@metamask/eslint-config-typescript'],
14+
files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'],
15+
extends: ['@metamask/eslint-config-jest'],
16+
rules: {
17+
// TODO: Re-enable
18+
'import/no-named-as-default-member': 'off',
19+
'jest/no-conditional-expect': 'off',
20+
},
21+
},
22+
{
23+
// These files are test helpers, not tests. We still use the Jest ESLint
24+
// config here to ensure that ESLint expects a test-like environment, but
25+
// various rules meant just to apply to tests have been disabled.
26+
files: ['**/tests/**/*.{ts,js}', '!*.test.{ts,js}'],
27+
rules: {
28+
'jest/no-export': 'off',
29+
'jest/require-top-level-describe': 'off',
30+
'jest/no-if': 'off',
31+
'jest/no-test-return-statement': 'off',
32+
// TODO: Re-enable this rule; we can accomodate this even in our test helpers
33+
'jest/expect-expect': 'off',
34+
},
1035
},
11-
1236
{
1337
files: ['*.js'],
1438
parserOptions: {
1539
sourceType: 'script',
40+
ecmaVersion: '2018',
1641
},
17-
extends: ['@metamask/eslint-config-nodejs'],
1842
},
43+
{
44+
files: ['*.ts'],
45+
extends: ['@metamask/eslint-config-typescript'],
46+
parserOptions: {
47+
tsconfigRootDir: __dirname,
48+
project: ['./tsconfig.json'],
49+
},
50+
rules: {
51+
// disabled due to incompatibility with Record<string, unknown>
52+
// See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440
53+
'@typescript-eslint/consistent-type-definitions': 'off',
1954

55+
// TODO: auto-fix breaks stuff
56+
'@typescript-eslint/promise-function-async': 'off',
57+
58+
// TODO: re-enble most of these rules
59+
'@typescript-eslint/await-thenable': 'warn',
60+
'@typescript-eslint/naming-convention': 'off',
61+
'@typescript-eslint/no-floating-promises': 'warn',
62+
'@typescript-eslint/no-for-in-array': 'warn',
63+
'@typescript-eslint/no-loss-of-precision': 'warn',
64+
'@typescript-eslint/no-misused-promises': 'warn',
65+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
66+
'@typescript-eslint/unbound-method': 'off',
67+
'@typescript-eslint/prefer-enum-initializers': 'off',
68+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
69+
'@typescript-eslint/prefer-optional-chain': 'off',
70+
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
71+
'@typescript-eslint/restrict-plus-operands': 'warn',
72+
'@typescript-eslint/restrict-template-expressions': 'warn',
73+
'no-restricted-syntax': 'off',
74+
'no-restricted-globals': 'off',
75+
},
76+
},
77+
{
78+
files: ['tests/setupAfterEnv/matchers.ts'],
79+
parserOptions: {
80+
sourceType: 'script',
81+
},
82+
},
2083
{
21-
files: ['*.test.ts', '*.test.js'],
22-
extends: [
23-
'@metamask/eslint-config-jest',
24-
'@metamask/eslint-config-nodejs',
25-
],
84+
files: ['*.d.ts'],
85+
rules: {
86+
'@typescript-eslint/naming-convention': 'warn',
87+
'import/unambiguous': 'off',
88+
},
89+
},
90+
{
91+
files: ['scripts/*.ts'],
92+
rules: {
93+
// All scripts will have shebangs.
94+
'n/shebang': 'off',
95+
},
2696
},
2797
],
98+
rules: {
99+
// Left disabled because various properties throughough this repo are snake_case because the
100+
// names come from external sources or must comply with standards
101+
// e.g. `txreceipt_status`, `signTypedData_v4`, `token_id`
102+
camelcase: 'off',
103+
'id-length': 'off',
28104

29-
ignorePatterns: [
30-
'!.eslintrc.js',
31-
'!.prettierrc.js',
32-
'dist/',
33-
'docs/',
34-
'.yarn/',
35-
],
105+
// TODO: re-enble most of these rules
106+
'@typescript-eslint/naming-convention': 'off',
107+
'function-paren-newline': 'off',
108+
'guard-for-in': 'off',
109+
'id-denylist': 'off',
110+
'implicit-arrow-linebreak': 'off',
111+
'import/no-anonymous-default-export': 'off',
112+
'import/no-unassigned-import': 'off',
113+
'lines-around-comment': 'off',
114+
'n/no-sync': 'off',
115+
'no-async-promise-executor': 'off',
116+
'no-case-declarations': 'off',
117+
'no-invalid-this': 'off',
118+
'no-negated-condition': 'off',
119+
'no-new': 'off',
120+
'no-param-reassign': 'off',
121+
'no-restricted-syntax': 'off',
122+
radix: 'off',
123+
'require-atomic-updates': 'off',
124+
'jsdoc/match-description': [
125+
'off',
126+
{ matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' },
127+
],
128+
},
129+
settings: {
130+
'import/resolver': {
131+
typescript: {},
132+
},
133+
},
36134
};

merged-packages/json-rpc-engine/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [7.2.0]
10+
### Added
11+
- Applied eslint rules from core monorepo ([#172](https://github.com/MetaMask/json-rpc-engine/pull/172))
12+
913
## [7.1.1]
1014
### Changed
1115
- Bumped `@metamask/utils` from `^5.0.2` to `^8.1.0` [#158](https://github.com/MetaMask/json-rpc-engine/pull/158) ([#162](https://github.com/MetaMask/json-rpc-engine/pull/162))
@@ -79,7 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7983
This change may affect consumers that depend on the eager execution of middleware _during_ request processing, _outside of_ middleware functions and request handlers.
8084
- In general, it is a bad practice to work with state that depends on middleware execution, while the middleware are executing.
8185

82-
[Unreleased]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.1...HEAD
86+
[Unreleased]: https://github.com/MetaMask/json-rpc-engine/compare/v7.2.0...HEAD
87+
[7.2.0]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.1...v7.2.0
8388
[7.1.1]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.0...v7.1.1
8489
[7.1.0]: https://github.com/MetaMask/json-rpc-engine/compare/v7.0.0...v7.1.0
8590
[7.0.0]: https://github.com/MetaMask/json-rpc-engine/compare/v6.1.0...v7.0.0

merged-packages/json-rpc-engine/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/json-rpc-engine",
3-
"version": "7.1.1",
3+
"version": "7.2.0",
44
"description": "A tool for processing JSON-RPC messages.",
55
"homepage": "https://github.com/MetaMask/json-rpc-engine#readme",
66
"bugs": {
@@ -52,6 +52,7 @@
5252
"depcheck": "^1.4.3",
5353
"eslint": "^8.27.0",
5454
"eslint-config-prettier": "^8.5.0",
55+
"eslint-import-resolver-typescript": "^2.5.0",
5556
"eslint-plugin-import": "^2.26.0",
5657
"eslint-plugin-jest": "^27.1.5",
5758
"eslint-plugin-jsdoc": "^39.6.2",

merged-packages/json-rpc-engine/src/createAsyncMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function createAsyncMiddleware<
7171
returnHandlerCallback = runReturnHandlersCallback;
7272
resolveNextPromise();
7373
});
74-
await nextPromise;
74+
return nextPromise;
7575
};
7676

7777
try {

0 commit comments

Comments
 (0)