Skip to content

Commit 37ffa36

Browse files
committed
fix(linter): No more clippy warnings
1 parent 948a35d commit 37ffa36

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

crates/oxc_linter/src/context/host.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ use crate::{
1818
config::{LintConfig, LintPlugins, OxlintEnv, OxlintGlobals, OxlintSettings},
1919
disable_directives::{DisableDirectives, DisableDirectivesBuilder, RuleCommentType},
2020
fixer::{Fix, FixKind, Message, PossibleFixes},
21-
frameworks::{self, FrameworkOptions},
21+
frameworks::FrameworkOptions,
2222
module_record::ModuleRecord,
2323
options::LintOptions,
2424
rules::RuleEnum,
2525
};
2626

27+
#[cfg(not(test))]
28+
use crate::frameworks::{has_jest_imports, has_vitest_imports, is_jestlike_file};
29+
2730
use super::{LintContext, plugin_name_to_prefix};
2831

2932
/// Stores shared information about a script block being linted.
@@ -491,9 +494,9 @@ impl<'a> ContextHost<'a> {
491494
if self.plugins().has_test() {
492495
// let mut test_flags = FrameworkFlags::empty();
493496

494-
let vitest_like = frameworks::has_vitest_imports(self.module_record());
495-
let jest_like = frameworks::is_jestlike_file(&self.file_path)
496-
|| frameworks::has_jest_imports(self.module_record());
497+
let vitest_like = has_vitest_imports(self.module_record());
498+
let jest_like =
499+
is_jestlike_file(&self.file_path) || has_jest_imports(self.module_record());
497500

498501
self.frameworks.set(FrameworkFlags::Vitest, vitest_like);
499502
self.frameworks.set(FrameworkFlags::Jest, jest_like);

crates/oxc_linter/src/frameworks.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use std::{hash, path::Path};
1+
use std::hash;
2+
#[cfg(not(test))]
3+
use std::path::Path;
24

35
use bitflags::bitflags;
46

7+
#[cfg(not(test))]
58
use crate::ModuleRecord;
69

710
bitflags! {
@@ -72,6 +75,7 @@ impl FrameworkFlags {
7275
}
7376

7477
/// <https://jestjs.io/docs/configuration#testmatch-arraystring>
78+
#[cfg(not(test))]
7579
pub fn is_jestlike_file(path: &Path) -> bool {
7680
use std::ffi::OsStr;
7781

@@ -88,12 +92,14 @@ pub fn is_jestlike_file(path: &Path) -> bool {
8892
.is_some_and(|name_or_first_ext| name_or_first_ext == "test" || name_or_first_ext == "spec")
8993
}
9094

95+
#[cfg(not(test))]
9196
pub fn has_vitest_imports(module_record: &ModuleRecord) -> bool {
9297
module_record.import_entries.iter().any(|entry| {
9398
entry.module_request.name() == "vitest" || entry.module_request.name() == "vite-plus/test"
9499
})
95100
}
96101

102+
#[cfg(not(test))]
97103
pub fn has_jest_imports(module_record: &ModuleRecord) -> bool {
98104
module_record.import_entries.iter().any(|entry| entry.module_request.name() == "@jest/globals")
99105
}

0 commit comments

Comments
 (0)