Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Adds hooks-strict-return #237

Merged
merged 5 commits into from
Apr 18, 2019
Merged

Adds hooks-strict-return #237

merged 5 commits into from
Apr 18, 2019

Conversation

cartogram
Copy link
Contributor

@cartogram cartogram commented Apr 9, 2019

closes #234

@cartogram
Copy link
Contributor Author

@lemonmade @GoodForOneFare @michelleyschen @TheMallen Can I get some initial feedback on this rule? Is this what we want to enforce? Anything I am missing?

Worth noting that I am not looking to get this to the point where it will know everything about what you are returning. For example, if the variables you are returning are the result of a function call or from another file.

@lemonmade
Copy link
Member

I am board with this 👍

@cartogram cartogram changed the title [WIP] Adds hooks-strict-return Adds hooks-strict-return Apr 15, 2019
Copy link
Member

@lemonmade lemonmade left a comment

Choose a reason for hiding this comment

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

Code LGTM but I think the flow control bits are probably going to prevent some violations from being caught

return;
}

inHook = false;
Copy link
Member

Choose a reason for hiding this comment

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

I suspect something like this will cause the rule to not complain, even though it should:

function useFoo() {
  useEffect(() => {});

  return [1, 2, 3, 4];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cartogram cartogram merged commit ff94c17 into master Apr 18, 2019
@cartogram cartogram deleted the hooks-strict-return branch April 18, 2019 02:07
cartogram pushed a commit that referenced this pull request Apr 26, 2019
* 'master' of github.com:Shopify/eslint-plugin-shopify:
  Optimize images-no-direct-imports rule
  Update dependencies to enable Greenkeeper 🌴 (#244)
  Dependency updates (#242)
  Fix restrict-full-import (#243)
  Adds `hooks-strict-return` (#237)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lint rule for "what do I return from a hook?"
2 participants