question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:17
  • Comments:9

github_iconTop GitHub Comments

3reactions
bdharrington7commented, Sep 10, 2019

Just curious what the ETA is for publishing the patch?

1reaction
esetnikcommented, Sep 6, 2019

You can also use SKIP_PREFLIGHT_CHECK=true to avoid the issue mentioned by @jwhitlock. For the proper solution see #7594. Let’s get it merged!

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint giving false positive - typescript - Stack Overflow
I'm new to Webpack and have ran into an issue with eslint and Typescript. eslint is telling me that I'm missing return type...
Read more >
Remove high-FP-rate `detect-object-injection` eslint ... - GitLab
Problem to solve A number of eslint, and the matching semgrep eslint, rules output a significant amount of false positives. The...
Read more >
ESLint v3.19.0 released - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
prefer-optional-chain | typescript-eslint
There are a few edge cases where this rule will false positive. Use your best judgement when evaluating reported errors. Options​. This rule...
Read more >
node_modules/@typescript-eslint/eslint-plugin/CHANGELOG.md ...
eslint -plugin: [array-type] parenthesize ReadonlyArray fix (#2747) (83385ac); eslint-plugin: [no-extra-non-null-assertion] false positive with non-nullable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found