Skip to content
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

Fix no-unused-vars issues #7315

Merged
merged 2 commits into from
Aug 17, 2016
Merged

Fix no-unused-vars issues #7315

merged 2 commits into from
Aug 17, 2016

Conversation

ghost
Copy link

@ghost ghost commented Aug 6, 2016

This PR seeks to resolve all no-unused-vars ESLint issues in the codebase. Although useful on its own, it is focused on helping to land #6945

Each commit message references the commit where the changes should have been done, as a way to help others to review.

cc @nb

Test live: https://calypso.live/?branch=fix/no-unused-vars

@ghost ghost force-pushed the fix/no-unused-vars branch from 8d78b2e to a8b7fa0 Compare August 11, 2016 11:35
@ghost
Copy link
Author

ghost commented Aug 11, 2016

This is ready to be reviewed @nb

Now that all no-unused-vars issues in the codebase are fixed, I would propose set this as an error, to help landing #6945

@@ -44,7 +44,7 @@ module.exports = {
'no-unreachable': 1,
// Allows Chai `expect` expressions
'no-unused-expressions': 0,
'no-unused-vars': 1,
'no-unused-vars': 2,
Copy link
Contributor

@aduth aduth Aug 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we extend eslint-config-wpcalypso we can simply remove the line here because it only existed to downgrade from the default error to warning.

@nb
Copy link
Member

nb commented Aug 12, 2016

It looks like unused arguments are rarely legitimate, @nssw, @aduth, what do you think about relaxing the rule?

@nb
Copy link
Member

nb commented Aug 12, 2016

@nssw this needs a rebase – a lot of files were moved around (sorry, you weren’t lucky :) ).

@ghost ghost force-pushed the fix/no-unused-vars branch from ad4084a to 3dbef60 Compare August 12, 2016 19:03
@ghost
Copy link
Author

ghost commented Aug 12, 2016

Rebase done. I had already rebased yesterday but I guess this was bound to happen with such a cross-project PR :)

It looks like unused arguments are rarely legitimate

Thanks for the comment @nb ! I was hoping to receive something like this. I haven't left a comment for reviewers about that to avoid anchoring the topic.

So: I am not sure about this. On the one hand, I like how leaving not used arguments/variables/etc in some places (signatures for functions that process events, errs/success callbacks where you do not use the arguments, positional variables, etc) documents the code and the expectations, in a manner. On the other hand, I am not sure whether having the exception for those cases could be a source of subtle bugs yet to comprehend or whether it is a bad practice for some other reason.

I have chosen the first route, just because, well, I needed to choose one. But I would be equally happy to choose the other if more eyes see this as a code smell somehow.

@nb
Copy link
Member

nb commented Aug 16, 2016

I have chosen the first route, just because, well, I needed to choose one. But I would be equally happy to choose the other if more eyes see this as a code smell somehow.

I think it’s okay for now. After looking through your changes, the cases when we need to add line-level exception are few enough.

I read through the changes and I noticed two more things:

  • In few occasions it was hard for me to know which is the unused variable we added an exception for – maybe we should add some extra clarification for each exception saying what’s the variable and why are we adding the exception?
  • The whitespace/indentation changes were often distracting for me, do we need them in this PR?

@ghost ghost force-pushed the fix/no-unused-vars branch from c68e6ed to c145557 Compare August 16, 2016 10:26
@nb nb force-pushed the fix/no-unused-vars branch from b34fb66 to e540814 Compare August 17, 2016 15:23
Remove the rule, as it is already set to error in the config Calypso depends on
@nb nb force-pushed the fix/no-unused-vars branch from e540814 to 0183387 Compare August 17, 2016 15:51
@nb
Copy link
Member

nb commented Aug 17, 2016

Squashing and merging, thanks for working and following up on that @nssw!

@nb nb merged commit b60253e into master Aug 17, 2016
@nb nb deleted the fix/no-unused-vars branch August 17, 2016 16:10
@ghost
Copy link
Author

ghost commented Aug 18, 2016

Thanks to you @nb for you patience, the good suggestions and the time you have taken for reviewing this!

@gziolo
Copy link
Member

gziolo commented Aug 18, 2016

Nice one! We need more tasks like that 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants