Skip to content
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

🐛 useExhaustiveDependencies error when useState is on a new line #168

Closed
1 task done
aparedes opened this issue Sep 6, 2023 · 3 comments · Fixed by #232
Closed
1 task done

🐛 useExhaustiveDependencies error when useState is on a new line #168

aparedes opened this issue Sep 6, 2023 · 3 comments · Fixed by #232

Comments

@aparedes
Copy link

aparedes commented Sep 6, 2023

Environment information

CLI:
  Version:                      1.0.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.16.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/1.22.19"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Discovering running Biome servers...

Running Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The client isn't connected to any server but rage discovered this running Biome server.

Server:
  Version:                      1.0.0
  Name:                         rome_lsp
  CPU Architecture:             x86_64
  OS:                           macos

Workspace:
  Open Documents:               0

Other Active Server Workspaces:

Workspace:
  Open Documents:               4
  Client Name:                  Visual Studio Code
  Client Version:               1.81.1

What happened?

useExhaustiveDependencies marks incorrectly a useState function as a missing dependency when the useState statement is on the next line.

https://biomejs.dev/playground/?indentStyle=space&quoteStyle=single&jsxQuoteStyle=single&lintRules=all&code=aQBtAHAAbwByAHQAIAB7ACAAdQBzAGUAUwB0AGEAdABlACwAIAB1AHMAZQBFAGYAZgBlAGMAdAAgAH0AIABmAHIAbwBtACAAJwByAGUAYQBjAHQAJwA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QBzAGUARQBmAGYAZQBjAHQAKAAoACkAIAA9AD4AIAB7AAoAIAAgACAAIABzAGUAdABTAHQAcgBpAG4AZwAoACgAYwBvAG4AdABlAG4AdAApACAAPQA%2BACAAewAKACAAIAAgACAAIAAgAHIAZQB0AHUAcgBuACAAYAAkAHsAYwBvAG4AdABlAG4AdAB9ACAAbwB0AGgAZQByAGAAOwAKACAAIAAgACAAfQApADsACgAgACAAfQAsACAAWwBdACkAOwAKAAoAIAAgAHIAZQB0AHUAcgBuACAAcwB0AHIAaQBuAGcAQwBvAG4AdABlAG4AdAA7AAoAfQA7AAoA

Expected result

No useExhaustiveDependencies error on useState functions

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico
Copy link
Member

Thank you for reporting. I opened the playground and I see a diagnostic on useEffect instead of useState. Maybe the link is incorrect?

@aparedes
Copy link
Author

aparedes commented Sep 6, 2023

Yes the diagnostic error comes on useEffect, useMemo and useCallback but the culprit is that the useState is on a new line. on the second component the useState is in line const [....] = useState("something") so it doesnt mark the dependency as missing.

@aparedes
Copy link
Author

aparedes commented Sep 6, 2023

@ematipico maybe this example is clearer, it has the same variables the only difference is line 5 and 6 vs line 18

 const [stringContent, setStringContent] =
    useState<SomeLongStringType>('Something');
 const [stringContent, setStringContent] = useState<SomeLongStringType>('Something');

https://biomejs.dev/playground/?indentStyle=space&quoteStyle=single&jsxQuoteStyle=single&lintRules=all&code=aQBtAHAAbwByAHQAIAB7ACAAdQBzAGUAUwB0AGEAdABlACwAIAB1AHMAZQBFAGYAZgBlAGMAdAAgAH0AIABmAHIAbwBtACAAJwByAGUAYQBjAHQAJwA7AAoACgB0AHkAcABlACAAUwBvAG0AZQBMAG8AbgBnAFMAdAByAGkAbgBnAFQAeQBwAGUAIAA9ACAAcwB0AHIAaQBuAGcAOwAKAGUAeABwAG8AcgB0ACAAYwBvAG4AcwB0ACAAQwBvAG0AcABvAG4AZQBuAHQAIAA9ACAAKAApACAAPQA%2BACAAewAKACAAIABjAG8AbgB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AAgACAAcgBlAHQAdQByAG4AIABgACQAewBjAG8AbgB0AGUAbgB0AH0AIABvAHQAaABlAHIAYAA7AAoAIAAgACAAIAB9ACkAOwAKACAAIAB9ACwAIABbAF0AKQA7AAoACgAgACAAcgBlAHQAdQByAG4AIABzAHQAcgBpAG4AZwBDAG8AbgB0AGUAbgB0ADsACgB9ADsACgA%3D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants