Skip to content

Commit

Permalink
refactor(js_semantic): minor changes (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Oct 6, 2023
1 parent 075b9c4 commit e188e52
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ use biome_console::markup;
use biome_deserialize::json::{has_only_known_keys, VisitJsonNode};
use biome_deserialize::{DeserializationDiagnostic, VisitNode};
use biome_js_semantic::{Binding, BindingExtensions};
use biome_js_syntax::{
JsIdentifierAssignment, JsReferenceIdentifier, JsxReferenceIdentifier, TextRange,
};
use biome_js_syntax::{AnyJsIdentifierUsage, TextRange};
use biome_json_syntax::JsonLanguage;
use biome_rowan::{declare_node_union, AstNode, SyntaxNode};
use biome_rowan::{AstNode, SyntaxNode};
use bpaf::Bpaf;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
Expand Down Expand Up @@ -58,10 +56,6 @@ declare_rule! {
}
}

declare_node_union! {
pub(crate) AnyIdentifier = JsReferenceIdentifier | JsIdentifierAssignment | JsxReferenceIdentifier
}

const RESTRICTED_GLOBALS: [&str; 2] = ["event", "error"];

/// Options for the rule `noRestrictedGlobals`.
Expand Down Expand Up @@ -134,15 +128,15 @@ impl Rule for NoRestrictedGlobals {
unresolved_reference_nodes
.chain(global_references_nodes)
.filter_map(|node| {
let node = AnyIdentifier::unwrap_cast(node);
let node = AnyJsIdentifierUsage::unwrap_cast(node);
let (token, binding) = match node {
AnyIdentifier::JsReferenceIdentifier(node) => {
AnyJsIdentifierUsage::JsReferenceIdentifier(node) => {
(node.value_token(), node.binding(model))
}
AnyIdentifier::JsxReferenceIdentifier(node) => {
AnyJsIdentifierUsage::JsxReferenceIdentifier(node) => {
(node.value_token(), node.binding(model))
}
AnyIdentifier::JsIdentifierAssignment(node) => {
AnyJsIdentifierUsage::JsIdentifierAssignment(node) => {
(node.name_token(), node.binding(model))
}
};
Expand Down
Loading

0 comments on commit e188e52

Please sign in to comment.