Skip to content

Commit 5dc4789

Browse files
forked from facebook/react
0 parents  commit 5dc4789

File tree

10 files changed

+11943
-0
lines changed

10 files changed

+11943
-0
lines changed

CHANGELOG.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## 4.4.0
2+
3+
* No changes, this was an automated release together with React 18.
4+
5+
## 4.3.0
6+
7+
* Support ESLint 8. ([@MichaelDeBoey](https://github.com/MichaelDeBoey) in [#22248](https://github.com/facebook/react/pull/22248))
8+
* Fix a crash with an empty effect. ([@ChrisRu](https://github.com/ChrisRu) in [#20385](https://github.com/facebook/react/pull/20385))
9+
* Improve the error message. ([@callmetwan](https://github.com/callmetwan) in [#20692](https://github.com/facebook/react/pull/20692))
10+
* Handle optional chained methods as dependency. ([@AriPerkkio](https://github.com/AriPerkkio) in [#20247](https://github.com/facebook/react/pull/20247))
11+
* Assume the new `useTransition` signature in the rule. ([@rickhanlonii](https://github.com/rickhanlonii) in [#20976](https://github.com/facebook/react/pull/20976))
12+
13+
## 4.2.0
14+
15+
* No changes, this was an automated release together with React 17.
16+
17+
## 4.1.2
18+
* Fix a crash with the TypeScript 4.x parser. ([@eps1lon](https://github.com/eps1lon) in [#19815](https://github.com/facebook/react/pull/19815))
19+
20+
## 4.1.1
21+
* Improve support for optional chaining. ([@pfongkye](https://github.com/pfongkye) in [#19680](https://github.com/facebook/react/pull/19680))
22+
* Fix a false positive warning for TypeScript parameters. ([@NeoRaider](https://github.com/NeoRaider) in [#19751](https://github.com/facebook/react/pull/19751))
23+
24+
## 4.1.0
25+
* **New Violations:** Warn when dependencies change on every render. ([@captbaritone](https://github.com/captbaritone) in [#19590](https://github.com/facebook/react/pull/19590))
26+
27+
## 4.0.8
28+
* Fixes TypeScript `typeof` annotation to not be considered a dependency. ([@delca85](https://github.com/delca85) in [#19316](https://github.com/facebook/react/pull/19316))
29+
30+
## 4.0.7
31+
* Fixes an overly coarse dependency suggestion. ([@gaearon](https://github.com/gaearon) in [#19313](https://github.com/facebook/react/pull/19313))
32+
33+
## 4.0.6
34+
* Fix crashes and other bugs related to optional chaining. ([@gaearon](https://github.com/gaearon) in [#19273](https://github.com/facebook/react/pull/19273) and [#19275](https://github.com/facebook/react/pull/19275))
35+
36+
## 4.0.5
37+
* Fix a crash when the dependency array has an empty element. ([@yeonjuan](https://github.com/yeonjuan) in [#19145](https://github.com/facebook/react/pull/19145))
38+
* Fix a false positive warning that occurs with optional chaining. ([@fredvollmer](https://github.com/fredvollmer) in [#19061](https://github.com/facebook/react/pull/19061))
39+
40+
## 4.0.4
41+
* Fix a false positive warning that occurs with optional chaining. ([@fredvollmer](https://github.com/fredvollmer) in [#19061](https://github.com/facebook/react/pull/19061))
42+
* Support nullish coalescing and optional chaining. ([@yanneves](https://github.com/yanneves) in [#19008](https://github.com/facebook/react/pull/19008))
43+
44+
## 4.0.3
45+
* Remove the heuristic that checks all Hooks ending with `Effect` due to too many false positives. ([@gaearon](https://github.com/gaearon) in [#19004](https://github.com/facebook/react/pull/19004))
46+
47+
## 4.0.2
48+
* Prevent Hooks that have `Effect` in the middle from being considered effects. ([@surgeboris](https://github.com/surgeboris) in [#18907](https://github.com/facebook/react/pull/18907))
49+
50+
## 4.0.1
51+
* Declare support for ESLint 7. ([@MichaelDeBoey](https://github.com/MichaelDeBoey) in [#18878](https://github.com/facebook/react/pull/18878))
52+
53+
## 4.0.0
54+
55+
* **New Violations:** Consider `PascalCase.useFoo()` calls as Hooks. ([@cyan33](https://github.com/cyan33) in [#18722](https://github.com/facebook/react/pull/18722))
56+
* **New Violations:** Check callback body when it's not written inline. ([@gaearon](https://github.com/gaearon) in [#18435](https://github.com/facebook/react/pull/18435))
57+
* **New Violations:** Check dependencies for all Hooks ending with `Effect`. ([@airjp73](https://github.com/airjp73) in [#18580](https://github.com/facebook/react/pull/18580))
58+
* Add a way to enable the dangerous autofix. ([@gaearon](https://github.com/gaearon) in [#18437](https://github.com/facebook/react/pull/18437))
59+
* Offer a more sensible suggestion when encountering an assignment. ([@Zzzen](https://github.com/Zzzen) in [#16784](https://github.com/facebook/react/pull/16784))
60+
* Consider TypeScript casts of `useRef` as constant. ([@sophiebits](https://github.com/sophiebits) in [#18496](https://github.com/facebook/react/pull/18496))
61+
* Add documentation. ([@ghmcadams](https://github.com/ghmcadams) in [#16607](https://github.com/facebook/react/pull/16607))
62+
63+
## 3.0.0
64+
65+
* **New Violations:** Forbid calling Hooks from classes. ([@ianobermiller](https://github.com/ianobermiller) in [#18341](https://github.com/facebook/react/pull/18341))
66+
* Add a recommended config. ([@SimenB](https://github.com/SimenB) in [#14762](https://github.com/facebook/react/pull/14762))
67+
68+
## 2.5.0
69+
70+
* Fix a misleading error message in loops. ([@M-Izadmehr](https://github.com/M-Izadmehr) in [#16853](https://github.com/facebook/react/pull/16853))
71+
72+
## 2.4.0
73+
74+
* **New Violations:** Run checks for functions passed to `forwardRef`. ([@dprgarner](https://github.com/dprgarner) in [#17255](https://github.com/facebook/react/pull/17255))
75+
* **New Violations:** Check for ref usage in any Hook containing the word `Effect`. ([@gaearon](https://github.com/gaearon) in [#17663](https://github.com/facebook/react/pull/17663))
76+
* Disable dangerous autofix and use ESLint Suggestions API instead. ([@wdoug](https://github.com/wdoug) in [#17385](https://github.com/facebook/react/pull/17385))
77+
78+
## 2.0.0
79+
80+
* **New Violations:** Forbid calling Hooks at the top level. ([@gaearon](https://github.com/gaearon) in [#16455](https://github.com/facebook/react/pull/16455))
81+
* Fix a crash when referencing arguments in arrow functions. ([@hristo-kanchev](https://github.com/hristo-kanchev) in [#16356](https://github.com/facebook/react/pull/16356))
82+
83+
84+
## 1.x
85+
86+
The 1.x releases aren’t noted in this changelog, but you can find them in the [commit history](https://github.com/facebook/react/commits/main/packages/eslint-plugin-react-hooks).

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# `eslint-plugin-react-hooks`
2+
3+
This ESLint plugin enforces the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html).
4+
5+
It is a part of the [Hooks API](https://reactjs.org/docs/hooks-intro.html) for React.
6+
7+
## Installation
8+
9+
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
10+
11+
Assuming you already have ESLint installed, run:
12+
13+
```sh
14+
# npm
15+
npm install eslint-plugin-react-hooks --save-dev
16+
17+
# yarn
18+
yarn add eslint-plugin-react-hooks --dev
19+
```
20+
21+
Then extend the recommended eslint config:
22+
23+
```js
24+
{
25+
"extends": [
26+
// ...
27+
"plugin:react-hooks/recommended"
28+
]
29+
}
30+
```
31+
32+
### Custom Configuration
33+
34+
If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
35+
36+
```js
37+
{
38+
"plugins": [
39+
// ...
40+
"react-hooks"
41+
],
42+
"rules": {
43+
// ...
44+
"react-hooks/rules-of-hooks": "error",
45+
"react-hooks/exhaustive-deps": "warn"
46+
}
47+
}
48+
```
49+
50+
51+
## Advanced Configuration
52+
53+
`exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option.
54+
This option accepts a regex to match the names of custom Hooks that have dependencies.
55+
56+
```js
57+
{
58+
"rules": {
59+
// ...
60+
"react-hooks/exhaustive-deps": ["warn", {
61+
"additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
62+
}]
63+
}
64+
}
65+
```
66+
67+
We suggest to use this option **very sparingly, if at all**. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.
68+
69+
## Valid and Invalid Examples
70+
71+
Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule.
72+
73+
## License
74+
75+
MIT

0 commit comments

Comments
 (0)