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
32 changes: 31 additions & 1 deletion crates/oxc_linter/src/context/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub struct ContextSubHost<'a> {
/// `eslint-disable` or `eslint-disable-next-line`.
pub(super) disable_directives: Rc<DisableDirectives<'a>>,
// Specific framework options, for example, whether the context is inside `<script setup>` in Vue files.
#[expect(dead_code)]
pub(super) framework_options: FrameworkOptions,
/// The source text offset of the sub host
pub(super) source_text_offset: u32,
Expand Down Expand Up @@ -74,7 +73,25 @@ impl<'a> ContextSubHost<'a> {
framework_options: frameworks_options,
}
}

/// Shared reference to the [`Semantic`] analysis
#[inline]
pub fn semantic(&self) -> &Rc<Semantic<'a>> {
&self.semantic
}

/// Shared reference to the [`ModuleRecord`]
#[inline]
pub fn module_record(&self) -> &ModuleRecord {
&self.module_record
}

/// Shared reference to the [`DisableDirectives`]
pub fn disable_directives(&self) -> &Rc<DisableDirectives<'a>> {
&self.disable_directives
}
}

/// Stores shared information about a file being linted.
///
/// When linting a file, there are a number of shared resources that are
Expand Down Expand Up @@ -361,6 +378,19 @@ impl<'a> ContextHost<'a> {
pub fn frameworks(&self) -> FrameworkFlags {
self.frameworks
}

pub fn frameworks_options(&self) -> FrameworkOptions {
self.current_sub_host().framework_options
}

pub fn other_file_hosts(&self) -> Vec<&ContextSubHost<'a>> {
self.sub_hosts
.iter()
.enumerate()
.filter(|(index, _)| *index != *self.current_sub_host_index.borrow())
.map(|(_, sub_host)| sub_host)
.collect()
}
}

impl<'a> From<ContextHost<'a>> for Vec<Message<'a>> {
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_linter/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ impl<'a> LintContext<'a> {
pub fn frameworks(&self) -> FrameworkFlags {
self.parent.frameworks
}

pub fn other_file_hosts(&self) -> Vec<&ContextSubHost<'a>> {
self.parent.other_file_hosts()
}
}

/// Gets the prefixed plugin name, given the short plugin name.
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_linter/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ mod node {
pub mod no_new_require;
}

mod vue {
pub mod valid_define_emits;
}

oxc_macros::declare_all_lint_rules! {
eslint::array_callback_return,
eslint::arrow_body_style,
Expand Down Expand Up @@ -1196,4 +1200,5 @@ oxc_macros::declare_all_lint_rules! {
vitest::prefer_to_be_object,
vitest::prefer_to_be_truthy,
vitest::require_local_test_context_for_concurrent_snapshots,
vue::valid_define_emits,
}
Loading
Loading