Skip to content

Commit a3d475b

Browse files
committed
feat(linter): add vue/valid-define-emits
1 parent 9bac168 commit a3d475b

File tree

5 files changed

+589
-1
lines changed

5 files changed

+589
-1
lines changed

crates/oxc_linter/src/context/host.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub struct ContextSubHost<'a> {
2828
/// `eslint-disable` or `eslint-disable-next-line`.
2929
pub(super) disable_directives: Rc<DisableDirectives<'a>>,
3030
// Specific framework options, for example, whether the context is inside `<script setup>` in Vue files.
31-
#[expect(dead_code)]
3231
pub(super) framework_options: FrameworkOptions,
3332
/// The source text offset of the sub host
3433
pub(super) source_text_offset: u32,
@@ -74,7 +73,25 @@ impl<'a> ContextSubHost<'a> {
7473
framework_options: frameworks_options,
7574
}
7675
}
76+
77+
/// Shared reference to the [`Semantic`] analysis
78+
#[inline]
79+
pub fn semantic(&self) -> &Rc<Semantic<'a>> {
80+
&self.semantic
81+
}
82+
83+
/// Shared reference to the [`ModuleRecord`]
84+
#[inline]
85+
pub fn module_record(&self) -> &ModuleRecord {
86+
&self.module_record
87+
}
88+
89+
/// Shared reference to the [`DisableDirectives`]
90+
pub fn disable_directives(&self) -> &Rc<DisableDirectives<'a>> {
91+
&self.disable_directives
92+
}
7793
}
94+
7895
/// Stores shared information about a file being linted.
7996
///
8097
/// When linting a file, there are a number of shared resources that are
@@ -361,6 +378,19 @@ impl<'a> ContextHost<'a> {
361378
pub fn frameworks(&self) -> FrameworkFlags {
362379
self.frameworks
363380
}
381+
382+
pub fn frameworks_options(&self) -> FrameworkOptions {
383+
self.current_sub_host().framework_options
384+
}
385+
386+
pub fn other_file_hosts(&self) -> Vec<&ContextSubHost<'a>> {
387+
self.sub_hosts
388+
.iter()
389+
.enumerate()
390+
.filter(|(index, _)| *index != *self.current_sub_host_index.borrow())
391+
.map(|(_, sub_host)| sub_host)
392+
.collect()
393+
}
364394
}
365395

366396
impl<'a> From<ContextHost<'a>> for Vec<Message<'a>> {

crates/oxc_linter/src/context/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ impl<'a> LintContext<'a> {
442442
pub fn frameworks(&self) -> FrameworkFlags {
443443
self.parent.frameworks
444444
}
445+
446+
pub fn other_file_hosts(&self) -> Vec<&ContextSubHost<'a>> {
447+
self.parent.other_file_hosts()
448+
}
445449
}
446450

447451
/// Gets the prefixed plugin name, given the short plugin name.

crates/oxc_linter/src/rules.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ mod node {
622622
pub mod no_new_require;
623623
}
624624

625+
mod vue {
626+
pub mod valid_define_emits;
627+
}
628+
625629
oxc_macros::declare_all_lint_rules! {
626630
eslint::array_callback_return,
627631
eslint::arrow_body_style,
@@ -1196,4 +1200,5 @@ oxc_macros::declare_all_lint_rules! {
11961200
vitest::prefer_to_be_object,
11971201
vitest::prefer_to_be_truthy,
11981202
vitest::require_local_test_context_for_concurrent_snapshots,
1203+
vue::valid_define_emits,
11991204
}

0 commit comments

Comments
 (0)