-
Notifications
You must be signed in to change notification settings - Fork 17
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
Ignore rest siblings for no-unused-vars
#213
Ignore rest siblings for no-unused-vars
#213
Conversation
The `ignoreRestSiblings` rule has been enabled for the `no-unused-vars` rule [1] and the `@typescript-eslint/no-unused-vars` rule [2]. This allows the use of unused variables alongside a rest operator. This pattern can be useful for excluding variables from a group that you don't want to use. This option is already in use in the `@metamask/controllers` repository [3]. [1]: https://eslint.org/docs/rules/no-unused-vars [2]: /~https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md [3]: /~https://github.com/MetaMask/controllers/blob/8134da08a03fb63b146f8a3cffcb5e78fb70d58b/.eslintrc.js#L40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this change. Does this make it possible to do something like this:
const { foo, bar, ...rest } = someObject;
where foo
and bar
are allowed to be unused? If so then it's not clear to me how this is easier to use or clearer than:
const { _foo, _bar, ...rest } = someObject;
I know you said we are already using this in controllers, but is there an example of this in use?
This is the only use I know of: /~https://github.com/MetaMask/controllers/blob/main/src/network/NetworkController.ts#L291 The alternative you showed would not work because
So... not terrible 🤔 A bit verbose maybe. |
I don't feel strongly either way on this one. The workaround of aliasing the unused vars works for me. |
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the NetworkController example again (now available here). For some reason, my brain wasn't connecting the dots when I looked at that initially, but now I understand. This change makes sense to me and I agree with Erik that the workaround seems annoying.
The
ignoreRestSiblings
rule has been enabled for theno-unused-vars
rule and the@typescript-eslint/no-unused-vars
rule. This allows the use of unused variables alongside a rest operator. This pattern can be useful for excluding variables from a group that you don't want to use.This option is already in use in the
@metamask/controllers
repository.