Skip to content

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

Closed
@jwhitlock

Description

@jwhitlock

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions