-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Feature Request] Exhaustive deps lint rule integration in tslint react hook #9
Comments
Thank you for posting this feature request. I will try to investigate the effort required to add this one into this rule 😄 Analyzing eslint's rule implementation would probably be a good starting point. There are, however, some differences when it comes to the internals that eslint and tslint expose to rule walkers (classes that explore the AST and find violations), so that may not be trivial 😄 If anyone has any ideas on this one - let me know, or, even better, file a PR yourself |
I came here to ask to exact same request. It's actually a must have feature for this plugin, but i can easily understand that's harder than it looks. Their are some hard thing to manage ... function SearchResults() {
const [query, setQuery] = useState('react');
// Imagine this function is also long
function getFetchUrl() {
return 'https://hn.algolia.com/api/v1/search?query=' + query;
}
// Imagine this function is also long
async function fetchData() {
const result = await axios(getFetchUrl());
setData(result.data);
}
useEffect(() => {
fetchData();
}, []); // error, `query` should be there
// ...
} |
First, @Gelio, thank you for your efforts to port Rules of Hooks to Surely, the We are in a transitioning period from I decided to add Here's what I did:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"useJSXTextNode": true,
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"jsx": true
}
},
"plugins": ["react-hooks"],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
References: This article helped me with the setup. |
Hi, tslint.json: {
"extends": [
"tslint:recommended",
"tslint-react-hooks"
],
...
"react-hooks-nesting": "error",
"react-hooks/exhaustive-deps": "error",
...
} Any idea how to do this? Thanks |
@alicerocheman Are you using TSLint from inside ESLint? Could you create a separate issue and describe your problem there? 🙂 |
Any update on this? I find this to be the most useful feature of the |
@JemarJones Unfortunately, no progress so far. Moreover, I do not plan to add it in the near future 🙁 The problem is not only with the fact that the ESLint's version is long. ESLint exposes different features for rule validators which TSLint does not. If I'm not mistaken, one of those features is scope analysis. TSLint does not provide that. Thus, to analyze from which scope a variable comes we would have to implement it directly in the rule, which adds a lot of engineering work and has a toll on the performance 🙁 If you really miss the exhaustive deps checking, try migrating to linting TS files using ESLint: #9 (comment) |
Recently Dan published the new rule for react hooks...is it possible to add that feature in the tslint hook?
facebook/react#14920
The text was updated successfully, but these errors were encountered: