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

react-scripts 3.1.1 requires babel-eslint 10.0.2, which has false positive for for..in loops #7648

Closed
jwhitlock opened this issue Sep 5, 2019 · 1 comment

Comments

@jwhitlock
Copy link

react-scripts 3.1.1 requires babel-eslint 10.0.2, which has a bug where a no-unused-vars warning is raised for some loops. For example, here's some code that loops over a map:

export const parseQueryString = qs => {
  const searchParams = new URLSearchParams(qs);
  const parsed = {};
  for (let [key, value] of searchParams) {
    const already = parsed[key];
    if (already === undefined) {
      parsed[key] = value;
    } else if (Array.isArray(already)) {
      parsed[key].push(value);
    } else {
      parsed[key] = [already, value];
    }
  }
  return parsed;
};

babel-eslint 10.0.2 will produce two warnings:

  Line 4:  'key' is defined but never used    no-unused-vars
  Line 4:  'value' is defined but never used  no-unused-vars

This was reported upstream as eslint/eslint#12117, and fixed in babel-eslint 10.0.3, however setting this version with react-scripts 3.1.1 causes this error when running react-scripts build:

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-eslint": "10.0.2"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-eslint was detected higher up in the tree:

  /app/frontend/node_modules/babel-eslint (version: 10.0.3) 

Manually installing incompatible versions is known to cause hard-to-debug issues.
...

It would be nice if react-scripts required babel-eslint 10.0.3 instead.

@jwhitlock
Copy link
Author

This appears to be a duplicate of #7566, and #7594 would be my proposed solution as well.

@lock lock bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant