MetaMask / core

This monorepo is a collection of packages used across multiple MetaMask clients
MIT License
288 stars 185 forks source link

ESLint behaves differently on different system #4540

Open rekmarks opened 3 months ago

rekmarks commented 3 months ago

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)
MajorLift commented 3 months ago

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.

rekmarks commented 3 months ago

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
rekmarks commented 3 months ago

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.

mcmire commented 3 months ago

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

mcmire commented 5 days ago

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.