Skip to content

Commit

Permalink
feat(linter): add oxc/no-async-endpoint-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac committed Aug 31, 2024
1 parent add1465 commit abba6f2
Show file tree
Hide file tree
Showing 8 changed files with 621 additions and 7 deletions.
12 changes: 11 additions & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use std::{borrow::Cow, cell::Cell, fmt, hash::Hash};

use oxc_allocator::{Box, FromIn, Vec};
use oxc_span::{Atom, GetSpan, SourceType, Span};
use oxc_syntax::{operator::UnaryOperator, reference::ReferenceId, scope::ScopeFlags};
use oxc_syntax::{
operator::UnaryOperator, reference::ReferenceId, scope::ScopeFlags, symbol::SymbolId,
};

#[cfg(feature = "serialize")]
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
Expand Down Expand Up @@ -1056,6 +1058,14 @@ impl<'a> Function<'a> {
self.id.as_ref().map(|id| id.name.clone())
}

/// Get the [`SymbolId`] this [`Function`] is bound to.
///
/// Returns [`None`] for anonymous functions, or if semantic analysis was skipped.
#[inline]
pub fn symbol_id(&self) -> Option<SymbolId> {
self.id.as_ref().and_then(|id| id.symbol_id.get())
}

pub fn is_typescript_syntax(&self) -> bool {
matches!(
self.r#type,
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_linter/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ mod oxc {
pub mod missing_throw;
pub mod no_accumulating_spread;
pub mod no_async_await;
pub mod no_async_endpoint_handlers;
pub mod no_barrel_file;
pub mod no_const_enum;
pub mod no_optional_chaining;
Expand Down Expand Up @@ -834,6 +835,7 @@ oxc_macros::declare_all_lint_rules! {
oxc::number_arg_out_of_range,
oxc::only_used_in_recursion,
oxc::no_async_await,
oxc::no_async_endpoint_handlers,
oxc::uninvoked_array_callback,
nextjs::google_font_display,
nextjs::google_font_preconnect,
Expand Down
Loading

0 comments on commit abba6f2

Please sign in to comment.