Skip to content

Commit 56db8fa

Browse files
committed
refactor(linter): move imports (#14085)
Pure refactor. `run_external_rules` used to be feature-gated, so had a bunch of `use` statements in its body. But it's not feature-gated any more, so move them up to top level. Also move a few imports in tests.
1 parent a7dd0c7 commit 56db8fa

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

crates/oxc_linter/src/lib.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
#![expect(clippy::self_named_module_files)] // for rules.rs
22

3-
use std::{path::Path, rc::Rc};
3+
use std::{
4+
mem,
5+
path::Path,
6+
ptr::{self, NonNull},
7+
rc::Rc,
8+
};
49

510
use oxc_allocator::Allocator;
6-
use oxc_ast::ast_kind::AST_TYPE_MAX;
11+
use oxc_ast::{ast::Program, ast_kind::AST_TYPE_MAX};
712
use oxc_ast_macros::ast;
813
use oxc_ast_visit::utf8_to_utf16::Utf8ToUtf16;
914
use oxc_data_structures::box_macros::boxed_array;
15+
use oxc_diagnostics::OxcDiagnostic;
1016
use oxc_semantic::AstNode;
11-
12-
#[cfg(test)]
13-
mod tester;
17+
use oxc_span::Span;
1418

1519
mod ast_util;
1620
mod config;
@@ -41,6 +45,9 @@ mod generated {
4145
mod rule_runner_impls;
4246
}
4347

48+
#[cfg(test)]
49+
mod tester;
50+
4451
pub use crate::{
4552
config::{
4653
BuiltinLintPlugins, Config, ConfigBuilderError, ConfigStore, ConfigStoreBuilder,
@@ -66,7 +73,7 @@ pub use crate::{
6673
use crate::{
6774
config::{LintConfig, OxlintEnv, OxlintGlobals, OxlintSettings},
6875
context::ContextHost,
69-
fixer::{Fixer, Message},
76+
fixer::{Fixer, Message, PossibleFixes},
7077
rules::RuleEnum,
7178
utils::iter_possible_jest_call_node,
7279
};
@@ -328,17 +335,6 @@ impl Linter {
328335
ctx_host: &mut Rc<ContextHost<'a>>,
329336
allocator: &'a Allocator,
330337
) {
331-
use std::{
332-
mem,
333-
ptr::{self, NonNull},
334-
};
335-
336-
use oxc_ast::ast::Program;
337-
use oxc_diagnostics::OxcDiagnostic;
338-
use oxc_span::Span;
339-
340-
use crate::fixer::PossibleFixes;
341-
342338
if external_rules.is_empty() {
343339
return;
344340
}
@@ -465,13 +461,14 @@ impl RawTransferMetadata {
465461

466462
#[cfg(test)]
467463
mod test {
464+
use std::fs;
465+
466+
use project_root::get_project_root;
467+
468468
use super::Oxlintrc;
469469

470470
#[test]
471471
fn test_schema_json() {
472-
use std::fs;
473-
474-
use project_root::get_project_root;
475472
let path = get_project_root().unwrap().join("npm/oxlint/configuration_schema.json");
476473
let schema = schemars::schema_for!(Oxlintrc);
477474
let json = serde_json::to_string_pretty(&schema).unwrap();

0 commit comments

Comments
 (0)