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

Add lints for hooks in conditional branches (&& + ||) #2940

Open
matthunz opened this issue Sep 7, 2024 · 0 comments
Open

Add lints for hooks in conditional branches (&& + ||) #2940

matthunz opened this issue Sep 7, 2024 · 0 comments
Labels
check Related to the dioxus-check crate enhancement New feature or request

Comments

@matthunz
Copy link
Contributor

matthunz commented Sep 7, 2024

Feature Request

Follow-up for #2902

We should add lints for hooks in conditional branches such as:

  • if statements:
    let some_value = false;
    if some_value && use_signal(|| true)() {
        println!("123");
    }
  • match statements:
    let some_value = Some(false);
    match x {
         Some(b) if b && use_signal(|| true)() => { ... }
         ...
    }

Implement Suggestion

Add checks to https://github.com/DioxusLabs/dioxus/blob/main/packages/check/src/check.rs

We could ignore cases where literals (and maybe constants) are used if possible (e.g. if true && use_hook(...)), but clippy should hopefully prevent cases like that

@matthunz matthunz added enhancement New feature or request check Related to the dioxus-check crate labels Sep 7, 2024
@matthunz matthunz changed the title Add lints for hooks in conditional branches Add lints for hooks in conditional branches (&& + ||) Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
check Related to the dioxus-check crate enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant