palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

Add rule for React Hooks #204

Closed Gelio closed 5 years ago

Gelio commented 5 years ago

I created a rule for detecting improper uses of React Hooks. For more information about the rule take a look at the tslint-react-hooks repository.

This PR integrates the react-hooks-nesting into this repository.

I built tslint-react with the newly added rule and it works correctly with both react-hooks-nesting and built in this repository (example that reports both react-hooks-nesting for using a hook inside if and jsx-wrap-multiline):

image

tslint.json contained only the following:

{
  "extends": "tslint-react"
}

This PR is related to #186.

palantirtech commented 5 years ago

Thanks for your interest in palantir/tslint-react, @Gelio! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

gibbok commented 5 years ago

Would be fantastic to include your PR in tslint-react. Any update on this? Thanks for your great work!

Gelio commented 5 years ago

@gibbok Thank you 🙂 I see many people giving a thumbs-up on this PR, but a maintainer needs to review it. Considering the fact that Palantir is moving development resources from TSLint to ESLint, it may take a while 😟

Gelio commented 5 years ago

That's a pity. I would rather keep the hooks rule in my repo to be able to develop it freely. I will close this PR

adidahiya commented 5 years ago

Sure, you're free to do that, and users can install your package and use extends: "tslint-react-hooks"... that's exactly what that feature was designed for.

sonhanguyen commented 5 years ago

@Gelio do you mind me doing this copy paste job?

Gelio commented 5 years ago

@sonhanguyen Hey :wave: Yes, I do mind. I would rather not copy paste the rule's code over to this project as it would lead to duplication. Updates would have to be applied twice. Thus, I would rather keep the hooks rule in the tslint-react-hooks repository

Thanks for reaching out and suggesting :slightly_smiling_face: