Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit 7d0865b

Browse files
authored
applied eslint rules from core monorepo and fixed the errors (#172)
* applied eslint rules from core monorepo and fixed the errors * added eslint-import-resolver-typescript devDependencies
1 parent dad4b65 commit 7d0865b

4 files changed

Lines changed: 186 additions & 21 deletions

File tree

.eslintrc.js

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
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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",

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 {

yarn.lock

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ __metadata:
10051005
depcheck: ^1.4.3
10061006
eslint: ^8.27.0
10071007
eslint-config-prettier: ^8.5.0
1008+
eslint-import-resolver-typescript: ^2.5.0
10081009
eslint-plugin-import: ^2.26.0
10091010
eslint-plugin-jest: ^27.1.5
10101011
eslint-plugin-jsdoc: ^39.6.2
@@ -2730,6 +2731,22 @@ __metadata:
27302731
languageName: node
27312732
linkType: hard
27322733

2734+
"eslint-import-resolver-typescript@npm:^2.5.0":
2735+
version: 2.7.1
2736+
resolution: "eslint-import-resolver-typescript@npm:2.7.1"
2737+
dependencies:
2738+
debug: ^4.3.4
2739+
glob: ^7.2.0
2740+
is-glob: ^4.0.3
2741+
resolve: ^1.22.0
2742+
tsconfig-paths: ^3.14.1
2743+
peerDependencies:
2744+
eslint: "*"
2745+
eslint-plugin-import: "*"
2746+
checksum: 1d81b657b1f73bf95b8f0b745c0305574b91630c1db340318f3ca8918e206fce20a933b95e7c419338cc4452cb80bb2b2d92acaf01b6aa315c78a332d832545c
2747+
languageName: node
2748+
linkType: hard
2749+
27332750
"eslint-module-utils@npm:^2.7.4":
27342751
version: 2.7.4
27352752
resolution: "eslint-module-utils@npm:2.7.4"
@@ -3382,6 +3399,20 @@ __metadata:
33823399
languageName: node
33833400
linkType: hard
33843401

3402+
"glob@npm:^7.2.0":
3403+
version: 7.2.3
3404+
resolution: "glob@npm:7.2.3"
3405+
dependencies:
3406+
fs.realpath: ^1.0.0
3407+
inflight: ^1.0.4
3408+
inherits: 2
3409+
minimatch: ^3.1.1
3410+
once: ^1.3.0
3411+
path-is-absolute: ^1.0.0
3412+
checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133
3413+
languageName: node
3414+
linkType: hard
3415+
33853416
"glob@npm:^8.0.1":
33863417
version: 8.1.0
33873418
resolution: "glob@npm:8.1.0"
@@ -3773,6 +3804,15 @@ __metadata:
37733804
languageName: node
37743805
linkType: hard
37753806

3807+
"is-core-module@npm:^2.13.0":
3808+
version: 2.13.0
3809+
resolution: "is-core-module@npm:2.13.0"
3810+
dependencies:
3811+
has: ^1.0.3
3812+
checksum: 053ab101fb390bfeb2333360fd131387bed54e476b26860dc7f5a700bbf34a0ec4454f7c8c4d43e8a0030957e4b3db6e16d35e1890ea6fb654c833095e040355
3813+
languageName: node
3814+
linkType: hard
3815+
37763816
"is-date-object@npm:^1.0.1":
37773817
version: 1.0.1
37783818
resolution: "is-date-object@npm:1.0.1"
@@ -4783,7 +4823,7 @@ __metadata:
47834823
languageName: node
47844824
linkType: hard
47854825

4786-
"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.2":
4826+
"minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2":
47874827
version: 3.1.2
47884828
resolution: "minimatch@npm:3.1.2"
47894829
dependencies:
@@ -5541,6 +5581,19 @@ __metadata:
55415581
languageName: node
55425582
linkType: hard
55435583

5584+
"resolve@npm:^1.22.0":
5585+
version: 1.22.8
5586+
resolution: "resolve@npm:1.22.8"
5587+
dependencies:
5588+
is-core-module: ^2.13.0
5589+
path-parse: ^1.0.7
5590+
supports-preserve-symlinks-flag: ^1.0.0
5591+
bin:
5592+
resolve: bin/resolve
5593+
checksum: f8a26958aa572c9b064562750b52131a37c29d072478ea32e129063e2da7f83e31f7f11e7087a18225a8561cfe8d2f0df9dbea7c9d331a897571c0a2527dbb4c
5594+
languageName: node
5595+
linkType: hard
5596+
55445597
"resolve@patch:resolve@^1.18.1#~builtin<compat/resolve>, resolve@patch:resolve@^1.20.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.1#~builtin<compat/resolve>":
55455598
version: 1.22.2
55465599
resolution: "resolve@patch:resolve@npm%3A1.22.2#~builtin<compat/resolve>::version=1.22.2&hash=c3c19d"
@@ -5554,6 +5607,19 @@ __metadata:
55545607
languageName: node
55555608
linkType: hard
55565609

5610+
"resolve@patch:resolve@^1.22.0#~builtin<compat/resolve>":
5611+
version: 1.22.8
5612+
resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin<compat/resolve>::version=1.22.8&hash=c3c19d"
5613+
dependencies:
5614+
is-core-module: ^2.13.0
5615+
path-parse: ^1.0.7
5616+
supports-preserve-symlinks-flag: ^1.0.0
5617+
bin:
5618+
resolve: bin/resolve
5619+
checksum: 5479b7d431cacd5185f8db64bfcb7286ae5e31eb299f4c4f404ad8aa6098b77599563ac4257cb2c37a42f59dfc06a1bec2bcf283bb448f319e37f0feb9a09847
5620+
languageName: node
5621+
linkType: hard
5622+
55575623
"retry@npm:^0.12.0":
55585624
version: 0.12.0
55595625
resolution: "retry@npm:0.12.0"

0 commit comments

Comments
 (0)