diff --git a/merged-packages/json-rpc-engine/.eslintrc.js b/merged-packages/json-rpc-engine/.eslintrc.js index dc7fd432a1..9691799e03 100644 --- a/merged-packages/json-rpc-engine/.eslintrc.js +++ b/merged-packages/json-rpc-engine/.eslintrc.js @@ -1,36 +1,134 @@ module.exports = { root: true, - - extends: ['@metamask/eslint-config'], - + extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'], + ignorePatterns: [ + '!.eslintrc.js', + '!jest.config.js', + 'node_modules', + 'dist', + 'docs', + 'coverage', + ], overrides: [ { - files: ['*.ts'], - extends: ['@metamask/eslint-config-typescript'], + files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'], + extends: ['@metamask/eslint-config-jest'], + rules: { + // TODO: Re-enable + 'import/no-named-as-default-member': 'off', + 'jest/no-conditional-expect': 'off', + }, + }, + { + // 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', + 'jest/no-test-return-statement': 'off', + // TODO: Re-enable this rule; we can accomodate this even in our test helpers + 'jest/expect-expect': 'off', + }, }, - { files: ['*.js'], parserOptions: { sourceType: 'script', + ecmaVersion: '2018', }, - extends: ['@metamask/eslint-config-nodejs'], }, + { + files: ['*.ts'], + extends: ['@metamask/eslint-config-typescript'], + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, + rules: { + // disabled due to incompatibility with Record + // See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440 + '@typescript-eslint/consistent-type-definitions': 'off', + // TODO: auto-fix breaks stuff + '@typescript-eslint/promise-function-async': 'off', + + // TODO: re-enble most of these rules + '@typescript-eslint/await-thenable': 'warn', + '@typescript-eslint/naming-convention': 'off', + '@typescript-eslint/no-floating-promises': 'warn', + '@typescript-eslint/no-for-in-array': 'warn', + '@typescript-eslint/no-loss-of-precision': 'warn', + '@typescript-eslint/no-misused-promises': 'warn', + '@typescript-eslint/no-unnecessary-type-assertion': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/prefer-enum-initializers': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/prefer-optional-chain': 'off', + '@typescript-eslint/prefer-reduce-type-parameter': 'off', + '@typescript-eslint/restrict-plus-operands': 'warn', + '@typescript-eslint/restrict-template-expressions': 'warn', + 'no-restricted-syntax': 'off', + 'no-restricted-globals': 'off', + }, + }, + { + files: ['tests/setupAfterEnv/matchers.ts'], + parserOptions: { + sourceType: 'script', + }, + }, { - files: ['*.test.ts', '*.test.js'], - extends: [ - '@metamask/eslint-config-jest', - '@metamask/eslint-config-nodejs', - ], + files: ['*.d.ts'], + rules: { + '@typescript-eslint/naming-convention': 'warn', + 'import/unambiguous': 'off', + }, + }, + { + files: ['scripts/*.ts'], + rules: { + // All scripts will have shebangs. + 'n/shebang': 'off', + }, }, ], + rules: { + // Left disabled because various properties throughough this repo are snake_case because the + // names come from external sources or must comply with standards + // e.g. `txreceipt_status`, `signTypedData_v4`, `token_id` + camelcase: 'off', + 'id-length': 'off', - ignorePatterns: [ - '!.eslintrc.js', - '!.prettierrc.js', - 'dist/', - 'docs/', - '.yarn/', - ], + // TODO: re-enble most of these rules + '@typescript-eslint/naming-convention': 'off', + 'function-paren-newline': 'off', + 'guard-for-in': 'off', + 'id-denylist': 'off', + 'implicit-arrow-linebreak': 'off', + 'import/no-anonymous-default-export': 'off', + 'import/no-unassigned-import': 'off', + 'lines-around-comment': 'off', + 'n/no-sync': 'off', + 'no-async-promise-executor': 'off', + 'no-case-declarations': 'off', + 'no-invalid-this': 'off', + 'no-negated-condition': 'off', + 'no-new': 'off', + 'no-param-reassign': 'off', + 'no-restricted-syntax': 'off', + radix: 'off', + 'require-atomic-updates': 'off', + 'jsdoc/match-description': [ + 'off', + { matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' }, + ], + }, + settings: { + 'import/resolver': { + typescript: {}, + }, + }, }; diff --git a/merged-packages/json-rpc-engine/CHANGELOG.md b/merged-packages/json-rpc-engine/CHANGELOG.md index 85363f2fec..8dfa4eac1b 100644 --- a/merged-packages/json-rpc-engine/CHANGELOG.md +++ b/merged-packages/json-rpc-engine/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.2.0] +### Added +- Applied eslint rules from core monorepo ([#172](https://github.com/MetaMask/json-rpc-engine/pull/172)) + ## [7.1.1] ### Changed - 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 This change may affect consumers that depend on the eager execution of middleware _during_ request processing, _outside of_ middleware functions and request handlers. - In general, it is a bad practice to work with state that depends on middleware execution, while the middleware are executing. -[Unreleased]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.1...HEAD +[Unreleased]: https://github.com/MetaMask/json-rpc-engine/compare/v7.2.0...HEAD +[7.2.0]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.1...v7.2.0 [7.1.1]: https://github.com/MetaMask/json-rpc-engine/compare/v7.1.0...v7.1.1 [7.1.0]: https://github.com/MetaMask/json-rpc-engine/compare/v7.0.0...v7.1.0 [7.0.0]: https://github.com/MetaMask/json-rpc-engine/compare/v6.1.0...v7.0.0 diff --git a/merged-packages/json-rpc-engine/package.json b/merged-packages/json-rpc-engine/package.json index 55cfe369a2..b6fddbe8b4 100644 --- a/merged-packages/json-rpc-engine/package.json +++ b/merged-packages/json-rpc-engine/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/json-rpc-engine", - "version": "7.1.1", + "version": "7.2.0", "description": "A tool for processing JSON-RPC messages.", "homepage": "https://github.com/MetaMask/json-rpc-engine#readme", "bugs": { @@ -52,6 +52,7 @@ "depcheck": "^1.4.3", "eslint": "^8.27.0", "eslint-config-prettier": "^8.5.0", + "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "^27.1.5", "eslint-plugin-jsdoc": "^39.6.2", diff --git a/merged-packages/json-rpc-engine/src/createAsyncMiddleware.ts b/merged-packages/json-rpc-engine/src/createAsyncMiddleware.ts index ebf18526aa..19122f5636 100644 --- a/merged-packages/json-rpc-engine/src/createAsyncMiddleware.ts +++ b/merged-packages/json-rpc-engine/src/createAsyncMiddleware.ts @@ -71,7 +71,7 @@ export function createAsyncMiddleware< returnHandlerCallback = runReturnHandlersCallback; resolveNextPromise(); }); - await nextPromise; + return nextPromise; }; try { diff --git a/merged-packages/json-rpc-engine/yarn.lock b/merged-packages/json-rpc-engine/yarn.lock index ccd09640bc..65cd4e6d9a 100644 --- a/merged-packages/json-rpc-engine/yarn.lock +++ b/merged-packages/json-rpc-engine/yarn.lock @@ -24,6 +24,16 @@ __metadata: languageName: node linkType: hard +"@babel/code-frame@npm:^7.22.13": + version: 7.22.13 + resolution: "@babel/code-frame@npm:7.22.13" + dependencies: + "@babel/highlight": ^7.22.13 + chalk: ^2.4.2 + checksum: 22e342c8077c8b77eeb11f554ecca2ba14153f707b85294fcf6070b6f6150aae88a7b7436dd88d8c9289970585f3fe5b9b941c5aa3aa26a6d5a8ef3f292da058 + languageName: node + linkType: hard + "@babel/compat-data@npm:^7.21.4": version: 7.21.4 resolution: "@babel/compat-data@npm:7.21.4" @@ -66,6 +76,18 @@ __metadata: languageName: node linkType: hard +"@babel/generator@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/generator@npm:7.23.0" + dependencies: + "@babel/types": ^7.23.0 + "@jridgewell/gen-mapping": ^0.3.2 + "@jridgewell/trace-mapping": ^0.3.17 + jsesc: ^2.5.1 + checksum: 8efe24adad34300f1f8ea2add420b28171a646edc70f2a1b3e1683842f23b8b7ffa7e35ef0119294e1901f45bfea5b3dc70abe1f10a1917ccdfb41bed69be5f1 + languageName: node + linkType: hard + "@babel/helper-compilation-targets@npm:^7.21.4": version: 7.21.4 resolution: "@babel/helper-compilation-targets@npm:7.21.4" @@ -88,22 +110,29 @@ __metadata: languageName: node linkType: hard -"@babel/helper-function-name@npm:^7.21.0": - version: 7.21.0 - resolution: "@babel/helper-function-name@npm:7.21.0" +"@babel/helper-environment-visitor@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-environment-visitor@npm:7.22.20" + checksum: d80ee98ff66f41e233f36ca1921774c37e88a803b2f7dca3db7c057a5fea0473804db9fb6729e5dbfd07f4bed722d60f7852035c2c739382e84c335661590b69 + languageName: node + linkType: hard + +"@babel/helper-function-name@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/helper-function-name@npm:7.23.0" dependencies: - "@babel/template": ^7.20.7 - "@babel/types": ^7.21.0 - checksum: d63e63c3e0e3e8b3138fa47b0cd321148a300ef12b8ee951196994dcd2a492cc708aeda94c2c53759a5c9177fffaac0fd8778791286746f72a000976968daf4e + "@babel/template": ^7.22.15 + "@babel/types": ^7.23.0 + checksum: e44542257b2d4634a1f979244eb2a4ad8e6d75eb6761b4cfceb56b562f7db150d134bc538c8e6adca3783e3bc31be949071527aa8e3aab7867d1ad2d84a26e10 languageName: node linkType: hard -"@babel/helper-hoist-variables@npm:^7.18.6": - version: 7.18.6 - resolution: "@babel/helper-hoist-variables@npm:7.18.6" +"@babel/helper-hoist-variables@npm:^7.22.5": + version: 7.22.5 + resolution: "@babel/helper-hoist-variables@npm:7.22.5" dependencies: - "@babel/types": ^7.18.6 - checksum: fd9c35bb435fda802bf9ff7b6f2df06308a21277c6dec2120a35b09f9de68f68a33972e2c15505c1a1a04b36ec64c9ace97d4a9e26d6097b76b4396b7c5fa20f + "@babel/types": ^7.22.5 + checksum: 394ca191b4ac908a76e7c50ab52102669efe3a1c277033e49467913c7ed6f7c64d7eacbeabf3bed39ea1f41731e22993f763b1edce0f74ff8563fd1f380d92cc languageName: node linkType: hard @@ -157,6 +186,15 @@ __metadata: languageName: node linkType: hard +"@babel/helper-split-export-declaration@npm:^7.22.6": + version: 7.22.6 + resolution: "@babel/helper-split-export-declaration@npm:7.22.6" + dependencies: + "@babel/types": ^7.22.5 + checksum: e141cace583b19d9195f9c2b8e17a3ae913b7ee9b8120246d0f9ca349ca6f03cb2c001fd5ec57488c544347c0bb584afec66c936511e447fd20a360e591ac921 + languageName: node + linkType: hard + "@babel/helper-string-parser@npm:^7.19.4": version: 7.19.4 resolution: "@babel/helper-string-parser@npm:7.19.4" @@ -164,6 +202,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-string-parser@npm:^7.22.5": + version: 7.22.5 + resolution: "@babel/helper-string-parser@npm:7.22.5" + checksum: 836851ca5ec813077bbb303acc992d75a360267aa3b5de7134d220411c852a6f17de7c0d0b8c8dcc0f567f67874c00f4528672b2a4f1bc978a3ada64c8c78467 + languageName: node + linkType: hard + "@babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.19.1": version: 7.19.1 resolution: "@babel/helper-validator-identifier@npm:7.19.1" @@ -171,6 +216,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-identifier@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-validator-identifier@npm:7.22.20" + checksum: 136412784d9428266bcdd4d91c32bcf9ff0e8d25534a9d94b044f77fe76bc50f941a90319b05aafd1ec04f7d127cd57a179a3716009ff7f3412ef835ada95bdc + languageName: node + linkType: hard + "@babel/helper-validator-option@npm:^7.21.0": version: 7.21.0 resolution: "@babel/helper-validator-option@npm:7.21.0" @@ -200,6 +252,17 @@ __metadata: languageName: node linkType: hard +"@babel/highlight@npm:^7.22.13": + version: 7.22.20 + resolution: "@babel/highlight@npm:7.22.20" + dependencies: + "@babel/helper-validator-identifier": ^7.22.20 + chalk: ^2.4.2 + js-tokens: ^4.0.0 + checksum: 84bd034dca309a5e680083cd827a766780ca63cef37308404f17653d32366ea76262bd2364b2d38776232f2d01b649f26721417d507e8b4b6da3e4e739f6d134 + languageName: node + linkType: hard + "@babel/parser@npm:7.16.4": version: 7.16.4 resolution: "@babel/parser@npm:7.16.4" @@ -218,6 +281,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/parser@npm:7.23.0" + bin: + parser: ./bin/babel-parser.js + checksum: 453fdf8b9e2c2b7d7b02139e0ce003d1af21947bbc03eb350fb248ee335c9b85e4ab41697ddbdd97079698de825a265e45a0846bb2ed47a2c7c1df833f42a354 + languageName: node + linkType: hard + "@babel/plugin-syntax-async-generators@npm:^7.8.4": version: 7.8.4 resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4" @@ -383,21 +455,32 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2, @babel/traverse@npm:^7.21.4, @babel/traverse@npm:^7.7.2": - version: 7.21.4 - resolution: "@babel/traverse@npm:7.21.4" +"@babel/template@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/template@npm:7.22.15" dependencies: - "@babel/code-frame": ^7.21.4 - "@babel/generator": ^7.21.4 - "@babel/helper-environment-visitor": ^7.18.9 - "@babel/helper-function-name": ^7.21.0 - "@babel/helper-hoist-variables": ^7.18.6 - "@babel/helper-split-export-declaration": ^7.18.6 - "@babel/parser": ^7.21.4 - "@babel/types": ^7.21.4 + "@babel/code-frame": ^7.22.13 + "@babel/parser": ^7.22.15 + "@babel/types": ^7.22.15 + checksum: 1f3e7dcd6c44f5904c184b3f7fe280394b191f2fed819919ffa1e529c259d5b197da8981b6ca491c235aee8dbad4a50b7e31304aa531271cb823a4a24a0dd8fd + languageName: node + linkType: hard + +"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2, @babel/traverse@npm:^7.21.4, @babel/traverse@npm:^7.7.2": + version: 7.23.2 + resolution: "@babel/traverse@npm:7.23.2" + dependencies: + "@babel/code-frame": ^7.22.13 + "@babel/generator": ^7.23.0 + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-function-name": ^7.23.0 + "@babel/helper-hoist-variables": ^7.22.5 + "@babel/helper-split-export-declaration": ^7.22.6 + "@babel/parser": ^7.23.0 + "@babel/types": ^7.23.0 debug: ^4.1.0 globals: ^11.1.0 - checksum: f22f067c2d9b6497abf3d4e53ea71f3aa82a21f2ed434dd69b8c5767f11f2a4c24c8d2f517d2312c9e5248e5c69395fdca1c95a2b3286122c75f5783ddb6f53c + checksum: 26a1eea0dde41ab99dde8b9773a013a0dc50324e5110a049f5d634e721ff08afffd54940b3974a20308d7952085ac769689369e9127dea655f868c0f6e1ab35d languageName: node linkType: hard @@ -412,6 +495,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/types@npm:7.23.0" + dependencies: + "@babel/helper-string-parser": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 + to-fast-properties: ^2.0.0 + checksum: 215fe04bd7feef79eeb4d33374b39909ce9cad1611c4135a4f7fdf41fe3280594105af6d7094354751514625ea92d0875aba355f53e86a92600f290e77b0e604 + languageName: node + linkType: hard + "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -1005,6 +1099,7 @@ __metadata: depcheck: ^1.4.3 eslint: ^8.27.0 eslint-config-prettier: ^8.5.0 + eslint-import-resolver-typescript: ^2.5.0 eslint-plugin-import: ^2.26.0 eslint-plugin-jest: ^27.1.5 eslint-plugin-jsdoc: ^39.6.2 @@ -2115,7 +2210,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^2.0.0": +"chalk@npm:^2.0.0, chalk@npm:^2.4.2": version: 2.4.2 resolution: "chalk@npm:2.4.2" dependencies: @@ -2730,6 +2825,22 @@ __metadata: languageName: node linkType: hard +"eslint-import-resolver-typescript@npm:^2.5.0": + version: 2.7.1 + resolution: "eslint-import-resolver-typescript@npm:2.7.1" + dependencies: + debug: ^4.3.4 + glob: ^7.2.0 + is-glob: ^4.0.3 + resolve: ^1.22.0 + tsconfig-paths: ^3.14.1 + peerDependencies: + eslint: "*" + eslint-plugin-import: "*" + checksum: 1d81b657b1f73bf95b8f0b745c0305574b91630c1db340318f3ca8918e206fce20a933b95e7c419338cc4452cb80bb2b2d92acaf01b6aa315c78a332d832545c + languageName: node + linkType: hard + "eslint-module-utils@npm:^2.7.4": version: 2.7.4 resolution: "eslint-module-utils@npm:2.7.4" @@ -3382,6 +3493,20 @@ __metadata: languageName: node linkType: hard +"glob@npm:^7.2.0": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + "glob@npm:^8.0.1": version: 8.1.0 resolution: "glob@npm:8.1.0" @@ -3773,6 +3898,15 @@ __metadata: languageName: node linkType: hard +"is-core-module@npm:^2.13.0": + version: 2.13.0 + resolution: "is-core-module@npm:2.13.0" + dependencies: + has: ^1.0.3 + checksum: 053ab101fb390bfeb2333360fd131387bed54e476b26860dc7f5a700bbf34a0ec4454f7c8c4d43e8a0030957e4b3db6e16d35e1890ea6fb654c833095e040355 + languageName: node + linkType: hard + "is-date-object@npm:^1.0.1": version: 1.0.1 resolution: "is-date-object@npm:1.0.1" @@ -4783,7 +4917,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.2": +"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": version: 3.1.2 resolution: "minimatch@npm:3.1.2" dependencies: @@ -5541,6 +5675,19 @@ __metadata: languageName: node linkType: hard +"resolve@npm:^1.22.0": + version: 1.22.8 + resolution: "resolve@npm:1.22.8" + dependencies: + is-core-module: ^2.13.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: f8a26958aa572c9b064562750b52131a37c29d072478ea32e129063e2da7f83e31f7f11e7087a18225a8561cfe8d2f0df9dbea7c9d331a897571c0a2527dbb4c + languageName: node + linkType: hard + "resolve@patch:resolve@^1.18.1#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.2 resolution: "resolve@patch:resolve@npm%3A1.22.2#~builtin::version=1.22.2&hash=c3c19d" @@ -5554,6 +5701,19 @@ __metadata: languageName: node linkType: hard +"resolve@patch:resolve@^1.22.0#~builtin": + version: 1.22.8 + resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin::version=1.22.8&hash=c3c19d" + dependencies: + is-core-module: ^2.13.0 + path-parse: ^1.0.7 + supports-preserve-symlinks-flag: ^1.0.0 + bin: + resolve: bin/resolve + checksum: 5479b7d431cacd5185f8db64bfcb7286ae5e31eb299f4c4f404ad8aa6098b77599563ac4257cb2c37a42f59dfc06a1bec2bcf283bb448f319e37f0feb9a09847 + languageName: node + linkType: hard + "retry@npm:^0.12.0": version: 0.12.0 resolution: "retry@npm:0.12.0"