Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioduarte committed Sep 19, 2024
1 parent 981362a commit c168909
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions crates/biome_js_analyze/src/lint/nursery/use_object_has_own.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Rule for UseObjectHasOwn {
let is_call_member = member_expr.member_name()?.text() == "call";
let is_has_own_property = obj_expr.member_name()?.text() == "hasOwnProperty";
let is_valid_scope = variable_scope.is_none() || variable_scope?.is_global_scope();
let has_left_hand = has_left_hand_object(obj_expr)?;
let has_left_hand = has_left_hand_object(&obj_expr)?;

if is_call_member && is_has_own_property && has_left_hand && is_valid_scope {
return Some(());
Expand Down Expand Up @@ -134,7 +134,7 @@ impl Rule for UseObjectHasOwn {

/// Checks if the given node is considered to be an access to a property of `Object.prototype`.
/// Returns `true` if `expression.object` is `Object`, `Object.prototype`, or `{}` (empty `JsObjectExpression`).
fn has_left_hand_object(member_expr: AnyJsMemberExpression) -> Option<bool> {
fn has_left_hand_object(member_expr: &AnyJsMemberExpression) -> Option<bool> {
let object = member_expr.object().ok()?.omit_parentheses();

let node = match &object {
Expand All @@ -157,14 +157,11 @@ fn has_left_hand_object(member_expr: AnyJsMemberExpression) -> Option<bool> {
_ => object,
};

match &node {
AnyJsExpression::JsIdentifierExpression(id_expr) => {
if id_expr.name().ok()?.text() == "Object" {
return Some(true);
}
if let AnyJsExpression::JsIdentifierExpression(id_expr) = &node {
if id_expr.name().ok()?.text() == "Object" {
return Some(true);
}
_ => (),
};
}

Some(false)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_semantic/src/semantic_model/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Eq for Scope {}

impl Scope {
pub fn is_global_scope(&self) -> bool {
return self.id.index() == 0;
self.id.index() == 0
}

/// Returns all parents of this scope. Starting with the current
Expand Down

0 comments on commit c168909

Please sign in to comment.