ESLint behaves differently on different system
Recently, @mcmire put up #4537 to address some lint errors he observes locally (ref: https://github.com/MetaMask/core/pull/4537#issuecomment-2237108995). These began to appear on his system after my PR #4521. I am unable to observe the same errors. On the other hand, I observe no less than 44 errors from the root yarn lint on current main (b7fa70e1):
ESLint output
./packages/json-rpc-middleware-stream/src/createStreamMiddleware.ts
115:63 error Invalid type "Infer" of template literal expression @typescript-eslint/restrict-template-expressions
154:70 error Invalid type "any" of template literal expression @typescript-eslint/restrict-template-expressions
./packages/json-rpc-middleware-stream/src/index.test.ts
34:7 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
./packages/permission-controller/src/permission-middleware.ts
89:34 error Invalid type "any" of template literal expression @typescript-eslint/restrict-template-expressions
./packages/permission-log-controller/tests/PermissionLogController.test.ts
108:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
135:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
161:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
185:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
211:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
235:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
243:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
251:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
315:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
343:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
394:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
409:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
424:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
431:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
453:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
484:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
489:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
511:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
538:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
548:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
570:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
593:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
619:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
640:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
658:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
714:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
755:11 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
./packages/queued-request-controller/src/QueuedRequestMiddleware.test.ts
17:21 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
31:21 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
45:21 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
59:21 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
73:23 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
97:23 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
118:23 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
134:7 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
158:7 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
182:9 error Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
203:25 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
./packages/selected-network-controller/tests/SelectedNetworkMiddleware.test.ts
43:21 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
72:23 error Promise returned in function argument where a void return was expected @typescript-eslint/no-misused-promises
✖ 44 problems (44 errors, 0 warnings)
Comment thread where two more people experienced this: https://github.com/MetaMask/core/pull/4506#discussion_r1673148521
In my case, it was something about my local dev environment that was off. Unfortunately, I didn't document the fix that ended up working, and haven't been able to repro the bug.
It wasn't a complex fix. It might have been removing node_modules and reinstalling dependencies, removing eslint cache, or something of the sort.
I did several variations of the following to no effect:
# in ./core
# I don't know that there's more than one of these, but it's best to be sure
find . -type f -name ".eslintcache" -exec rm {} +
rm -rf node_modules
yarn cache clean
ESLint succeeds in fresh clone of the repo, but only in a different directory on my system. If I delete my original copy of the repo and replace it with the freshly cloned copy, it starts failing again. There are no .eslintconfig files in any parent directory, and the Node versions are the same. This is definitely local to my system, but I don't understand the hell that I'm in.
I'll leave this open for other people who are debugging their local ESLint behavior.
I've just run into this problem again. There are two lint issues I see locally. I have tried all of the solutions posted above to remove them without success. I've attempted to fix these here but we shouldn't have to do this: https://github.com/MetaMask/core/pull/4545
Still running into this problem as of October 2024 — this time it's the @typescript-eslint/restrict-template-expression that's failing locally for me (but obviously not failing in CI, otherwise CI would be failing on main). This ESLint rule has failed numerous times in the past for me and is rather unreliable, so it's not a surprise, but still, rather annoying.
I've just merged in #4727 which bumped all of the lint packages. I ran yarn lint locally and no longer see the false positive I was seeing before (not the one I mentioned above, but a different one with KeyringController). So it's possible that this problem is now solved, but we should keep an eye on it for now.
With the upgrade to the ESLint 9, the false positives around the typescript-eslint rules seem to be gone (in fact there are tons of eslint-disable lines we can now remove). I think the inconsistencies in behavior we were seeing before are basically gone as well. @mikesposito did report an issue in a recent PR, but I think this was due to an outdated ESLint cache file rather than a bug in any one rule.
I'm going to close this ticket for now and we can reopen it if we see it again.