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

refactor(linter/consistent-function-scoping): remove Visit::enter_node usage #8538

Merged
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
21 changes: 8 additions & 13 deletions crates/oxc_linter/src/rules/unicorn/consistent_function_scoping.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use oxc_ast::{AstKind, Visit};
use rustc_hash::FxHashSet;

use oxc_ast::{visit::walk, AstKind, Visit};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::ReferenceId;
use oxc_semantic::{ReferenceId, ScopeFlags};
use oxc_span::{GetSpan, Span};
use rustc_hash::FxHashSet;

use crate::{
ast_util::{get_function_like_declaration, nth_outermost_paren_parent, outermost_paren_parent},
Expand Down Expand Up @@ -283,16 +284,10 @@ impl<'a> Visit<'a> for ReferencesFinder {
}
}

fn enter_node(&mut self, kind: AstKind<'a>) {
if let AstKind::Function(_) = kind {
self.in_function += 1;
}
}

fn leave_node(&mut self, kind: AstKind<'a>) {
if let AstKind::Function(_) = kind {
self.in_function -= 1;
}
fn visit_function(&mut self, func: &oxc_ast::ast::Function<'a>, flags: ScopeFlags) {
self.in_function += 1;
walk::walk_function(self, func, flags);
self.in_function -= 1;
}
}

Expand Down
Loading