Skip to content

eslint-config-react-app doesn't show unused vars when destructuring at least in stateless components #4186

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

Closed
goncy opened this issue Mar 20, 2018 · 4 comments

Comments

@goncy
Copy link
Contributor

goncy commented Mar 20, 2018

Current configuration:
image

Use case, check onEdit prop:
image

Changing no-unused-vars args prop to all:
image

Result:
image

[eslint] 'onEdit' is defined but never used. (no-unused-vars)

I can create a PR for this if needed, just wanted to know if this was intentional and why, thanks!

@andriijas
Copy link
Contributor

This one made it to the latest alpha and maybe it was intentional setting before.

Now code like this will be marked with warnings:

const Foo = props  => (<div>component that doesnt use props</div>)
handleEvent(event, otherArg) {
    doStuff(otherArg)
}

Whats your opinion on that @goncy?

@goncy
Copy link
Contributor Author

goncy commented Mar 23, 2018

In my opinion props is still a unused prop in the first scenario, just that we are used to have it there, i don't think that is bad having it as a warning, the second one is true, are you getting a no-unused-vars warning for the first argument?, in that case we can change the all in args to after-used

after-used - only the last argument must be used. This allows you, for instance, to have two named parameters to a function and as long as you use the second argument, ESLint will not warn you about the first. This is the default setting.
all - all named arguments must be used.

@goncy
Copy link
Contributor Author

goncy commented Mar 23, 2018

After used:
image

All:
image

@andriijas
Copy link
Contributor

andriijas commented Mar 23, 2018

This change has been reverted. I was under the impression this change only affected object destructing in arguments and after consideration among maintainers we decided to stick with the previous setting for now. Sorry about any inconvenience.

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants