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.

prefer-destructuring reports false positives with compound assignments

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.13.0
  • Node Version: 7.3.0
  • npm Version: 4.0.5

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

{ "parserOptions": { "ecmaVersion": 6 } }

What did you do? Please include the actual source code causing the issue.

/* eslint prefer-destructuring: error */

let foo = 0;
foo += bar.foo;

What did you expect to happen?

No error, I guess.

What actually happened? Please include the actual, raw output from ESLint.

  4:1  error  Use object destructuring                  prefer-destructuring

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
thealjeycommented, Jan 11, 2017

@kaicataldo I personally am not that big on helping people 😃 Creating and properly writing an issue just seems like too much work, sorry 😊

And my suggestion is already out there, it’s pretty simple. It goes like this:

This rule should completely ignore everything but variable definitions (var, const, let, function arguments, commonjs imports) and ignore things that are already a destructuring assignment.

That’s it, at least I cannot think of any other valid use for this rule.

2reactions
not-an-aardvarkcommented, Jan 7, 2017

I can reproduce this, thanks for the report.

It’s happening because the rule is treating the line the same as

let foo = bar.foo;

…which could be fixed to

let {foo} = bar;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bayes' Theorem Example: Surprising False Positives - YouTube
We apply Bayes' Theorem to decide the conditional probability that you have an illness given that you have tested positive for a disease....
Read more >
eslint/CHANGELOG.md
143, * 240c1a4 Fix: prefer-const object destructuring false positive (fixes ... 1114, * 3fc4e3f Fix: prefer-destructuring reporting compound assignments ...
Read more >
node_modules/eslint/CHANGELOG.md · master · tbrousso ...
39dfe08 Update: false positives in function-call-argument-newline ... 3fc4e3f Fix: prefer-destructuring reporting compound assignments ...
Read more >
eslint-config-canonical
Rule CN AB GG SD XO @babel/new‑cap ❌ 👻 👻 👻 👻 @babel/no‑invalid‑this 🚨 👻 👻 👻 👻 @babel/no‑unused‑expressions 🚨 👻 👻 👻 👻
Read more >
How to Decipher False Positives (and Negatives) with Bayes ...
When I teach conditional probability, I tell my students to pay close attention to the vertical line in the formula above.
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