Skip to content
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/oxc_linter/src/rules/eslint/block_scoped_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ fn run_for_all_references(
ctx.scoping()
.get_resolved_references(*symbol)
.filter(|reference| {
let reference_scope_id = ctx.nodes().get_node(reference.node_id()).scope_id();

let reference_scope_id = reference.scope_id();
reference_scope_id != node.scope_id() && !scope_ids.contains(&reference_scope_id)
})
.for_each(|reference| {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_undef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Rule for NoUndef {
if name == "arguments"
&& ctx
.scoping()
.scope_ancestors(ctx.nodes().get_node(reference.node_id()).scope_id())
.scope_ancestors(reference.scope_id())
.map(|id| ctx.scoping().scope_flags(id))
.any(|scope_flags| scope_flags.is_function() && !scope_flags.is_arrow())
{
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl<'a> Symbol<'_, 'a> {
// cancel = cancel?.(); // `cancel` is used
// }
// ```
if self.get_parent_variable_scope(self.get_ref_scope(reference))
if self.get_parent_variable_scope(Symbol::get_ref_scope(reference))
!= self.get_parent_variable_scope(self.scope_id())
{
return false;
Expand Down Expand Up @@ -831,8 +831,8 @@ impl<'a> Symbol<'_, 'a> {

/// Get the [`ScopeId`] where a [`Reference`] is located.
#[inline]
fn get_ref_scope(&self, reference: &Reference) -> ScopeId {
self.nodes().get_node(reference.node_id()).scope_id()
fn get_ref_scope(reference: &Reference) -> ScopeId {
reference.scope_id()
}

/// Get the [`Span`] covering the [`AstNode`] containing a [`Reference`].
Expand Down
7 changes: 3 additions & 4 deletions crates/oxc_mangler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use base54::base54;
use oxc_allocator::{Allocator, BitSet, Vec};
use oxc_ast::ast::{Declaration, Program, Statement};
use oxc_data_structures::inline_string::InlineString;
use oxc_semantic::{AstNodes, Scoping, Semantic, SemanticBuilder, SymbolId};
use oxc_semantic::{AstNodes, Reference, Scoping, Semantic, SemanticBuilder, SymbolId};
use oxc_span::{Atom, CompactStr};

pub(crate) mod base54;
Expand Down Expand Up @@ -406,9 +406,8 @@ impl<'t> Mangler<'t> {
.iter()
.map(|r| ast_nodes.get_node(r.declaration).scope_id());

let referenced_scope_ids = scoping
.get_resolved_references(symbol_id)
.map(|reference| ast_nodes.get_node(reference.node_id()).scope_id());
let referenced_scope_ids =
scoping.get_resolved_references(symbol_id).map(Reference::scope_id);

// Calculate the scope ids that this symbol is alive in.
// For each used_scope_id, we walk up the ancestor chain and collect scopes
Expand Down
Loading