-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
prefer-const object destructuring false positive #9108
Comments
Thanks for the report. I can reproduce this issue. |
It also happens in array destructuring e.g.: // This isn't global where it's used but the error still happens
let currentScanner = this
const result = []
for (let i = 0 ; i < value ; i++) {
let char
;[currentScanner, char] = currentScanner.consumeOne()
result.push(char)
} |
I will make it in the next few days. |
@not-an-aardvark I'm just going into to it, but there is something I'm curious about. Is the case described above really a reassignment? Or is it just a reassignment if I explicit assign a value to
Because the case below throws the same message:
So this is probably also a bug right? |
Strictly speaking, I'd say that in both cases, it is a reassignment (in 2nd case, the Either way, the first case (I reported) is definitely explicit re-assignment. But.. the nomenclature isn't really important here. The case I reported is a bug because a user wouldn't be able to use destructuring without setting |
Which case? I don't understand the question. This is a reassignment: let b = 10;
b = 20; This is not a reassignment, since let b;
b = 20;
I'm not sure what case you're referring to. Could you clarify:
|
I was thinking of working on this, but I am happy to yield to @Orlandster1998. I have a question about this issue. It is labeled as a rule-bug issue, but does it not imply that there is also a test-coverage issue? If I were working on this, I would guess that the proper course of action is (1) to write a new test that fails at present, (2) change the rule to correct the bug, (3) show that all the tests now pass. Is that incorrect? |
@jrpool Yes, you got it. We always ask for tests in pull requests (exception: when code is being refactored and behavior isn't expected to change), so it's also fair to note that a rule bug usually means we missed a case in testing. |
Any update on this? I'm currently affected by...
I'm happy to work on a PR if this has fallen through the cracks. |
@Orlandster1998 said he was going to do it. Is that happening? |
Actually... just realized my issue was due to a typo. x-/ |
@Orlandster1998 Friendly ping: Are you still working on this? (If not, totally okay, just let us know if you intend to finish this or if someone else should start looking at this.) Thanks! |
…10368) <!-- ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct). --> close #9108 **What is the purpose of this pull request? (put an "X" next to item)** [ ] Documentation update [x] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md)) [ ] New rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-proposal.md)) [ ] Changes an existing rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-change-proposal.md)) [ ] Add autofixing to a rule [ ] Add a CLI option [ ] Add something to the core [ ] Other, please explain: <!-- If the item you've checked above has a template, please paste the template questions below and answer them. (If this pull request is addressing an issue, you can just paste a link to the issue here instead.) --> #9108 <!-- Please ensure your pull request is ready: - Read the pull request guide (https://eslint.org/docs/developer-guide/contributing/pull-requests) - Include tests for this change - Update documentation for this change (if appropriate) --> <!-- The following is required for all pull requests: --> **What changes did you make? (Give an overview)** Allow: ```js (function ({ a }) { let b; ({ a, b } = obj); })(); ``` or ```js let a; { let b; ({ a, b } = obj); } ```
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? Babel-ESLint
Please show your full configuration:
/* eslint prefer-const: [ "warn", { "destructuring": "all", "ignoreReadBeforeAssign": true } ] */
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
Should pass since neither
let
norconst
can be specified at the start of the variable assignment statement.What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: