Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In ESLint 6, what is the logic behind for loops throwing "no-unused-vars" linter warning? #12121

Closed
GasimGasimzada opened this issue Aug 19, 2019 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion triage An ESLint team member will look at this issue soon

Comments

@GasimGasimzada
Copy link

I am using CRA whose new version updates ESLint to v6. Now, I am getting errors in for ... of and for ... in loops. Here is an example:

if (graphQLErrors) {
  for (let err of graphQLErrors) { // this gives me error that "err" is unused
    if (err.extensions && err.extensions.status && err.extensions.status === 401) {
      return fromPromise(performRefresh()).flatMap(() => {
        return forward(operation);
      });
    }
  }
}

What's the logic and what does ESLint expect in this case?

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Aug 19, 2019
@ooflorent
Copy link

I also encounter this warning using the following statements:

const entrypoints = {};
for (const [chunk, entrypoint] of Object.entries(stats.entrypoints)) {
//          ^^^^^  ^^^^^^^^^^
//          flagged as unused
  const js = [];
  const css = [];
  for (const asset of entrypoint.assets) {
//           ^^^^^
//         also here
    if (asset.endsWith(".js")) {
      js.push(PUBLIC_PATH + asset);
    } else if (asset.endsWith(".css")) {
      css.push(PUBLIC_PATH + asset);
    }
  }
  entrypoints[chunk] = { js, css };
}

Works as expected in 6.1.0
Broken in 6.2.0

@g-plane
Copy link
Member

g-plane commented Aug 19, 2019

Duplicate of #12117 . Please track that issue.

@g-plane g-plane closed this as completed Aug 19, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 16, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

3 participants