-
-
Notifications
You must be signed in to change notification settings - Fork 501
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(lint/useExhaustiveDependencies): support Preact #2105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b | |
|
||
Contributed by @Conaclos | ||
|
||
- Implement [#2043](https://github.com/biomejs/biome/issues/2043): The React rule [`useExhaustiveDependencies`](https://biomejs.dev/linter/rules/use-exhaustive-dependencies/) is now also compatible with Preact hooks imported from `preact/hooks` or `preact/compat`. Contributed by @arendjr | ||
|
||
#### Enhancements | ||
|
||
#### Bug fixes | ||
|
@@ -268,7 +270,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b | |
|
||
- Support applying lint fixes when calling the `lintContent` method of the `Biome` class ([#1956](https://github.com/biomejs/biome/pull/1956)). Contributed by @mnahkies | ||
|
||
### Linter | ||
### Parser | ||
|
||
#### Bug fixes | ||
|
||
|
@@ -359,10 +361,6 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b | |
|
||
#### Bug fixes | ||
|
||
- JavaScript lexer is now able to lex regular expression literals with escaped non-ascii chars ([#1941](https://github.com/biomejs/biome/issues/1941)). | ||
|
||
Contributed by @Sec-ant | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, that was indeed a wrongly merged conflict. I'll fix right away, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
## 1.6.0 (2024-03-08) | ||
|
||
### Analyzer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useCallback } from 'preact/compat'; | ||
import { useState } from 'preact/hooks'; | ||
|
||
function useCounter() { | ||
const [value, setValue] = useState(0); | ||
const increment = useCallback(() => { | ||
setValue(value + 1); | ||
}, []); | ||
return { value, increment }; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: preactHooks.js | ||
--- | ||
# Input | ||
```jsx | ||
import { useCallback } from 'preact/compat'; | ||
import { useState } from 'preact/hooks'; | ||
|
||
function useCounter() { | ||
const [value, setValue] = useState(0); | ||
const increment = useCallback(() => { | ||
setValue(value + 1); | ||
}, []); | ||
return { value, increment }; | ||
} | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
preactHooks.js:6:23 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
! This hook does not specify all of its dependencies: value | ||
|
||
4 │ function useCounter() { | ||
5 │ const [value, setValue] = useState(0); | ||
> 6 │ const increment = useCallback(() => { | ||
│ ^^^^^^^^^^^ | ||
7 │ setValue(value + 1); | ||
8 │ }, []); | ||
|
||
i This dependency is not specified in the hook dependency list. | ||
|
||
5 │ const [value, setValue] = useState(0); | ||
6 │ const increment = useCallback(() => { | ||
> 7 │ setValue(value + 1); | ||
│ ^^^^^ | ||
8 │ }, []); | ||
9 │ return { value, increment }; | ||
|
||
i Either include it or remove the dependency array | ||
|
||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?