Skip to content

Relax a couple lint rules #44

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

Merged
merged 1 commit into from
Jul 20, 2016
Merged

Relax a couple lint rules #44

merged 1 commit into from
Jul 20, 2016

Conversation

lacker
Copy link
Contributor

@lacker lacker commented Jul 20, 2016

I tried applying these lint rules to a couple random projects I had lying around and ran into some frustrations. I suggest these two tweaks.

  1. no-new is now a warning instead of an error. Sometimes you have an API where all you need to do is create an object; you don't need to do anything else with it. You can usually get around the lint rule by doing something trivial, but there's no reason not to run the resulting code.
  2. no-unused-vars is now a warning instead of an error, and doesn't apply to function arguments. There's plenty of times when you have a variable and haven't used it yet but you want to see the intermediate results. Also, there are cases when it's weird to omit unused function arguments. Like when you are creating a promise with new Promise(resolve, reject), it is odd to omit reject. Or if you are using an API based on inheritance, it is odd to omit args from the signature that you don't use.

@ghost ghost added the CLA Signed label Jul 20, 2016
@gaearon gaearon merged commit ff73f16 into facebook:master Jul 20, 2016
@gaearon
Copy link
Contributor

gaearon commented Jul 20, 2016

Thanks

@vjeux
Copy link
Contributor

vjeux commented Jul 20, 2016

One convention we have on our PHP codebase (enforced by a lint rule) is to name unused arguments start with an underscore when they are intentionally unused. I really like it

@lacker
Copy link
Contributor Author

lacker commented Jul 21, 2016

I think Eclipse does that - e.g. http://stackoverflow.com/questions/11486148/unused-variable-naming-in-python . A lot of people use starting-with-an-underscore to mean different things, is the only problem with that IMO. I can't quite recall but I think Google had a convention to start the variable name with "unused". But anyway now that @gaearon bumped down all the rules one notch it is moot.

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

Successfully merging this pull request may close these issues.

3 participants