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.

no-unused-vars when destructuring

See original GitHub issue

Tell us about your environment

  • ESLint Version: ^3.14.1
  • Node Version: 7.4
  • npm Version: 3

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

babel-eslint

Please show your full configuration:

https://github.com/gajus/eslint-config-canonical/blob/master/configurations/eslintrc.json

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

Using a stateless component whose first argument contains both the children and all other props passed to it.

I want to pass only the props to another component:

const statelessReactComponent = ({ children, ...props }) => {
  return <someOtherComponent {...props} />
};

Here it complains that “[eslint] ‘children’ is defined but never used. (no-unused-vars)”

I don’t intend to use it but I still have to define it like that because I only want to pass down props, so the children is required while destructuring, much like when you want to use second argument you still have to declare the first argument in a function.

What did you expect to happen?

no-unused-vars should consider destructuring

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mysticateacommented, Feb 3, 2017

Thank you for the report.

We have the plan to release ignoreRestSiblings option of no-unused-vars rule: #7968. Please wait for the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars option to allow unused vars in object ...
I'd like an option for the no-unused-vars rule that would allow unused variables that are created as part of an object destructuring pattern ......
Read more >
Omit property variable when using object destructuring
We're omitting property a from the object, but then const a is assigned a value, but never used - error from eslint (no-unused-vars)....
Read more >
no-unused-vars and destructuring
The code is, I believe, correct and the two symbols are necessary for it to work. How can I stop ESLint complaining?
Read more >
no-unused-vars - 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 >
The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
The no-unused-vars rule is one of the most important ESLint rules for keeping code ... Allowing unused values when destructuring arrays ...
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