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

fix(useExhaustiveDependencies): make stableResult optional #3764

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/biome_js_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ mod tests {
use std::slice;

use crate::lint::correctness::use_exhaustive_dependencies::{Hook, HooksOptions};
use crate::react::hooks::StableHookResult;
use crate::{analyze, AnalysisFilter, ControlFlow};

#[ignore]
Expand All @@ -202,7 +201,7 @@ mod tests {
name: "myEffect".to_string(),
closure_index: Some(0),
dependencies_index: Some(1),
stable_result: StableHookResult::None,
stable_result: None,
};
let rule_filter = RuleFilter::Rule("style", "useNodejsImportProtocol");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ pub struct Hook {
///
/// For example, for React's `useRef()` hook the value would be `true`,
/// while for `useState()` it would be `[1]`.
pub stable_result: StableHookResult,
pub stable_result: Option<StableHookResult>,
}

impl DeserializableValidator for Hook {
Expand Down Expand Up @@ -358,12 +358,14 @@ impl ReactExtensiveDependenciesOptions {
pub fn new(hooks: HooksOptions) -> Self {
let mut result = ReactExtensiveDependenciesOptions::default();
for hook in hooks.hooks {
if hook.stable_result != StableHookResult::None {
result.stable_config.insert(StableReactHookConfiguration {
hook_name: hook.name.clone(),
result: hook.stable_result,
builtin: false,
});
if let Some(stable_result) = hook.stable_result {
if stable_result != StableHookResult::None {
result.stable_config.insert(StableReactHookConfiguration {
hook_name: hook.name.clone(),
result: stable_result,
builtin: false,
});
}
}
if let (Some(closure_index), Some(dependencies_index)) =
(hook.closure_index, hook.dependencies_index)
Expand Down
2 changes: 1 addition & 1 deletion packages/@biomejs/backend-jsonrpc/src/workspace.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/@biomejs/biome/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading