Skip to content

Commit 83fb5cb

Browse files
committed
refactor(linter): make disable directives own the rule name
1 parent 6bc7664 commit 83fb5cb

File tree

4 files changed

+87
-70
lines changed

4 files changed

+87
-70
lines changed

crates/oxc_linter/src/context/host.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct ContextSubHost<'a> {
3232
pub(super) module_record: Arc<ModuleRecord>,
3333
/// Information about specific rules that should be disabled or enabled, via comment directives like
3434
/// `eslint-disable` or `eslint-disable-next-line`.
35-
pub(super) disable_directives: DisableDirectives<'a>,
35+
pub(super) disable_directives: DisableDirectives,
3636
// Specific framework options, for example, whether the context is inside `<script setup>` in Vue files.
3737
pub(super) framework_options: FrameworkOptions,
3838
/// The source text offset of the sub host
@@ -93,7 +93,7 @@ impl<'a> ContextSubHost<'a> {
9393
}
9494

9595
/// Shared reference to the [`DisableDirectives`]
96-
pub fn disable_directives(&self) -> &DisableDirectives<'a> {
96+
pub fn disable_directives(&self) -> &DisableDirectives {
9797
&self.disable_directives
9898
}
9999
}
@@ -202,7 +202,7 @@ impl<'a> ContextHost<'a> {
202202
}
203203

204204
/// Shared reference to the [`DisableDirectives`] of the current script block.
205-
pub fn disable_directives(&self) -> &DisableDirectives<'a> {
205+
pub fn disable_directives(&self) -> &DisableDirectives {
206206
&self.current_sub_host().disable_directives
207207
}
208208

@@ -309,7 +309,7 @@ impl<'a> ContextHost<'a> {
309309
"Unused eslint-enable directive (no matching eslint-disable directives were found).";
310310
for (rule_name, enable_comment_span) in self.disable_directives().unused_enable_comments() {
311311
unused_directive_diagnostics.push((
312-
rule_name.map_or(Cow::Borrowed(message_for_enable), |name| {
312+
rule_name.as_ref().map_or(Cow::Borrowed(message_for_enable), |name| {
313313
Cow::Owned(format!(
314314
"Unused eslint-enable directive (no matching eslint-disable directives were found for {name})."
315315
))

crates/oxc_linter/src/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a> LintContext<'a> {
125125

126126
/// List of all disable directives in the file being linted.
127127
#[inline]
128-
pub fn disable_directives(&self) -> &DisableDirectives<'a> {
128+
pub fn disable_directives(&self) -> &DisableDirectives {
129129
self.parent.disable_directives()
130130
}
131131

0 commit comments

Comments
 (0)