Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 Returning the return value of a hook triggers false positive for useHookAtTopLevel #4483

Closed
1 task done
jaskp opened this issue May 15, 2023 · 0 comments · Fixed by #4538
Closed
1 task done
Assignees
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@jaskp
Copy link

jaskp commented May 15, 2023

Environment information

CLI:
  Version:                      12.1.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  ROME_LOG_DIR:                 unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v16.18.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/1.22.19"

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

What happened?

Hooks where the return value of another hook is immediately returned trigger a false positive for useHookAtTopLevel.

>Rome playground link<

Example:

const useFoo = () => {
  return useState() // not valid according to useHookAtTopLevel
}

Expected result

The code should pass the useHookAtTopLevel rule as valid.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@jaskp jaskp added the S-To triage Status: user report of a possible bug that needs to be triaged label May 15, 2023
@nissy-dev nissy-dev self-assigned this May 16, 2023
@nissy-dev nissy-dev added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Linter Area: linter and removed S-To triage Status: user report of a possible bug that needs to be triaged labels May 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
2 participants