Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7566
Closed
Open
Issue created Aug 19, 2019 by Administrator@rootContributor

eslint for...in / for...of false positive

Created by: shiraze

Describe the bug

ESlint shows a no-unused-vars false positive with for-in loops. Looks very similar to https://github.com/eslint/eslint/issues/12117

This issue didn't exist in react-scripts@3.0.0

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

N/A

Environment

Unfortunately, running npx create-react-app --info throws the error shown further down. I'm using react-scripts@3.1.1

Error from npx command Environment Info: (node:612) UnhandledPromiseRejectionWarning: Error: The system cannot find the path specified.

at Function.e.exports.sync (C:\Users\Shiraz.Esat\AppData\Roaming\npm\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:7778)
at Object.copySync (C:\Users\Shiraz.Esat\AppData\Roaming\npm\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:104976)
at Object.t.writeSync.e [as writeSync] (C:\Users\Shiraz.Esat\AppData\Roaming\npm\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:123499)
at C:\Users\Shiraz.Esat\AppData\Roaming\npm\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:124274
at Promise.all.then.e (C:\Users\Shiraz.Esat\AppData\Roaming\npm\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:124289)
at process._tickCallback (internal/process/next_tick.js:68:7)

(node:612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:612) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce

Create a simple function in your CRA project with something like:

    export function simple() {
      const iterate = { prop: "value" };
      for (const item in iterate) {
        console.log(item);
      }
    }

Run npm start

Expected behavior

No ESLint warnings should be shown. item is used.

Actual behavior

Compiled with warnings.

./src/utils/file.js Line 3: 'item' is defined but never used no-unused-vars

Search for the keywords to learn more about each warning. To ignore, add // eslint-disable-next-line to the line before.

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Assignee
Assign to
Time tracking