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

feat(rule): add no-identity-handlers rule #108

Closed
wants to merge 2 commits into from

Conversation

macklinu
Copy link
Contributor

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • New rule
  • Changes an existing rule
  • Add autofixing to a rule
  • Other, please explain:

What changes did you make? (Give an overview)

This PR implements and resolves #12. It checks to see if the then() or catch() callback functions are identity functions. For our purposes, an identity function is:

  • a function that receives one argument and returns it as-is
  • a function that receives one argument and throws it as-is

I would like to flesh out the documentation for this before merging, but opening a PR in case anyone has suggestions for a better rule name or code cases I haven't considered.

@macklinu
Copy link
Contributor Author

I didn't think to check for object or array destructuring - will include those test cases and rule additions in a future commit.

getObject().then(({ a, b }) => ({ a, b }))
getArray().then(([a, b]) => [a, b])

@macklinu
Copy link
Contributor Author

I've addressed the object and array destructuring. I would like to consider better context.report() messaging as well as documentation before this PR is ready to review / merge.

@macklinu macklinu force-pushed the rule/no-identity-handlers branch 2 times, most recently from bc8c3d9 to 4a350ec Compare February 25, 2018 18:24
@macklinu
Copy link
Contributor Author

Pushed up a couple of failing test cases that need to be addressed - hadn't thought through those edge cases.

@macklinu
Copy link
Contributor Author

macklinu commented Jul 9, 2018

I opened this months ago and even I don't understand the code I wrote. 😅 Aiming to readdress this PR in the coming week or so.

@macklinu
Copy link
Contributor Author

This is pretty outdated, and I'd like to take a different approach moving forward, so will close and open a new PR some other time.

@macklinu macklinu closed this Aug 17, 2018
@MichaelDeBoey MichaelDeBoey deleted the rule/no-identity-handlers branch September 23, 2022 14:32
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.

Rule to prevent no-op promise handlers
1 participant