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
no-unused-vars option to allow unused vars in object destructuring with rest property #4880
Comments
@bryanrsmith Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. |
Yeah, too early to add an exception. We don't make special affordances for experimental features, but feel free to follow up if it becomes official. |
Thanks. Will do.
|
@bryanrsmith What's you work around regarding this point? |
@oliviertassinari For now I used the |
I have the same problem, is it possible to tweak using a plugin? |
@neoziro I think that https://github.com/babel/eslint-plugin-babel would be the right location to add the support for this feature. |
I've written a (hopefully temporary) plugin for this at https://github.com/bryanrsmith/eslint-plugin-no-unused-vars-rest. It basically just monkey patches the option into the existing core rule. I'd be happy to submit a PR to eslint-plugin-babel if everyone would prefer that. It's a little odd, though, because it doesn't require babel-eslint. Espree's |
Thank you @bryanrsmith. That's exactly what I was looking for! Was just about to disable |
Is this not already a valid, current spec compliant pattern when used with array destructuring?
|
@uniqname this is for Object destructuring assignment, which is still a Stage 3 proposal, separate from Array destructuring, which is an ES2015 standard. |
@mmcgahan I understand that, but the |
With array destructuring, you can use this as a workaround: const [ , ...tail] = someArray; This isn't possible with object destructuring. |
Interesting. I'm not sure I would prefer that to a named destructured variable that is optionally ignored by islint, but at least the pattern is supported. Thanks @not-an-aardvark |
doesn't work with destructuring. eslint/eslint#4880 ES2015 is like three years old, @open-source-maintainers.
doesn't work with destructuring. eslint/eslint#4880 ES2015 is like three years old, @open-source-maintainers.
For posterity's sake: The |
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 that also includes an experimental rest property.Use case: experimental object rest properties offer a convenient way to shallow clone an object while omitting certain properties.
For example,
This can be done now by naming the unused variables with a pattern (instead of using the shorthand) and configuring
no-unused-vars
withvarsIgnorePattern
. It's less convenient and it adds noise, though.Rest/spread properties are still a stage 2 proposal, so it might be premature to add an option to a core rule. I figured I'd open for discussion anyways :-)
The text was updated successfully, but these errors were encountered: