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.

camelcase ignoreDestructuring fails when using destructured variables

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 10.16.0
  • npm Version: 6.9.0

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

Please show your full configuration:

Configuration
/* eslint camelcase: [error, { ignoreDestructuring: true, properties: "never" }] */

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

/* eslint camelcase: [error, { ignoreDestructuring: true, properties: "never" }] */

const { a_parameter } = query

/* These should pass */
const myVar = a_parameter
console.log(`parameter is ${a_parameter}`)
(() => a_parameter)()

/* These pass */
console.log(a_parameter)
new MyClass(a_parameter)

const myObj = { a_property: "123" }

The issue is reproducible on ESLint demo:

https://eslint.org/demo/#eyJ0ZXh0IjoiLyogZXNsaW50IGNhbWVsY2FzZTogW2Vycm9yLCB7IGlnbm9yZURlc3RydWN0dXJpbmc6IHRydWUsIHByb3BlcnRpZXM6IFwibmV2ZXJcIiB9XSAqL1xyXG5cclxuY29uc3QgeyBhX3BhcmFtZXRlciB9ID0gcXVlcnlcclxuXHJcbi8qIFRoaXMgc2hvdWxkIHBhc3MgKi9cclxuY29uc3QgbXlWYXIgPSBhX3BhcmFtZXRlclxyXG5jb25zb2xlLmxvZyhgcGFyYW1ldGVyIGlzICR7YV9wYXJhbWV0ZXJ9YClcclxuKCgpID0+IGFfcGFyYW1ldGVyKSgpXHJcblxyXG5cclxuY29uc29sZS5sb2coYV9wYXJhbWV0ZXIpXHJcbm5ldyBNeUNsYXNzKGFfcGFyYW1ldGVyKVxyXG5cclxuXHJcblxyXG5jb25zdCBteU9iaiA9IHsgYV9wcm9wZXJ0eTogXCIxMjNcIiB9XHJcbiIsIm9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hVmVyc2lvbiI6Niwic291cmNlVHlwZSI6Im1vZHVsZSIsImVjbWFGZWF0dXJlcyI6e319LCJydWxlcyI6e30sImVudiI6e319fQ==

What did you expect to happen? No negatives for the statements that use the variables created from object destructuring.

What actually happened? Please include the actual, raw output from ESLint. No negatives when using variables as parameter to functions, but negatives when using it on string templates, variable attribution or as return value.

Are you willing to submit a pull request to fix this bug? No

This looks like a related issue: #2254

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Aug 4, 2019

Reopening this so we can verify if this is a bug or not.

0reactions
eslint-deprecated[bot]commented, Oct 23, 2019

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

camelcase - ESLint - Pluggable JavaScript Linter
This rule focuses on using the camelcase approach. ... camelcase style for destructured identifiers; "ignoreDestructuring": true does not check destructured ...
Read more >
React - Eslint - Camel camel case props - Stack Overflow
You can assign different variable names when destructuring: const { id, email, first_name: fistName, last_name: lastName, name } = response.
Read more >
Id-match - ESLint - W3cubDocs
This rule allows you to precisely define and enforce the variables and function names on your team should use. No more limiting yourself...
Read more >
Prevent Error with Default {} when Destructuring
Why does it throw an Error? This is because you can't destructure undefined and null values. const { age } ...
Read more >
camelCase in front, snake_case in the back : r/javascript - Reddit
By convention, for JS, we use camelCase for variable names and object ... disabling the rule for destructuring via `"ignoreDestructuring": ...
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