Skip to content

Commit 8f00fa4

Browse files
re-tarocamc314
authored andcommitted
refactor: reduce Path::new calls
1 parent 163d272 commit 8f00fa4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/oxc_linter/src/rules/react/only_export_components.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::path::Path;
2+
13
use oxc_ast::{AstKind, ast::*};
24
use oxc_diagnostics::OxcDiagnostic;
35
use oxc_macros::declare_oxc_lint;
@@ -294,11 +296,9 @@ impl OnlyExportComponents {
294296
}
295297

296298
fn should_scan(f: &str, check_js: bool) -> bool {
297-
use std::path::Path;
298-
Path::new(f).extension().is_some_and(|ext| ext.eq_ignore_ascii_case("tsx"))
299-
|| Path::new(f).extension().is_some_and(|ext| ext.eq_ignore_ascii_case("jsx"))
300-
|| (check_js
301-
&& Path::new(f).extension().is_some_and(|ext| ext.eq_ignore_ascii_case("js")))
299+
let ext = Path::new(f).extension().and_then(|e| e.to_str());
300+
matches!(ext, Some(e) if e.eq_ignore_ascii_case("tsx") || e.eq_ignore_ascii_case("jsx"))
301+
|| (check_js && matches!(ext, Some(e) if e.eq_ignore_ascii_case("js")))
302302
}
303303

304304
fn starts_with_ascii_upper(s: &str) -> bool {

0 commit comments

Comments
 (0)