diff --git a/crates/oxc_ast/src/ast/mod.rs b/crates/oxc_ast/src/ast/mod.rs index 25fe7c3092598..b9e70d1a93794 100644 --- a/crates/oxc_ast/src/ast/mod.rs +++ b/crates/oxc_ast/src/ast/mod.rs @@ -173,14 +173,6 @@ //! //! If you are seeing compile-time errors in `src/ast/macros.rs`, this will be the cause. -pub(crate) mod comment; -pub(crate) mod js; -pub(crate) mod jsx; -pub(crate) mod literal; -pub(crate) mod macros; -pub(crate) mod ts; - -use macros::inherit_variants; // Re-export AST types from other crates pub use oxc_span::{Atom, Language, LanguageVariant, ModuleKind, SourceType, Span}; pub use oxc_syntax::{ @@ -190,4 +182,17 @@ pub use oxc_syntax::{ }, }; -pub use self::{comment::*, js::*, jsx::*, literal::*, ts::*}; +pub(crate) mod comment; +pub(crate) mod js; +pub(crate) mod jsx; +pub(crate) mod literal; +pub(crate) mod macros; +pub(crate) mod ts; + +pub use comment::*; +pub use js::*; +pub use jsx::*; +pub use literal::*; +pub use ts::*; + +use macros::inherit_variants; diff --git a/crates/oxc_ast/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index 7242b2dd1708f..378391f049040 100644 --- a/crates/oxc_ast/src/serialize.rs +++ b/crates/oxc_ast/src/serialize.rs @@ -1,14 +1,15 @@ use cow_utils::CowUtils; use num_bigint::BigInt; use num_traits::Num; -use oxc_allocator::Box; -use oxc_span::{Atom, Span}; -use oxc_syntax::number::BigintBase; use serde::{ ser::{SerializeSeq, Serializer}, Serialize, }; +use oxc_allocator::Box; +use oxc_span::{Atom, Span}; +use oxc_syntax::number::BigintBase; + use crate::ast::{ BigIntLiteral, BindingPatternKind, BooleanLiteral, Directive, Elision, FormalParameter, FormalParameterKind, FormalParameters, JSXElementName, JSXIdentifier, diff --git a/crates/oxc_codegen/src/comment.rs b/crates/oxc_codegen/src/comment.rs index 8ec0c4d7dc31b..9260aa2974f43 100644 --- a/crates/oxc_codegen/src/comment.rs +++ b/crates/oxc_codegen/src/comment.rs @@ -1,6 +1,7 @@ +use rustc_hash::FxHashMap; + use oxc_ast::{Comment, CommentKind}; use oxc_syntax::identifier::is_line_terminator; -use rustc_hash::FxHashMap; use crate::{Codegen, LegalComment}; diff --git a/crates/oxc_ecmascript/src/constant_evaluation/mod.rs b/crates/oxc_ecmascript/src/constant_evaluation/mod.rs index bf7c88fcde8de..6bb1c41a48e37 100644 --- a/crates/oxc_ecmascript/src/constant_evaluation/mod.rs +++ b/crates/oxc_ecmascript/src/constant_evaluation/mod.rs @@ -1,16 +1,19 @@ -mod is_literal_value; -mod value; -mod value_type; - use std::{borrow::Cow, cmp::Ordering}; use num_bigint::BigInt; use num_traits::Zero; + use oxc_ast::ast::*; -pub use self::{is_literal_value::IsLiteralValue, value::ConstantValue, value_type::ValueType}; use crate::{side_effects::MayHaveSideEffects, ToBigInt, ToBoolean, ToInt32, ToJsString, ToNumber}; +mod is_literal_value; +mod value; +mod value_type; +pub use is_literal_value::IsLiteralValue; +pub use value::ConstantValue; +pub use value_type::ValueType; + pub trait ConstantEvaluation<'a> { fn is_global_reference(&self, ident: &IdentifierReference<'a>) -> bool { matches!(ident.name.as_str(), "undefined" | "NaN" | "Infinity") diff --git a/crates/oxc_ecmascript/src/to_big_int.rs b/crates/oxc_ecmascript/src/to_big_int.rs index c34348a551cf5..49f7dd5c953de 100644 --- a/crates/oxc_ecmascript/src/to_big_int.rs +++ b/crates/oxc_ecmascript/src/to_big_int.rs @@ -1,5 +1,6 @@ use num_bigint::BigInt; use num_traits::{One, Zero}; + use oxc_ast::ast::{BigIntLiteral, Expression}; use oxc_syntax::operator::UnaryOperator; diff --git a/crates/oxc_isolated_declarations/src/enum.rs b/crates/oxc_isolated_declarations/src/enum.rs index b885500de8478..d9a844d459bd3 100644 --- a/crates/oxc_isolated_declarations/src/enum.rs +++ b/crates/oxc_isolated_declarations/src/enum.rs @@ -1,3 +1,5 @@ +use rustc_hash::FxHashMap; + use oxc_allocator::CloneIn; use oxc_ast::ast::*; use oxc_ecmascript::ToInt32; @@ -6,7 +8,6 @@ use oxc_syntax::{ number::{NumberBase, ToJsString}, operator::{BinaryOperator, UnaryOperator}, }; -use rustc_hash::FxHashMap; use crate::{diagnostics::enum_member_initializers, IsolatedDeclarations}; diff --git a/crates/oxc_isolated_declarations/src/lib.rs b/crates/oxc_isolated_declarations/src/lib.rs index 7cd31fa27a811..780f733067a8a 100644 --- a/crates/oxc_isolated_declarations/src/lib.rs +++ b/crates/oxc_isolated_declarations/src/lib.rs @@ -5,6 +5,17 @@ //! * //! * +use std::{cell::RefCell, mem}; + +use rustc_hash::{FxHashMap, FxHashSet}; + +use oxc_allocator::{Allocator, CloneIn}; +use oxc_ast::{ast::*, AstBuilder, Visit, NONE}; +use oxc_diagnostics::OxcDiagnostic; +use oxc_span::{Atom, GetSpan, SourceType, SPAN}; + +use crate::{diagnostics::function_with_assigning_properties, scope::ScopeTree}; + mod class; mod declaration; mod diagnostics; @@ -19,16 +30,6 @@ mod scope; mod signatures; mod types; -use std::{cell::RefCell, mem}; - -use oxc_allocator::{Allocator, CloneIn}; -use oxc_ast::{ast::*, AstBuilder, Visit, NONE}; -use oxc_diagnostics::OxcDiagnostic; -use oxc_span::{Atom, GetSpan, SourceType, SPAN}; -use rustc_hash::{FxHashMap, FxHashSet}; - -use crate::{diagnostics::function_with_assigning_properties, scope::ScopeTree}; - #[derive(Debug, Default, Clone, Copy)] pub struct IsolatedDeclarationsOptions { /// Do not emit declarations for code that has an `@internal` annotation in its JSDoc comment. diff --git a/crates/oxc_isolated_declarations/src/scope.rs b/crates/oxc_isolated_declarations/src/scope.rs index c0e1fd53391a8..5bffc4656997f 100644 --- a/crates/oxc_isolated_declarations/src/scope.rs +++ b/crates/oxc_isolated_declarations/src/scope.rs @@ -1,10 +1,11 @@ use std::cell::Cell; use bitflags::bitflags; +use rustc_hash::FxHashMap; + use oxc_ast::{ast::*, visit::walk::*, Visit}; use oxc_span::Atom; use oxc_syntax::scope::{ScopeFlags, ScopeId}; -use rustc_hash::FxHashMap; bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/crates/oxc_isolated_declarations/src/signatures.rs b/crates/oxc_isolated_declarations/src/signatures.rs index 35ffd361be8d1..562d5a40e7fc4 100644 --- a/crates/oxc_isolated_declarations/src/signatures.rs +++ b/crates/oxc_isolated_declarations/src/signatures.rs @@ -1,7 +1,8 @@ +use rustc_hash::FxHashMap; + use oxc_allocator::{CloneIn, Vec}; use oxc_ast::ast::{TSMethodSignatureKind, TSSignature}; use oxc_span::GetSpan; -use rustc_hash::FxHashMap; use crate::IsolatedDeclarations; diff --git a/crates/oxc_language_server/src/linter.rs b/crates/oxc_language_server/src/linter.rs index b0450b9bb83d3..1bcb56261d25a 100644 --- a/crates/oxc_language_server/src/linter.rs +++ b/crates/oxc_language_server/src/linter.rs @@ -8,6 +8,12 @@ use std::{ use cow_utils::CowUtils; use log::debug; +use rustc_hash::FxHashSet; +use tower_lsp::lsp_types::{ + self, CodeDescription, DiagnosticRelatedInformation, DiagnosticSeverity, NumberOrString, + Position, Range, Url, +}; + use oxc_allocator::Allocator; use oxc_data_structures::rope::{get_line_column, Rope}; use oxc_diagnostics::{Error, NamedSource, Severity}; @@ -18,11 +24,6 @@ use oxc_linter::{ use oxc_parser::{ParseOptions, Parser}; use oxc_semantic::SemanticBuilder; use oxc_span::VALID_EXTENSIONS; -use rustc_hash::FxHashSet; -use tower_lsp::lsp_types::{ - self, CodeDescription, DiagnosticRelatedInformation, DiagnosticSeverity, NumberOrString, - Position, Range, Url, -}; const LINT_DOC_LINK_PREFIX: &str = "https://oxc.rs/docs/guide/usage/linter/rules"; #[derive(Debug)] diff --git a/crates/oxc_language_server/src/main.rs b/crates/oxc_language_server/src/main.rs index 38e9aaa8d7a0c..b0d067bbbe6e1 100644 --- a/crates/oxc_language_server/src/main.rs +++ b/crates/oxc_language_server/src/main.rs @@ -1,5 +1,3 @@ -mod linter; - use std::{fmt::Debug, path::PathBuf, str::FromStr}; use dashmap::DashMap; @@ -7,7 +5,6 @@ use futures::future::join_all; use globset::Glob; use ignore::gitignore::Gitignore; use log::{debug, error, info}; -use oxc_linter::{FixKind, LinterBuilder, Oxlintrc}; use rustc_hash::FxBuildHasher; use serde::{Deserialize, Serialize}; use tokio::sync::{Mutex, OnceCell, RwLock, SetError}; @@ -26,8 +23,12 @@ use tower_lsp::{ Client, LanguageServer, LspService, Server, }; +use oxc_linter::{FixKind, LinterBuilder, Oxlintrc}; + use crate::linter::{DiagnosticReport, ServerLinter}; +mod linter; + type FxDashMap = DashMap; struct Backend { diff --git a/crates/oxc_linter/src/config/flat.rs b/crates/oxc_linter/src/config/flat.rs index 28e8bd3c8fc06..b5fcd9a2552cb 100644 --- a/crates/oxc_linter/src/config/flat.rs +++ b/crates/oxc_linter/src/config/flat.rs @@ -7,11 +7,12 @@ use std::{ use dashmap::DashMap; use rustc_hash::{FxBuildHasher, FxHashSet}; +use crate::{rules::RULES, LintPlugins, RuleWithSeverity}; + use super::{ overrides::{OverrideId, OxlintOverrides}, LintConfig, }; -use crate::{rules::RULES, LintPlugins, RuleWithSeverity}; type AppliedOverrideHash = u64; type FxDashMap = DashMap; diff --git a/crates/oxc_linter/src/config/mod.rs b/crates/oxc_linter/src/config/mod.rs index 31daa7193802e..03228e26b649a 100644 --- a/crates/oxc_linter/src/config/mod.rs +++ b/crates/oxc_linter/src/config/mod.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + mod categories; mod env; mod flat; @@ -7,20 +9,15 @@ mod oxlintrc; mod plugins; mod rules; mod settings; - -use std::path::PathBuf; - -pub(crate) use self::flat::ResolvedLinterState; -pub use self::{ - env::OxlintEnv, - flat::ConfigStore, - globals::OxlintGlobals, - overrides::OxlintOverrides, - oxlintrc::Oxlintrc, - plugins::LintPlugins, - rules::{ESLintRule, OxlintRules}, - settings::{jsdoc::JSDocPluginSettings, OxlintSettings}, -}; +pub use env::OxlintEnv; +pub use flat::ConfigStore; +pub(crate) use flat::ResolvedLinterState; +pub use globals::OxlintGlobals; +pub use overrides::OxlintOverrides; +pub use oxlintrc::Oxlintrc; +pub use plugins::LintPlugins; +pub use rules::{ESLintRule, OxlintRules}; +pub use settings::{jsdoc::JSDocPluginSettings, OxlintSettings}; #[derive(Debug, Default, Clone)] pub(crate) struct LintConfig { diff --git a/crates/oxc_linter/src/config/overrides.rs b/crates/oxc_linter/src/config/overrides.rs index 394c66bed94ed..7750d3ec115cf 100644 --- a/crates/oxc_linter/src/config/overrides.rs +++ b/crates/oxc_linter/src/config/overrides.rs @@ -1,10 +1,11 @@ use std::{borrow::Cow, ops::Deref, path::Path}; use nonmax::NonMaxU32; -use oxc_index::{Idx, IndexVec}; use schemars::{gen, schema::Schema, JsonSchema}; use serde::{de, ser, Deserialize, Serialize}; +use oxc_index::{Idx, IndexVec}; + use crate::{config::OxlintRules, LintPlugins}; #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] diff --git a/crates/oxc_linter/src/config/oxlintrc.rs b/crates/oxc_linter/src/config/oxlintrc.rs index 652360f913171..37bf6566e2414 100644 --- a/crates/oxc_linter/src/config/oxlintrc.rs +++ b/crates/oxc_linter/src/config/oxlintrc.rs @@ -1,14 +1,16 @@ use std::path::{Path, PathBuf}; -use oxc_diagnostics::OxcDiagnostic; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use oxc_diagnostics::OxcDiagnostic; + +use crate::utils::read_to_string; + use super::{ categories::OxlintCategories, env::OxlintEnv, globals::OxlintGlobals, overrides::OxlintOverrides, plugins::LintPlugins, rules::OxlintRules, settings::OxlintSettings, }; -use crate::utils::read_to_string; /// Oxlint Configuration File /// diff --git a/crates/oxc_linter/src/config/rules.rs b/crates/oxc_linter/src/config/rules.rs index bbac4fd01138e..e661f876f9fe9 100644 --- a/crates/oxc_linter/src/config/rules.rs +++ b/crates/oxc_linter/src/config/rules.rs @@ -1,6 +1,5 @@ use std::{borrow::Cow, fmt}; -use oxc_diagnostics::{Error, OxcDiagnostic}; use rustc_hash::{FxHashMap, FxHashSet}; use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema}; use serde::{ @@ -9,6 +8,8 @@ use serde::{ Deserialize, Serialize, }; +use oxc_diagnostics::{Error, OxcDiagnostic}; + use crate::{ rules::{RuleEnum, RULES}, utils::{is_eslint_rule_adapted_to_typescript, is_jest_rule_adapted_to_vitest}, @@ -344,12 +345,13 @@ mod test { use serde::Deserialize; use serde_json::{json, Value}; - use super::{OxlintRules, RuleSet}; use crate::{ rules::{RuleEnum, RULES}, AllowWarnDeny, RuleWithSeverity, }; + use super::{OxlintRules, RuleSet}; + #[test] fn test_parse_rules() { let rules = OxlintRules::deserialize(&json!({ diff --git a/crates/oxc_linter/src/context/host.rs b/crates/oxc_linter/src/context/host.rs index cb6fa2b304042..d44590447af2d 100644 --- a/crates/oxc_linter/src/context/host.rs +++ b/crates/oxc_linter/src/context/host.rs @@ -3,7 +3,6 @@ use std::{cell::RefCell, path::Path, rc::Rc, sync::Arc}; use oxc_semantic::Semantic; use oxc_span::SourceType; -use super::{plugin_name_to_prefix, LintContext}; use crate::{ config::{LintConfig, LintPlugins}, disable_directives::{DisableDirectives, DisableDirectivesBuilder}, @@ -14,6 +13,8 @@ use crate::{ utils, FrameworkFlags, RuleWithSeverity, }; +use super::{plugin_name_to_prefix, LintContext}; + /// Stores shared information about a file being linted. /// /// When linting a file, there are a number of shared resources that are diff --git a/crates/oxc_linter/src/context/mod.rs b/crates/oxc_linter/src/context/mod.rs index 3f18057fa6e2f..14c2e632a7c1c 100644 --- a/crates/oxc_linter/src/context/mod.rs +++ b/crates/oxc_linter/src/context/mod.rs @@ -1,9 +1,7 @@ #![allow(rustdoc::private_intra_doc_links)] // useful for intellisense -mod host; use std::{ops::Deref, path::Path, rc::Rc}; -pub(crate) use host::ContextHost; use oxc_cfg::ControlFlowGraph; use oxc_diagnostics::{OxcDiagnostic, Severity}; use oxc_semantic::Semantic; @@ -18,6 +16,9 @@ use crate::{ AllowWarnDeny, FrameworkFlags, ModuleRecord, OxlintEnv, OxlintGlobals, OxlintSettings, }; +mod host; +pub(crate) use host::ContextHost; + #[derive(Clone)] #[must_use] /// Contains all of the state and context specific to this lint rule. Includes information diff --git a/crates/oxc_linter/src/fixer/mod.rs b/crates/oxc_linter/src/fixer/mod.rs index 61ee49daff57e..35554af15e5e6 100644 --- a/crates/oxc_linter/src/fixer/mod.rs +++ b/crates/oxc_linter/src/fixer/mod.rs @@ -1,14 +1,14 @@ -mod fix; - use std::borrow::Cow; -pub use fix::{CompositeFix, Fix, FixKind, RuleFix}; use oxc_codegen::{CodeGenerator, CodegenOptions}; use oxc_diagnostics::OxcDiagnostic; use oxc_span::{GetSpan, Span}; use crate::LintContext; +mod fix; +pub use fix::{CompositeFix, Fix, FixKind, RuleFix}; + /// Produces [`RuleFix`] instances. Inspired by ESLint's [`RuleFixer`]. /// /// [`RuleFixer`]: https://github.com/eslint/eslint/blob/v9.9.1/lib/linter/rule-fixer.js diff --git a/crates/oxc_linter/src/loader/mod.rs b/crates/oxc_linter/src/loader/mod.rs index 07742211eb458..4da9ba51a5cd9 100644 --- a/crates/oxc_linter/src/loader/mod.rs +++ b/crates/oxc_linter/src/loader/mod.rs @@ -1,9 +1,9 @@ -mod partial_loader; -mod source; - use std::{error::Error, fmt, path::Path}; use oxc_span::SourceType; + +mod partial_loader; +mod source; pub use partial_loader::{PartialLoader, LINT_PARTIAL_LOADER_EXT}; pub use source::JavaScriptSource; diff --git a/crates/oxc_linter/src/module_record.rs b/crates/oxc_linter/src/module_record.rs index 4ad65174fc5ff..439b7c5524494 100644 --- a/crates/oxc_linter/src/module_record.rs +++ b/crates/oxc_linter/src/module_record.rs @@ -7,10 +7,11 @@ use std::{ }; use dashmap::DashMap; +use rustc_hash::{FxBuildHasher, FxHashMap}; + use oxc_semantic::Semantic; use oxc_span::{CompactStr, Span}; pub use oxc_syntax::module_record::RequestedModule; -use rustc_hash::{FxBuildHasher, FxHashMap}; type FxDashMap = DashMap; diff --git a/crates/oxc_linter/src/options/allow_warn_deny.rs b/crates/oxc_linter/src/options/allow_warn_deny.rs index 23b882ce57a44..4f8093fc577da 100644 --- a/crates/oxc_linter/src/options/allow_warn_deny.rs +++ b/crates/oxc_linter/src/options/allow_warn_deny.rs @@ -3,11 +3,12 @@ use std::{ fmt::{self, Display}, }; -use oxc_diagnostics::{OxcDiagnostic, Severity}; use schemars::{schema::SchemaObject, JsonSchema}; use serde::{de, Deserialize, Serialize}; use serde_json::{Number, Value}; +use oxc_diagnostics::{OxcDiagnostic, Severity}; + #[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize)] #[serde(rename_all = "lowercase")] pub enum AllowWarnDeny { diff --git a/crates/oxc_linter/src/options/filter.rs b/crates/oxc_linter/src/options/filter.rs index 6010c394678be..80c8fc08ddb9a 100644 --- a/crates/oxc_linter/src/options/filter.rs +++ b/crates/oxc_linter/src/options/filter.rs @@ -1,8 +1,9 @@ use std::{borrow::Cow, fmt}; -use super::AllowWarnDeny; use crate::{LintPlugins, RuleCategory}; +use super::AllowWarnDeny; + /// Enables, disables, and sets the severity of lint rules. /// /// Filters come in 3 forms: diff --git a/crates/oxc_linter/src/rules/eslint/no_duplicate_imports.rs b/crates/oxc_linter/src/rules/eslint/no_duplicate_imports.rs index 2206f5c1b6370..69a994d34520a 100644 --- a/crates/oxc_linter/src/rules/eslint/no_duplicate_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/no_duplicate_imports.rs @@ -1,7 +1,8 @@ +use rustc_hash::FxHashMap; + use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::{CompactStr, Span}; -use rustc_hash::FxHashMap; use crate::{ context::LintContext, diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs index 504bbaec70553..41ae489468c08 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs @@ -1,9 +1,10 @@ use oxc_ast::ast::*; use oxc_semantic::{Semantic, SymbolId}; -use super::{symbol::Symbol, NoUnusedVars}; use crate::ModuleRecord; +use super::{symbol::Symbol, NoUnusedVars}; + #[derive(Clone, Copy)] pub(super) struct BindingContext<'s, 'a> { pub options: &'s NoUnusedVars, diff --git a/crates/oxc_linter/src/rules/eslint/sort_keys.rs b/crates/oxc_linter/src/rules/eslint/sort_keys.rs index d60a741e12150..6ecdecb797e00 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_keys.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_keys.rs @@ -2,6 +2,7 @@ use std::{cmp::Ordering, str::Chars}; use cow_utils::CowUtils; use itertools::all; + use oxc_ast::{ast::ObjectPropertyKind, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; diff --git a/crates/oxc_linter/src/rules/import/export.rs b/crates/oxc_linter/src/rules/import/export.rs index df7d50e87b1df..96f87fb7d31ec 100644 --- a/crates/oxc_linter/src/rules/import/export.rs +++ b/crates/oxc_linter/src/rules/import/export.rs @@ -1,9 +1,10 @@ use std::path::PathBuf; +use rustc_hash::{FxHashMap, FxHashSet}; + use oxc_diagnostics::{LabeledSpan, OxcDiagnostic}; use oxc_macros::declare_oxc_lint; use oxc_span::{CompactStr, Span}; -use rustc_hash::{FxHashMap, FxHashSet}; use crate::{context::LintContext, rule::Rule, ModuleRecord}; diff --git a/crates/oxc_linter/src/rules/import/no_namespace.rs b/crates/oxc_linter/src/rules/import/no_namespace.rs index 51eb159331298..6e98a40f5b045 100644 --- a/crates/oxc_linter/src/rules/import/no_namespace.rs +++ b/crates/oxc_linter/src/rules/import/no_namespace.rs @@ -1,4 +1,5 @@ use fast_glob::glob_match; + use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::{CompactStr, Span}; diff --git a/crates/oxc_linter/src/rules/jsx_a11y/prefer_tag_over_role.rs b/crates/oxc_linter/src/rules/jsx_a11y/prefer_tag_over_role.rs index 00a7f897d9d33..f59e67329602a 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/prefer_tag_over_role.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/prefer_tag_over_role.rs @@ -1,4 +1,6 @@ use lazy_static::lazy_static; +use phf::phf_map; + use oxc_ast::{ ast::{JSXAttributeItem, JSXAttributeValue}, AstKind, @@ -6,7 +8,6 @@ use oxc_ast::{ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; -use phf::phf_map; use crate::{ context::LintContext, diff --git a/crates/oxc_linter/src/rules/oxc/no_map_spread.rs b/crates/oxc_linter/src/rules/oxc/no_map_spread.rs index 54b839e6b3d36..d30e181e66477 100644 --- a/crates/oxc_linter/src/rules/oxc/no_map_spread.rs +++ b/crates/oxc_linter/src/rules/oxc/no_map_spread.rs @@ -1,5 +1,7 @@ use std::ops::Deref; +use serde::{Deserialize, Serialize}; + use oxc_ast::{ ast::{ ArrayExpression, ArrayExpressionElement, CallExpression, Expression, ObjectExpression, @@ -11,7 +13,6 @@ use oxc_diagnostics::{LabeledSpan, OxcDiagnostic}; use oxc_macros::declare_oxc_lint; use oxc_semantic::{ReferenceId, ScopeId, SymbolId}; use oxc_span::{GetSpan, Span}; -use serde::{Deserialize, Serialize}; use crate::{ ast_util::{is_method_call, leftmost_identifier_reference}, diff --git a/crates/oxc_linter/src/rules/react/exhaustive_deps.rs b/crates/oxc_linter/src/rules/react/exhaustive_deps.rs index 08531b72a3acf..f3e19468b451f 100644 --- a/crates/oxc_linter/src/rules/react/exhaustive_deps.rs +++ b/crates/oxc_linter/src/rules/react/exhaustive_deps.rs @@ -1,6 +1,9 @@ use std::hash::Hash; use itertools::Itertools; +use phf::phf_set; +use rustc_hash::FxHashSet; + use oxc_ast::{ ast::{ Argument, ArrayExpressionElement, ArrowFunctionExpression, BindingPatternKind, @@ -15,8 +18,6 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_semantic::{ReferenceId, ScopeId, Semantic, SymbolId}; use oxc_span::{Atom, GetSpan, Span}; -use phf::phf_set; -use rustc_hash::FxHashSet; use crate::{ ast_util::{ @@ -2114,11 +2115,11 @@ fn test() { "export function useCanvasZoomOrScroll() { useEffect(() => { let wheelStopTimeoutId: { current: number | undefined } = { current: undefined }; - + wheelStopTimeoutId = requestAnimationFrameTimeout(() => { setLastInteraction?.(null); }, 300); - + return () => { if (wheelStopTimeoutId.current !== undefined) { console.log('h1'); diff --git a/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs b/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs index 7d3ec3b0fe651..c122b9206d903 100644 --- a/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs +++ b/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs @@ -1,3 +1,5 @@ +use phf::{phf_set, Set}; + use oxc_ast::{ ast::{ Argument, Expression, JSXAttributeItem, JSXAttributeValue, JSXElementName, ObjectProperty, @@ -8,7 +10,6 @@ use oxc_ast::{ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; -use phf::{phf_set, Set}; use crate::{ ast_util::is_method_call, diff --git a/crates/oxc_linter/src/rules/react/jsx_no_script_url.rs b/crates/oxc_linter/src/rules/react/jsx_no_script_url.rs index 963866ab240ff..8c724525fa94f 100644 --- a/crates/oxc_linter/src/rules/react/jsx_no_script_url.rs +++ b/crates/oxc_linter/src/rules/react/jsx_no_script_url.rs @@ -1,11 +1,12 @@ use lazy_static::lazy_static; +use regex::Regex; +use rustc_hash::FxHashMap; +use serde_json::Value; + use oxc_ast::{ast::JSXAttributeItem, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::{CompactStr, GetSpan, Span}; -use regex::Regex; -use rustc_hash::FxHashMap; -use serde_json::Value; use crate::{ context::{ContextHost, LintContext}, diff --git a/crates/oxc_linter/src/rules/typescript/no_require_imports.rs b/crates/oxc_linter/src/rules/typescript/no_require_imports.rs index 8f8b296fc7b45..733c9d28a85ef 100644 --- a/crates/oxc_linter/src/rules/typescript/no_require_imports.rs +++ b/crates/oxc_linter/src/rules/typescript/no_require_imports.rs @@ -1,3 +1,5 @@ +use regex::Regex; + use oxc_ast::{ ast::{Argument, TSModuleReference}, AstKind, @@ -6,7 +8,6 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_semantic::IsGlobalReference; use oxc_span::{CompactStr, Span}; -use regex::Regex; use crate::{context::LintContext, rule::Rule, AstNode}; diff --git a/crates/oxc_linter/src/rules/vitest/prefer_to_be_falsy.rs b/crates/oxc_linter/src/rules/vitest/prefer_to_be_falsy.rs index 4d658851a5d88..5d129057e072b 100644 --- a/crates/oxc_linter/src/rules/vitest/prefer_to_be_falsy.rs +++ b/crates/oxc_linter/src/rules/vitest/prefer_to_be_falsy.rs @@ -1,8 +1,9 @@ use oxc_macros::declare_oxc_lint; -use super::prefer_to_be_truthy::prefer_to_be_simply_bool; use crate::{context::LintContext, rule::Rule}; +use super::prefer_to_be_truthy::prefer_to_be_simply_bool; + #[derive(Debug, Default, Clone)] pub struct PreferToBeFalsy; diff --git a/crates/oxc_linter/src/service/mod.rs b/crates/oxc_linter/src/service/mod.rs index 991c5b2656872..ceb91f54f416f 100644 --- a/crates/oxc_linter/src/service/mod.rs +++ b/crates/oxc_linter/src/service/mod.rs @@ -1,17 +1,18 @@ -mod module_cache; -mod runtime; - use std::{ path::{Path, PathBuf}, sync::Arc, }; -use oxc_diagnostics::DiagnosticSender; use rayon::{iter::ParallelBridge, prelude::ParallelIterator}; use runtime::Runtime; +use oxc_diagnostics::DiagnosticSender; + use crate::Linter; +mod module_cache; +mod runtime; + pub struct LintServiceOptions { /// Current working directory cwd: Box, diff --git a/crates/oxc_linter/src/service/runtime.rs b/crates/oxc_linter/src/service/runtime.rs index 28231c73789b4..8014df9f582fc 100644 --- a/crates/oxc_linter/src/service/runtime.rs +++ b/crates/oxc_linter/src/service/runtime.rs @@ -7,19 +7,16 @@ use std::{ sync::Arc, }; +use rayon::{iter::ParallelBridge, prelude::ParallelIterator}; +use rustc_hash::FxHashSet; + use oxc_allocator::Allocator; use oxc_diagnostics::{DiagnosticSender, DiagnosticService, Error, OxcDiagnostic}; use oxc_parser::{ParseOptions, Parser}; use oxc_resolver::Resolver; use oxc_semantic::SemanticBuilder; use oxc_span::{SourceType, VALID_EXTENSIONS}; -use rayon::{iter::ParallelBridge, prelude::ParallelIterator}; -use rustc_hash::FxHashSet; -use super::{ - module_cache::{ModuleCache, ModuleState}, - LintServiceOptions, -}; use crate::{ loader::{JavaScriptSource, PartialLoader, LINT_PARTIAL_LOADER_EXT}, module_record::ModuleRecord, @@ -27,6 +24,11 @@ use crate::{ Fixer, Linter, Message, }; +use super::{ + module_cache::{ModuleCache, ModuleState}, + LintServiceOptions, +}; + pub struct Runtime { cwd: Box, /// All paths to lint diff --git a/crates/oxc_minifier/src/ast_passes/mod.rs b/crates/oxc_minifier/src/ast_passes/mod.rs index 49c5d13fe8314..4d31e84337aa5 100644 --- a/crates/oxc_minifier/src/ast_passes/mod.rs +++ b/crates/oxc_minifier/src/ast_passes/mod.rs @@ -1,3 +1,7 @@ +use oxc_allocator::Vec; +use oxc_ast::ast::*; +use oxc_traverse::{traverse_mut_with_ctx, ReusableTraverseCtx, Traverse, TraverseCtx}; + mod collapse_variable_declarations; mod exploit_assigns; mod peephole_fold_constants; @@ -10,9 +14,6 @@ mod statement_fusion; pub use collapse_variable_declarations::CollapseVariableDeclarations; pub use exploit_assigns::ExploitAssigns; -use oxc_allocator::Vec; -use oxc_ast::ast::*; -use oxc_traverse::{traverse_mut_with_ctx, ReusableTraverseCtx, Traverse, TraverseCtx}; pub use peephole_fold_constants::PeepholeFoldConstants; pub use peephole_minimize_conditions::PeepholeMinimizeConditions; pub use peephole_remove_dead_code::PeepholeRemoveDeadCode; diff --git a/crates/oxc_minifier/tests/ast_passes/dead_code_elimination.rs b/crates/oxc_minifier/tests/ast_passes/dead_code_elimination.rs index 666b1faae585b..f366e3fc60ae0 100644 --- a/crates/oxc_minifier/tests/ast_passes/dead_code_elimination.rs +++ b/crates/oxc_minifier/tests/ast_passes/dead_code_elimination.rs @@ -1,4 +1,5 @@ use cow_utils::CowUtils; + use oxc_minifier::CompressOptions; fn test(source_text: &str, expected: &str) { diff --git a/crates/oxc_napi/src/lib.rs b/crates/oxc_napi/src/lib.rs index aacf4770b12c8..db11f25eb7a5c 100644 --- a/crates/oxc_napi/src/lib.rs +++ b/crates/oxc_napi/src/lib.rs @@ -1,4 +1,5 @@ use napi_derive::napi; + use oxc_diagnostics::{LabeledSpan, OxcDiagnostic}; #[napi(object)] diff --git a/crates/oxc_parser/src/state.rs b/crates/oxc_parser/src/state.rs index 463a90232c9a3..bb8e193ce9426 100644 --- a/crates/oxc_parser/src/state.rs +++ b/crates/oxc_parser/src/state.rs @@ -1,6 +1,7 @@ -use oxc_ast::ast::{AssignmentExpression, Decorator}; use rustc_hash::{FxHashMap, FxHashSet}; +use oxc_ast::ast::{AssignmentExpression, Decorator}; + #[derive(Default)] pub struct ParserState<'a> { pub not_parenthesized_arrow: FxHashSet, diff --git a/crates/oxc_prettier/src/comments/print.rs b/crates/oxc_prettier/src/comments/print.rs index 1c6b2c2ff2ece..317f70c7d1c11 100644 --- a/crates/oxc_prettier/src/comments/print.rs +++ b/crates/oxc_prettier/src/comments/print.rs @@ -1,9 +1,10 @@ use oxc_allocator::Vec; use oxc_span::Span; -use super::{CommentFlags, DanglingCommentsPrintOptions}; use crate::{ir::Doc, Prettier}; +use super::{CommentFlags, DanglingCommentsPrintOptions}; + impl<'a> Prettier<'a> { #[must_use] pub(crate) fn print_comments( diff --git a/crates/oxc_regular_expression/src/ast_impl/visit.rs b/crates/oxc_regular_expression/src/ast_impl/visit.rs index 492618f2cbc8d..3c158278facba 100644 --- a/crates/oxc_regular_expression/src/ast_impl/visit.rs +++ b/crates/oxc_regular_expression/src/ast_impl/visit.rs @@ -2,7 +2,6 @@ // But like `oxc_ast`, this should be generated by `tasks/ast_tools` in the future. use oxc_span::{GetSpan, Span}; -use walk::{walk_pattern, *}; use crate::ast::{ Alternative, BoundaryAssertion, CapturingGroup, Character, CharacterClass, @@ -11,6 +10,8 @@ use crate::ast::{ NamedReference, Pattern, Quantifier, Term, UnicodePropertyEscape, }; +use walk::{walk_pattern, *}; + #[derive(Copy, Clone, Debug)] pub enum RegExpAstKind<'a> { Pattern(&'a Pattern<'a>), diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index a38ad3956a0b4..10fe077bb014b 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -2,6 +2,8 @@ use std::cell::{Cell, RefCell}; +use rustc_hash::FxHashMap; + use oxc_ast::{ast::*, AstKind, Visit}; use oxc_cfg::{ ControlFlowGraphBuilder, CtxCursor, CtxFlags, EdgeType, ErrorEdgeKind, InstructionKind, @@ -15,7 +17,6 @@ use oxc_syntax::{ scope::{ScopeFlags, ScopeId}, symbol::{SymbolFlags, SymbolId}, }; -use rustc_hash::FxHashMap; use crate::{ binder::Binder, diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index 8cc93760d39d8..0039d10976605 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -1,3 +1,6 @@ +use phf::{phf_set, Set}; +use rustc_hash::FxHashMap; + use oxc_ast::{ast::*, AstKind}; use oxc_diagnostics::{LabeledSpan, OxcDiagnostic}; use oxc_ecmascript::{IsSimpleParameterList, PropName}; @@ -7,8 +10,6 @@ use oxc_syntax::{ operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator}, scope::ScopeFlags, }; -use phf::{phf_set, Set}; -use rustc_hash::FxHashMap; use crate::{builder::SemanticBuilder, diagnostics::redeclaration, AstNode}; diff --git a/crates/oxc_semantic/src/checker/typescript.rs b/crates/oxc_semantic/src/checker/typescript.rs index 4ab6be5c561c2..343d18c1ac7e1 100644 --- a/crates/oxc_semantic/src/checker/typescript.rs +++ b/crates/oxc_semantic/src/checker/typescript.rs @@ -1,10 +1,11 @@ use std::borrow::Cow; +use rustc_hash::FxHashMap; + use oxc_ast::{ast::*, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_ecmascript::{BoundNames, PropName}; use oxc_span::{Atom, GetSpan, Span}; -use rustc_hash::FxHashMap; use crate::{builder::SemanticBuilder, diagnostics::redeclaration}; diff --git a/crates/oxc_semantic/src/class/builder.rs b/crates/oxc_semantic/src/class/builder.rs index 74b58111b888d..c0419d2940a40 100644 --- a/crates/oxc_semantic/src/class/builder.rs +++ b/crates/oxc_semantic/src/class/builder.rs @@ -8,11 +8,12 @@ use oxc_ast::{ use oxc_span::GetSpan; use oxc_syntax::class::{ClassId, ElementKind}; +use crate::{AstNodes, NodeId}; + use super::{ table::{Element, PrivateIdentifierReference}, ClassTable, }; -use crate::{AstNodes, NodeId}; #[derive(Debug, Default)] pub struct ClassTableBuilder { diff --git a/crates/oxc_semantic/src/class/table.rs b/crates/oxc_semantic/src/class/table.rs index e8dc80224be23..803ff7e83b07d 100644 --- a/crates/oxc_semantic/src/class/table.rs +++ b/crates/oxc_semantic/src/class/table.rs @@ -1,10 +1,11 @@ +use rustc_hash::FxHashMap; + use oxc_index::IndexVec; use oxc_span::{CompactStr, Span}; use oxc_syntax::{ class::{ClassId, ElementId, ElementKind}, node::NodeId, }; -use rustc_hash::FxHashMap; #[derive(Debug)] pub struct Element { diff --git a/crates/oxc_semantic/src/jsdoc/builder.rs b/crates/oxc_semantic/src/jsdoc/builder.rs index 10cc40c5510c5..82be8c41bb8bb 100644 --- a/crates/oxc_semantic/src/jsdoc/builder.rs +++ b/crates/oxc_semantic/src/jsdoc/builder.rs @@ -1,10 +1,12 @@ +use rustc_hash::FxHashMap; + use oxc_ast::{ast::Comment, AstKind}; use oxc_span::{GetSpan, Span}; -use rustc_hash::FxHashMap; -use super::parser::JSDoc; use crate::jsdoc::JSDocFinder; +use super::parser::JSDoc; + #[derive(Default)] pub struct JSDocBuilder<'a> { not_attached_docs: FxHashMap>>, diff --git a/crates/oxc_semantic/src/jsdoc/finder.rs b/crates/oxc_semantic/src/jsdoc/finder.rs index a871fc7715742..5fc3bee4b3dfd 100644 --- a/crates/oxc_semantic/src/jsdoc/finder.rs +++ b/crates/oxc_semantic/src/jsdoc/finder.rs @@ -1,9 +1,11 @@ -use oxc_span::{GetSpan, Span}; use rustc_hash::FxHashMap; -use super::parser::JSDoc; +use oxc_span::{GetSpan, Span}; + use crate::AstNode; +use super::parser::JSDoc; + #[derive(Debug, Default)] pub struct JSDocFinder<'a> { /// JSDocs by Span diff --git a/crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs b/crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs index 3068659abce4a..6f309d4ee756d 100644 --- a/crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs +++ b/crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs @@ -1,9 +1,10 @@ use oxc_span::Span; +use crate::jsdoc::parser::utils; + use super::jsdoc_parts::{ JSDocCommentPart, JSDocTagKindPart, JSDocTagTypeNamePart, JSDocTagTypePart, }; -use crate::jsdoc::parser::utils; // Initially, I attempted to parse into specific structures such as: // - `@param {type} name comment`: `JSDocParameterTag { type, name, comment }` diff --git a/crates/oxc_semantic/src/lib.rs b/crates/oxc_semantic/src/lib.rs index d0050f568b9a6..d7e3328f50e37 100644 --- a/crates/oxc_semantic/src/lib.rs +++ b/crates/oxc_semantic/src/lib.rs @@ -36,17 +36,15 @@ mod stats; mod symbol; mod unresolved_stack; -use class::ClassTable; +pub use builder::{SemanticBuilder, SemanticBuilderReturn}; +pub use jsdoc::{JSDoc, JSDocFinder, JSDocTag}; +pub use node::{AstNode, AstNodes}; +pub use reference::Reference; +pub use scope::ScopeTree; +pub use stats::Stats; +pub use symbol::{IsGlobalReference, SymbolTable}; -pub use crate::{ - builder::{SemanticBuilder, SemanticBuilderReturn}, - jsdoc::{JSDoc, JSDocFinder, JSDocTag}, - node::{AstNode, AstNodes}, - reference::Reference, - scope::ScopeTree, - stats::Stats, - symbol::{IsGlobalReference, SymbolTable}, -}; +use class::ClassTable; /// Semantic analysis of a JavaScript/TypeScript program. /// diff --git a/crates/oxc_semantic/src/reference.rs b/crates/oxc_semantic/src/reference.rs index e2e57ab5f0da5..81fe53c3e94ca 100644 --- a/crates/oxc_semantic/src/reference.rs +++ b/crates/oxc_semantic/src/reference.rs @@ -1,9 +1,10 @@ -use oxc_syntax::{node::NodeId, reference::ReferenceFlags, symbol::SymbolId}; #[cfg(feature = "serialize")] use serde::Serialize; #[cfg(feature = "serialize")] use tsify::Tsify; +use oxc_syntax::{node::NodeId, reference::ReferenceFlags, symbol::SymbolId}; + /// Describes where and how a Symbol is used in the AST. /// /// References indicate how they are being used using [`ReferenceFlags`]. Refer diff --git a/crates/oxc_semantic/src/scope.rs b/crates/oxc_semantic/src/scope.rs index 4bc37480c6153..5fa12b0c901db 100644 --- a/crates/oxc_semantic/src/scope.rs +++ b/crates/oxc_semantic/src/scope.rs @@ -1,6 +1,8 @@ use std::mem; use indexmap::IndexMap; +use rustc_hash::{FxBuildHasher, FxHashMap}; + use oxc_index::IndexVec; use oxc_span::CompactStr; use oxc_syntax::{ @@ -9,7 +11,6 @@ use oxc_syntax::{ scope::{ScopeFlags, ScopeId}, symbol::SymbolId, }; -use rustc_hash::{FxBuildHasher, FxHashMap}; type FxIndexMap = IndexMap; diff --git a/crates/oxc_semantic/src/symbol.rs b/crates/oxc_semantic/src/symbol.rs index 033df256296e0..98562d14c442e 100644 --- a/crates/oxc_semantic/src/symbol.rs +++ b/crates/oxc_semantic/src/symbol.rs @@ -1,5 +1,10 @@ use std::mem; +#[cfg(feature = "serialize")] +use serde::Serialize; +#[cfg(feature = "serialize")] +use tsify::Tsify; + use oxc_ast::ast::{Expression, IdentifierReference}; use oxc_index::IndexVec; use oxc_span::{CompactStr, Span}; @@ -9,10 +14,6 @@ use oxc_syntax::{ scope::ScopeId, symbol::{RedeclarationId, SymbolFlags, SymbolId}, }; -#[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] -use tsify::Tsify; use crate::reference::Reference; diff --git a/crates/oxc_semantic/src/unresolved_stack.rs b/crates/oxc_semantic/src/unresolved_stack.rs index 70f40d0bdd9c6..ebba979791c9c 100644 --- a/crates/oxc_semantic/src/unresolved_stack.rs +++ b/crates/oxc_semantic/src/unresolved_stack.rs @@ -1,7 +1,8 @@ use assert_unchecked::assert_unchecked; +use rustc_hash::FxHashMap; + use oxc_span::Atom; use oxc_syntax::reference::ReferenceId; -use rustc_hash::FxHashMap; /// The difference with Scope's `UnresolvedReferences` is that this type uses Atom as the key. its clone is very cheap! type TempUnresolvedReferences<'a> = FxHashMap, Vec>; diff --git a/crates/oxc_semantic/tests/conformance/test_symbol_declaration.rs b/crates/oxc_semantic/tests/conformance/test_symbol_declaration.rs index 307b1da10537c..1baf9819a052a 100644 --- a/crates/oxc_semantic/tests/conformance/test_symbol_declaration.rs +++ b/crates/oxc_semantic/tests/conformance/test_symbol_declaration.rs @@ -6,9 +6,10 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_span::{GetSpan, Span}; use oxc_syntax::symbol::SymbolId; -use super::{ConformanceTest, TestResult}; use crate::Semantic; +use super::{ConformanceTest, TestResult}; + /// Verifies that symbol binding relationships between the SymbolTable and AST nodes are reflexive. /// /// What does this mean? diff --git a/crates/oxc_span/src/compact_str.rs b/crates/oxc_span/src/compact_str.rs index 87dec9cc26316..10752a2b7f30f 100644 --- a/crates/oxc_span/src/compact_str.rs +++ b/crates/oxc_span/src/compact_str.rs @@ -281,9 +281,10 @@ macro_rules! format_compact_str { mod test { use compact_str::CompactString; - use super::CompactStr; use crate::format_compact_str; + use super::CompactStr; + #[test] fn test_compactstr_eq() { let foo = CompactStr::new("foo"); diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index e25636fe31684..f58acb3a80b92 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -1,14 +1,14 @@ -mod error; - use std::{hash::Hash, path::Path}; -pub use error::UnknownExtension; use oxc_allocator::{Allocator, CloneIn}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use crate::{cmp::ContentEq, hash::ContentHash}; +mod error; +pub use error::UnknownExtension; + /// Source Type for JavaScript vs TypeScript / Script vs Module / JSX #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/crates/oxc_syntax/src/module_record.rs b/crates/oxc_syntax/src/module_record.rs index ef06f49e935cf..ad72ce41a82f5 100644 --- a/crates/oxc_syntax/src/module_record.rs +++ b/crates/oxc_syntax/src/module_record.rs @@ -1,8 +1,9 @@ //! [ECMAScript Module Record](https://tc39.es/ecma262/#sec-abstract-module-records) +use rustc_hash::FxHashMap; + use oxc_allocator::{Allocator, Vec}; use oxc_span::{Atom, Span}; -use rustc_hash::FxHashMap; /// ESM Module Record /// diff --git a/crates/oxc_transformer/src/common/arrow_function_converter.rs b/crates/oxc_transformer/src/common/arrow_function_converter.rs index 9e3d9630c9ba9..ebce3c0c8dff6 100644 --- a/crates/oxc_transformer/src/common/arrow_function_converter.rs +++ b/crates/oxc_transformer/src/common/arrow_function_converter.rs @@ -89,6 +89,8 @@ use compact_str::CompactString; use indexmap::IndexMap; +use rustc_hash::{FxBuildHasher, FxHashSet}; + use oxc_allocator::{Box as ArenaBox, Vec as ArenaVec}; use oxc_ast::{ast::*, NONE}; use oxc_data_structures::stack::{NonEmptyStack, SparseStack}; @@ -99,7 +101,6 @@ use oxc_syntax::{ symbol::SymbolFlags, }; use oxc_traverse::{Ancestor, BoundIdentifier, Traverse, TraverseCtx}; -use rustc_hash::{FxBuildHasher, FxHashSet}; use crate::EnvOptions; diff --git a/crates/oxc_transformer/src/common/helper_loader.rs b/crates/oxc_transformer/src/common/helper_loader.rs index 16ecf286edf5d..2d50fb76c7f90 100644 --- a/crates/oxc_transformer/src/common/helper_loader.rs +++ b/crates/oxc_transformer/src/common/helper_loader.rs @@ -67,6 +67,9 @@ use std::{borrow::Cow, cell::RefCell}; +use rustc_hash::FxHashMap; +use serde::Deserialize; + use oxc_allocator::{String as ArenaString, Vec as ArenaVec}; use oxc_ast::{ ast::{Argument, CallExpression, Expression}, @@ -75,8 +78,6 @@ use oxc_ast::{ use oxc_semantic::{ReferenceFlags, SymbolFlags}; use oxc_span::{Atom, Span, SPAN}; use oxc_traverse::{BoundIdentifier, TraverseCtx}; -use rustc_hash::FxHashMap; -use serde::Deserialize; use crate::TransformCtx; diff --git a/crates/oxc_transformer/src/common/module_imports.rs b/crates/oxc_transformer/src/common/module_imports.rs index 51d2fbbd64bd6..76f1bbc0bee30 100644 --- a/crates/oxc_transformer/src/common/module_imports.rs +++ b/crates/oxc_transformer/src/common/module_imports.rs @@ -35,6 +35,7 @@ use std::cell::RefCell; use indexmap::{map::Entry as IndexMapEntry, IndexMap}; + use oxc_ast::{ast::*, NONE}; use oxc_semantic::ReferenceFlags; use oxc_span::{Atom, SPAN}; diff --git a/crates/oxc_transformer/src/common/statement_injector.rs b/crates/oxc_transformer/src/common/statement_injector.rs index ed4104fc79fc5..71e4eafde3132 100644 --- a/crates/oxc_transformer/src/common/statement_injector.rs +++ b/crates/oxc_transformer/src/common/statement_injector.rs @@ -14,10 +14,11 @@ use std::cell::RefCell; +use rustc_hash::FxHashMap; + use oxc_allocator::{Address, GetAddress, Vec as ArenaVec}; use oxc_ast::ast::*; use oxc_traverse::{Traverse, TraverseCtx}; -use rustc_hash::FxHashMap; use crate::TransformCtx; diff --git a/crates/oxc_transformer/src/es2015/arrow_functions.rs b/crates/oxc_transformer/src/es2015/arrow_functions.rs index a0c2816713631..a6ae357f2c2b0 100644 --- a/crates/oxc_transformer/src/es2015/arrow_functions.rs +++ b/crates/oxc_transformer/src/es2015/arrow_functions.rs @@ -125,9 +125,10 @@ //! * Babel plugin implementation: //! * Arrow function specification: -use oxc_traverse::Traverse; use serde::Deserialize; +use oxc_traverse::Traverse; + use crate::context::TransformCtx; #[derive(Debug, Default, Clone, Copy, Deserialize)] diff --git a/crates/oxc_transformer/src/es2017/mod.rs b/crates/oxc_transformer/src/es2017/mod.rs index 740102d7ea050..ef939194fff63 100644 --- a/crates/oxc_transformer/src/es2017/mod.rs +++ b/crates/oxc_transformer/src/es2017/mod.rs @@ -1,13 +1,13 @@ -mod async_to_generator; -mod options; - -pub use async_to_generator::{AsyncGeneratorExecutor, AsyncToGenerator}; -pub use options::ES2017Options; use oxc_ast::ast::{Expression, Function, Statement}; use oxc_traverse::{Traverse, TraverseCtx}; use crate::TransformCtx; +mod async_to_generator; +mod options; +pub use async_to_generator::{AsyncGeneratorExecutor, AsyncToGenerator}; +pub use options::ES2017Options; + #[allow(dead_code)] pub struct ES2017<'a, 'ctx> { options: ES2017Options, diff --git a/crates/oxc_transformer/src/es2018/mod.rs b/crates/oxc_transformer/src/es2018/mod.rs index 46e63ebec7e80..bcac19e4f04cb 100644 --- a/crates/oxc_transformer/src/es2018/mod.rs +++ b/crates/oxc_transformer/src/es2018/mod.rs @@ -1,3 +1,8 @@ +use oxc_ast::ast::*; +use oxc_traverse::{Traverse, TraverseCtx}; + +use crate::context::TransformCtx; + mod async_generator_functions; mod object_rest_spread; mod options; @@ -5,10 +10,6 @@ mod options; pub use async_generator_functions::AsyncGeneratorFunctions; pub use object_rest_spread::{ObjectRestSpread, ObjectRestSpreadOptions}; pub use options::ES2018Options; -use oxc_ast::ast::*; -use oxc_traverse::{Traverse, TraverseCtx}; - -use crate::context::TransformCtx; pub struct ES2018<'a, 'ctx> { options: ES2018Options, diff --git a/crates/oxc_transformer/src/es2018/object_rest_spread.rs b/crates/oxc_transformer/src/es2018/object_rest_spread.rs index 00aae8a41f8ca..b425ad526a630 100644 --- a/crates/oxc_transformer/src/es2018/object_rest_spread.rs +++ b/crates/oxc_transformer/src/es2018/object_rest_spread.rs @@ -29,6 +29,8 @@ use std::mem; +use serde::Deserialize; + use oxc_allocator::{CloneIn, GetAddress, Vec as ArenaVec}; use oxc_ast::{ast::*, NONE}; use oxc_diagnostics::OxcDiagnostic; @@ -36,7 +38,6 @@ use oxc_ecmascript::{BoundNames, ToJsString}; use oxc_semantic::{ScopeFlags, ScopeId, SymbolFlags}; use oxc_span::{GetSpan, SPAN}; use oxc_traverse::{Ancestor, MaybeBoundIdentifier, Traverse, TraverseCtx}; -use serde::Deserialize; use crate::{common::helper_loader::Helper, TransformCtx}; diff --git a/crates/oxc_transformer/src/es2020/mod.rs b/crates/oxc_transformer/src/es2020/mod.rs index 1648ac95fba26..e04a624a7c14a 100644 --- a/crates/oxc_transformer/src/es2020/mod.rs +++ b/crates/oxc_transformer/src/es2020/mod.rs @@ -1,15 +1,15 @@ +use oxc_ast::ast::*; +use oxc_diagnostics::OxcDiagnostic; +use oxc_traverse::{Traverse, TraverseCtx}; + +use crate::TransformCtx; + mod nullish_coalescing_operator; mod optional_chaining; mod options; - use nullish_coalescing_operator::NullishCoalescingOperator; pub use optional_chaining::OptionalChaining; pub use options::ES2020Options; -use oxc_ast::ast::*; -use oxc_diagnostics::OxcDiagnostic; -use oxc_traverse::{Traverse, TraverseCtx}; - -use crate::TransformCtx; pub struct ES2020<'a, 'ctx> { ctx: &'ctx TransformCtx<'a>, diff --git a/crates/oxc_transformer/src/es2022/class_properties/class.rs b/crates/oxc_transformer/src/es2022/class_properties/class.rs index 849f4ec8cfda5..cb851e40d3c2a 100644 --- a/crates/oxc_transformer/src/es2022/class_properties/class.rs +++ b/crates/oxc_transformer/src/es2022/class_properties/class.rs @@ -12,6 +12,8 @@ use oxc_syntax::{ }; use oxc_traverse::{BoundIdentifier, TraverseCtx}; +use crate::common::helper_loader::Helper; + use super::{ super::ClassStaticBlock, constructor::InstanceInitsInsertLocation, @@ -22,7 +24,6 @@ use super::{ }, ClassBindings, ClassProperties, FxIndexMap, }; -use crate::common::helper_loader::Helper; impl<'a, 'ctx> ClassProperties<'a, 'ctx> { /// Transform class expression. diff --git a/crates/oxc_transformer/src/es2022/class_properties/mod.rs b/crates/oxc_transformer/src/es2022/class_properties/mod.rs index 74d693eeaefb2..ca2e661afded9 100644 --- a/crates/oxc_transformer/src/es2022/class_properties/mod.rs +++ b/crates/oxc_transformer/src/es2022/class_properties/mod.rs @@ -145,13 +145,14 @@ //! * Class properties TC39 proposal: use indexmap::IndexMap; +use rustc_hash::FxBuildHasher; +use serde::Deserialize; + use oxc_allocator::{Address, GetAddress}; use oxc_ast::ast::*; use oxc_data_structures::stack::NonEmptyStack; use oxc_syntax::scope::ScopeId; use oxc_traverse::{Traverse, TraverseCtx}; -use rustc_hash::FxBuildHasher; -use serde::Deserialize; use crate::TransformCtx; diff --git a/crates/oxc_transformer/src/es2022/class_properties/private.rs b/crates/oxc_transformer/src/es2022/class_properties/private.rs index 21da7c861228a..6bab35d7bd3ea 100644 --- a/crates/oxc_transformer/src/es2022/class_properties/private.rs +++ b/crates/oxc_transformer/src/es2022/class_properties/private.rs @@ -11,6 +11,8 @@ use oxc_traverse::{ ast_operations::get_var_name_from_node, Ancestor, BoundIdentifier, TraverseCtx, }; +use crate::{common::helper_loader::Helper, TransformCtx}; + use super::{ private_props::ResolvedPrivateProp, utils::{ @@ -19,7 +21,6 @@ use super::{ }, ClassProperties, }; -use crate::{common::helper_loader::Helper, TransformCtx}; impl<'a, 'ctx> ClassProperties<'a, 'ctx> { /// Transform private field expression. diff --git a/crates/oxc_transformer/src/es2022/class_properties/supers.rs b/crates/oxc_transformer/src/es2022/class_properties/supers.rs index 0c512493a7ab1..83da00ca88c10 100644 --- a/crates/oxc_transformer/src/es2022/class_properties/supers.rs +++ b/crates/oxc_transformer/src/es2022/class_properties/supers.rs @@ -6,9 +6,10 @@ use oxc_ast::ast::*; use oxc_span::SPAN; use oxc_traverse::TraverseCtx; -use super::ClassProperties; use crate::Helper; +use super::ClassProperties; + impl<'a, 'ctx> ClassProperties<'a, 'ctx> { /// Transform static member expression where object is `super`. /// diff --git a/crates/oxc_transformer/src/es2022/class_static_block.rs b/crates/oxc_transformer/src/es2022/class_static_block.rs index e50b4dc00d7d9..d4877584a9fd8 100644 --- a/crates/oxc_transformer/src/es2022/class_static_block.rs +++ b/crates/oxc_transformer/src/es2022/class_static_block.rs @@ -40,6 +40,7 @@ //! * Class static initialization blocks TC39 proposal: use itoa::Buffer as ItoaBuffer; + use oxc_allocator::String as ArenaString; use oxc_ast::{ast::*, NONE}; use oxc_span::SPAN; diff --git a/crates/oxc_transformer/src/jsx/jsx_impl.rs b/crates/oxc_transformer/src/jsx/jsx_impl.rs index 86069e5949548..5338a9e79b744 100644 --- a/crates/oxc_transformer/src/jsx/jsx_impl.rs +++ b/crates/oxc_transformer/src/jsx/jsx_impl.rs @@ -100,16 +100,17 @@ use oxc_syntax::{ }; use oxc_traverse::{BoundIdentifier, Traverse, TraverseCtx}; +use crate::{ + es2018::{ObjectRestSpread, ObjectRestSpreadOptions}, + TransformCtx, +}; + use super::{ diagnostics, jsx_self::JsxSelf, jsx_source::JsxSource, options::{JsxOptions, JsxRuntime}, }; -use crate::{ - es2018::{ObjectRestSpread, ObjectRestSpreadOptions}, - TransformCtx, -}; pub struct JsxImpl<'a, 'ctx> { options: JsxOptions, diff --git a/crates/oxc_transformer/src/jsx/refresh.rs b/crates/oxc_transformer/src/jsx/refresh.rs index 7448e447af26b..3287cf5286f44 100644 --- a/crates/oxc_transformer/src/jsx/refresh.rs +++ b/crates/oxc_transformer/src/jsx/refresh.rs @@ -1,16 +1,18 @@ use base64::prelude::{Engine, BASE64_STANDARD}; +use rustc_hash::FxHashMap; +use sha1::{Digest, Sha1}; + use oxc_allocator::{Address, CloneIn, GetAddress, Vec as ArenaVec}; use oxc_ast::{ast::*, match_expression, AstBuilder, NONE}; use oxc_semantic::{Reference, ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags}; use oxc_span::{Atom, GetSpan, SPAN}; use oxc_syntax::operator::AssignmentOperator; use oxc_traverse::{Ancestor, BoundIdentifier, Traverse, TraverseCtx}; -use rustc_hash::FxHashMap; -use sha1::{Digest, Sha1}; -use super::options::ReactRefreshOptions; use crate::TransformCtx; +use super::options::ReactRefreshOptions; + /// Parse a string into a `RefreshIdentifierResolver` and convert it into an `Expression` #[derive(Debug)] enum RefreshIdentifierResolver<'a> { diff --git a/crates/oxc_transformer/src/options/babel/env/mod.rs b/crates/oxc_transformer/src/options/babel/env/mod.rs index 4e2e5d95e0816..cdb73fd5d7f47 100644 --- a/crates/oxc_transformer/src/options/babel/env/mod.rs +++ b/crates/oxc_transformer/src/options/babel/env/mod.rs @@ -1,10 +1,10 @@ -mod targets; - use serde::Deserialize; -pub use self::targets::BabelTargets; use crate::{options::EngineTargets, Module}; +mod targets; +pub use targets::BabelTargets; + fn default_as_true() -> bool { true } diff --git a/crates/oxc_transformer/src/options/babel/mod.rs b/crates/oxc_transformer/src/options/babel/mod.rs index c8da314e16c6a..e9a7fdaf9160f 100644 --- a/crates/oxc_transformer/src/options/babel/mod.rs +++ b/crates/oxc_transformer/src/options/babel/mod.rs @@ -1,15 +1,16 @@ -mod env; -mod plugins; -mod presets; - use std::path::{Path, PathBuf}; use serde::{de::DeserializeOwned, Deserialize}; -pub use self::env::{BabelEnvOptions, BabelModule, BabelTargets}; -pub(crate) use self::{plugins::BabelPlugins, presets::BabelPresets}; use crate::CompilerAssumptions; +mod env; +mod plugins; +mod presets; +pub use env::{BabelEnvOptions, BabelModule, BabelTargets}; +pub(crate) use plugins::BabelPlugins; +pub(crate) use presets::BabelPresets; + /// Babel options /// /// diff --git a/crates/oxc_transformer/src/options/babel/plugins.rs b/crates/oxc_transformer/src/options/babel/plugins.rs index a9eb20f801039..ffd4bffc95d48 100644 --- a/crates/oxc_transformer/src/options/babel/plugins.rs +++ b/crates/oxc_transformer/src/options/babel/plugins.rs @@ -1,11 +1,12 @@ use serde::Deserialize; -use super::PluginPresetEntries; use crate::{ es2015::ArrowFunctionsOptions, es2018::ObjectRestSpreadOptions, es2022::ClassPropertiesOptions, jsx::JsxOptions, TypeScriptOptions, }; +use super::PluginPresetEntries; + #[derive(Debug, Default, Clone, Copy, Deserialize)] pub struct SyntaxTypeScriptOptions { #[serde(default)] diff --git a/crates/oxc_transformer/src/options/babel/presets.rs b/crates/oxc_transformer/src/options/babel/presets.rs index 1dbeaa2855efd..40c4dfe24a94e 100644 --- a/crates/oxc_transformer/src/options/babel/presets.rs +++ b/crates/oxc_transformer/src/options/babel/presets.rs @@ -1,8 +1,9 @@ use serde::Deserialize; -use super::PluginPresetEntries; use crate::{EnvOptions, JsxOptions, TypeScriptOptions}; +use super::PluginPresetEntries; + #[derive(Debug, Default, Clone, Deserialize)] #[serde(try_from = "PluginPresetEntries")] pub struct BabelPresets { diff --git a/crates/oxc_transformer/src/options/env.rs b/crates/oxc_transformer/src/options/env.rs index 8e5a8a39b5f40..eee0aa4586115 100644 --- a/crates/oxc_transformer/src/options/env.rs +++ b/crates/oxc_transformer/src/options/env.rs @@ -2,7 +2,6 @@ use std::str::FromStr; use serde::Deserialize; -use super::{babel::BabelEnvOptions, ESFeature, ESTarget, Engine, Module}; use crate::{ es2015::{ArrowFunctionsOptions, ES2015Options}, es2016::ES2016Options, @@ -16,6 +15,8 @@ use crate::{ EngineTargets, }; +use super::{babel::BabelEnvOptions, ESFeature, ESTarget, Engine, Module}; + #[derive(Debug, Default, Clone, Copy, Deserialize)] #[serde(try_from = "BabelEnvOptions")] pub struct EnvOptions { diff --git a/crates/oxc_transformer/src/options/es_features.rs b/crates/oxc_transformer/src/options/es_features.rs index 7f02375edfa03..53ef6d72c9b0c 100644 --- a/crates/oxc_transformer/src/options/es_features.rs +++ b/crates/oxc_transformer/src/options/es_features.rs @@ -1,11 +1,13 @@ // Auto generated by `tasks/compat_data/src/lib.rs`. #![allow(clippy::enum_glob_use, clippy::match_same_arms)] + use std::sync::OnceLock; use browserslist::Version; use rustc_hash::FxHashMap; use super::{Engine, EngineTargets}; + #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub enum ESFeature { ES5MemberExpressionLiterals, diff --git a/crates/oxc_transformer/src/options/mod.rs b/crates/oxc_transformer/src/options/mod.rs index 41cb1e7f766f5..82a40e53e9153 100644 --- a/crates/oxc_transformer/src/options/mod.rs +++ b/crates/oxc_transformer/src/options/mod.rs @@ -1,20 +1,5 @@ -pub mod babel; - -mod browserslist_query; -mod engine; -mod engine_targets; -mod env; -mod es_features; -mod es_target; -mod module; - use std::path::PathBuf; -use self::babel::BabelOptions; -pub use self::{ - browserslist_query::BrowserslistQuery, engine::Engine, engine_targets::EngineTargets, - env::EnvOptions, es_features::ESFeature, es_target::ESTarget, module::Module, -}; use crate::{ common::helper_loader::{HelperLoaderMode, HelperLoaderOptions}, compiler_assumptions::CompilerAssumptions, @@ -32,6 +17,24 @@ use crate::{ ReactRefreshOptions, }; +pub mod babel; +mod browserslist_query; +mod engine; +mod engine_targets; +mod env; +mod es_features; +mod es_target; +mod module; + +use babel::BabelOptions; +pub use browserslist_query::BrowserslistQuery; +pub use engine::Engine; +pub use engine_targets::EngineTargets; +pub use env::EnvOptions; +pub use es_features::ESFeature; +pub use es_target::ESTarget; +pub use module::Module; + /// #[derive(Debug, Default, Clone)] pub struct TransformOptions { diff --git a/crates/oxc_transformer/src/plugins/inject_global_variables.rs b/crates/oxc_transformer/src/plugins/inject_global_variables.rs index 1fae270abb14d..7243d819d82c6 100644 --- a/crates/oxc_transformer/src/plugins/inject_global_variables.rs +++ b/crates/oxc_transformer/src/plugins/inject_global_variables.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use cow_utils::CowUtils; + use oxc_allocator::Allocator; use oxc_ast::{ast::*, AstBuilder, NONE}; use oxc_semantic::{ScopeTree, SymbolTable}; diff --git a/crates/oxc_transformer/src/typescript/annotations.rs b/crates/oxc_transformer/src/typescript/annotations.rs index 9abe3a283ab3f..d321921602d68 100644 --- a/crates/oxc_transformer/src/typescript/annotations.rs +++ b/crates/oxc_transformer/src/typescript/annotations.rs @@ -1,3 +1,5 @@ +use rustc_hash::FxHashSet; + use oxc_allocator::Vec as ArenaVec; use oxc_ast::ast::*; use oxc_diagnostics::OxcDiagnostic; @@ -10,7 +12,6 @@ use oxc_syntax::{ symbol::SymbolId, }; use oxc_traverse::{Traverse, TraverseCtx}; -use rustc_hash::FxHashSet; use crate::{TransformCtx, TypeScriptOptions}; diff --git a/crates/oxc_transformer/src/typescript/enum.rs b/crates/oxc_transformer/src/typescript/enum.rs index 3000eca41cb7f..71f24e6451f0a 100644 --- a/crates/oxc_transformer/src/typescript/enum.rs +++ b/crates/oxc_transformer/src/typescript/enum.rs @@ -1,3 +1,5 @@ +use rustc_hash::FxHashMap; + use oxc_allocator::Vec as ArenaVec; use oxc_ast::{ast::*, visit::walk_mut, VisitMut, NONE}; use oxc_ecmascript::ToInt32; @@ -9,7 +11,6 @@ use oxc_syntax::{ symbol::SymbolFlags, }; use oxc_traverse::{BoundIdentifier, Traverse, TraverseCtx}; -use rustc_hash::FxHashMap; pub struct TypeScriptEnum<'a> { enums: FxHashMap, FxHashMap, ConstantValue>>, diff --git a/crates/oxc_transformer/src/typescript/namespace.rs b/crates/oxc_transformer/src/typescript/namespace.rs index 903697319720b..581732f1007cb 100644 --- a/crates/oxc_transformer/src/typescript/namespace.rs +++ b/crates/oxc_transformer/src/typescript/namespace.rs @@ -1,3 +1,5 @@ +use rustc_hash::FxHashSet; + use oxc_allocator::{Box as ArenaBox, Vec as ArenaVec}; use oxc_ast::{ast::*, NONE}; use oxc_ecmascript::BoundNames; @@ -8,13 +10,13 @@ use oxc_syntax::{ symbol::SymbolFlags, }; use oxc_traverse::{Traverse, TraverseCtx}; -use rustc_hash::FxHashSet; + +use crate::TransformCtx; use super::{ diagnostics::{ambient_module_nested, namespace_exporting_non_const, namespace_not_supported}, TypeScriptOptions, }; -use crate::TransformCtx; pub struct TypeScriptNamespace<'a, 'ctx> { ctx: &'ctx TransformCtx<'a>, diff --git a/crates/oxc_transformer/src/typescript/rewrite_extensions.rs b/crates/oxc_transformer/src/typescript/rewrite_extensions.rs index 139f1d2b88cc1..5951e8dd36a9e 100644 --- a/crates/oxc_transformer/src/typescript/rewrite_extensions.rs +++ b/crates/oxc_transformer/src/typescript/rewrite_extensions.rs @@ -10,9 +10,10 @@ use oxc_ast::ast::{ }; use oxc_traverse::{Traverse, TraverseCtx}; -use super::options::RewriteExtensionsMode; use crate::TypeScriptOptions; +use super::options::RewriteExtensionsMode; + pub struct TypeScriptRewriteExtensions { mode: RewriteExtensionsMode, } diff --git a/crates/oxc_traverse/src/context/bound_identifier.rs b/crates/oxc_traverse/src/context/bound_identifier.rs index a5d1ed76f0bf8..793fe6603a842 100644 --- a/crates/oxc_traverse/src/context/bound_identifier.rs +++ b/crates/oxc_traverse/src/context/bound_identifier.rs @@ -8,9 +8,10 @@ use oxc_ast::{ use oxc_span::{Atom, Span, SPAN}; use oxc_syntax::{reference::ReferenceFlags, symbol::SymbolId}; -use super::MaybeBoundIdentifier; use crate::TraverseCtx; +use super::MaybeBoundIdentifier; + /// Info about a binding, from which one can create a `BindingIdentifier` or `IdentifierReference`s. /// /// Typical usage: diff --git a/crates/oxc_traverse/src/context/maybe_bound_identifier.rs b/crates/oxc_traverse/src/context/maybe_bound_identifier.rs index 9f34720ac01de..623b7ef2e1fb1 100644 --- a/crates/oxc_traverse/src/context/maybe_bound_identifier.rs +++ b/crates/oxc_traverse/src/context/maybe_bound_identifier.rs @@ -2,9 +2,10 @@ use oxc_ast::ast::{AssignmentTarget, Expression, IdentifierReference, SimpleAssi use oxc_span::{Atom, Span, SPAN}; use oxc_syntax::{reference::ReferenceFlags, symbol::SymbolId}; -use super::BoundIdentifier; use crate::TraverseCtx; +use super::BoundIdentifier; + /// A factory for generating `IdentifierReference`s. /// /// Typical usage: diff --git a/crates/oxc_traverse/src/context/scoping.rs b/crates/oxc_traverse/src/context/scoping.rs index 60c2da041924c..c90f805f8359d 100644 --- a/crates/oxc_traverse/src/context/scoping.rs +++ b/crates/oxc_traverse/src/context/scoping.rs @@ -2,6 +2,8 @@ use std::str; use compact_str::CompactString; use itoa::Buffer as ItoaBuffer; +use rustc_hash::FxHashSet; + use oxc_ast::{ast::*, visit::Visit}; use oxc_semantic::{NodeId, Reference, ScopeTree, SymbolTable}; use oxc_span::{CompactStr, SPAN}; @@ -10,7 +12,6 @@ use oxc_syntax::{ scope::{ScopeFlags, ScopeId}, symbol::{SymbolFlags, SymbolId}, }; -use rustc_hash::FxHashSet; use crate::{scopes_collector::ChildScopeCollector, BoundIdentifier}; diff --git a/crates/oxc_wasm/src/lib.rs b/crates/oxc_wasm/src/lib.rs index ed212c5358ef4..5417a514ba461 100644 --- a/crates/oxc_wasm/src/lib.rs +++ b/crates/oxc_wasm/src/lib.rs @@ -5,6 +5,10 @@ use std::{ sync::Arc, }; +use serde::Serialize; +use tsify::Tsify; +use wasm_bindgen::prelude::*; + use oxc::{ allocator::Allocator, ast::{ast::Program, Comment as OxcComment, CommentKind, Visit}, @@ -21,9 +25,6 @@ use oxc::{ use oxc_index::Idx; use oxc_linter::{Linter, ModuleRecord}; use oxc_prettier::{Prettier, PrettierOptions}; -use serde::Serialize; -use tsify::Tsify; -use wasm_bindgen::prelude::*; use crate::options::{OxcOptions, OxcRunOptions}; diff --git a/napi/minify/src/lib.rs b/napi/minify/src/lib.rs index ebaf75d03ce4f..61156f360f351 100644 --- a/napi/minify/src/lib.rs +++ b/napi/minify/src/lib.rs @@ -1,4 +1,5 @@ use napi_derive::napi; + use oxc_allocator::Allocator; use oxc_codegen::{Codegen, CodegenOptions}; use oxc_minifier::{CompressOptions, Minifier, MinifierOptions}; diff --git a/napi/parser/src/convert.rs b/napi/parser/src/convert.rs index 8d71ccfab14e1..4bfb1f5a6a032 100644 --- a/napi/parser/src/convert.rs +++ b/napi/parser/src/convert.rs @@ -1,6 +1,7 @@ -use oxc::syntax::module_record::{self, ModuleRecord}; use rustc_hash::FxHashMap; +use oxc::syntax::module_record::{self, ModuleRecord}; + use crate::types::{ EcmaScriptModule, ExportExportName, ExportExportNameKind, ExportImportName, ExportImportNameKind, ExportLocalName, ExportLocalNameKind, ImportName, ImportNameKind, Span, diff --git a/napi/parser/src/lib.rs b/napi/parser/src/lib.rs index 02f6e7ee16579..3cf9945dfb8dc 100644 --- a/napi/parser/src/lib.rs +++ b/napi/parser/src/lib.rs @@ -1,15 +1,11 @@ -#![allow( - clippy::needless_pass_by_value // Napi value need to be passed as value -)] - -mod convert; -mod magic_string; -mod types; +// Napi value need to be passed as value +#![expect(clippy::needless_pass_by_value)] use std::mem; use napi::{bindgen_prelude::AsyncTask, Task}; use napi_derive::napi; + use oxc::{ allocator::Allocator, ast::CommentKind, @@ -18,10 +14,11 @@ use oxc::{ }; use oxc_napi::OxcError; -pub use crate::{ - magic_string::MagicString, - types::{Comment, EcmaScriptModule, ParseResult, ParserOptions}, -}; +mod convert; +mod magic_string; +mod types; +pub use magic_string::MagicString; +pub use types::{Comment, EcmaScriptModule, ParseResult, ParserOptions}; fn get_source_type(filename: &str, options: &ParserOptions) -> SourceType { match options.lang.as_deref() { diff --git a/napi/parser/src/magic_string.rs b/napi/parser/src/magic_string.rs index e958a4facd789..4ff652c871fee 100644 --- a/napi/parser/src/magic_string.rs +++ b/napi/parser/src/magic_string.rs @@ -2,11 +2,12 @@ // use std::sync::Arc; use napi_derive::napi; -use oxc_data_structures::rope::{get_line_column, Rope}; -// use oxc_sourcemap::napi::SourceMap; use self_cell::self_cell; use string_wizard::MagicString as MS; +use oxc_data_structures::rope::{get_line_column, Rope}; +// use oxc_sourcemap::napi::SourceMap; + #[napi] pub struct MagicString { cell: MagicStringImpl, diff --git a/napi/parser/src/types.rs b/napi/parser/src/types.rs index 4c4b73ca923de..e4f69de5efbb6 100644 --- a/napi/parser/src/types.rs +++ b/napi/parser/src/types.rs @@ -1,6 +1,7 @@ use std::mem; use napi_derive::napi; + use oxc_napi::OxcError; use crate::magic_string::MagicString; diff --git a/napi/transform/src/isolated_declaration.rs b/napi/transform/src/isolated_declaration.rs index bdba5e28d76d1..ffbaf37263fb0 100644 --- a/napi/transform/src/isolated_declaration.rs +++ b/napi/transform/src/isolated_declaration.rs @@ -1,6 +1,7 @@ use std::path::Path; use napi_derive::napi; + use oxc::{ allocator::Allocator, codegen::{CodeGenerator, CodegenOptions}, diff --git a/napi/transform/src/transformer.rs b/napi/transform/src/transformer.rs index ba886442b1b4b..1ce05e297a6fe 100644 --- a/napi/transform/src/transformer.rs +++ b/napi/transform/src/transformer.rs @@ -8,6 +8,8 @@ use std::{ use napi::Either; use napi_derive::napi; +use rustc_hash::FxHashMap; + use oxc::{ codegen::CodegenReturn, diagnostics::OxcDiagnostic, @@ -20,7 +22,6 @@ use oxc::{ }; use oxc_napi::OxcError; use oxc_sourcemap::napi::SourceMap; -use rustc_hash::FxHashMap; use crate::IsolatedDeclarationsOptions; diff --git a/tasks/ast_tools/src/derives/clone_in.rs b/tasks/ast_tools/src/derives/clone_in.rs index a9bcfea9ac13b..48e6b20669c9b 100644 --- a/tasks/ast_tools/src/derives/clone_in.rs +++ b/tasks/ast_tools/src/derives/clone_in.rs @@ -3,12 +3,13 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::Ident; -use super::{define_derive, Derive}; use crate::{ markers::CloneInAttribute, schema::{EnumDef, GetIdent, Schema, StructDef, TypeDef}, }; +use super::{define_derive, Derive}; + pub struct DeriveCloneIn; define_derive!(DeriveCloneIn); diff --git a/tasks/ast_tools/src/derives/content_eq.rs b/tasks/ast_tools/src/derives/content_eq.rs index 483be783ae4ed..496a870403cfd 100644 --- a/tasks/ast_tools/src/derives/content_eq.rs +++ b/tasks/ast_tools/src/derives/content_eq.rs @@ -2,12 +2,13 @@ use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ schema::{EnumDef, GetGenerics, Schema, StructDef, ToType, TypeDef}, util::ToIdent, }; +use super::{define_derive, Derive}; + pub struct DeriveContentEq; define_derive!(DeriveContentEq); diff --git a/tasks/ast_tools/src/derives/content_hash.rs b/tasks/ast_tools/src/derives/content_hash.rs index dce774c1b780e..d44c1ea645690 100644 --- a/tasks/ast_tools/src/derives/content_hash.rs +++ b/tasks/ast_tools/src/derives/content_hash.rs @@ -2,12 +2,13 @@ use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ schema::{EnumDef, GetGenerics, Schema, StructDef, ToType, TypeDef}, util::ToIdent, }; +use super::{define_derive, Derive}; + pub struct DeriveContentHash; define_derive!(DeriveContentHash); diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 232b123e82927..48de37d199409 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -3,7 +3,6 @@ use proc_macro2::TokenStream; use quote::quote; use rustc_hash::FxHashMap; -use super::{define_derive, Derive}; use crate::{ markers::ESTreeStructTagMode, schema::{ @@ -12,6 +11,8 @@ use crate::{ }, }; +use super::{define_derive, Derive}; + pub struct DeriveESTree; define_derive!(DeriveESTree); diff --git a/tasks/ast_tools/src/derives/get_address.rs b/tasks/ast_tools/src/derives/get_address.rs index c1a12946008da..c3ddd6674c52b 100644 --- a/tasks/ast_tools/src/derives/get_address.rs +++ b/tasks/ast_tools/src/derives/get_address.rs @@ -1,12 +1,13 @@ use proc_macro2::TokenStream; use quote::quote; -use super::{define_derive, Derive}; use crate::{ schema::{EnumDef, Schema, ToType, TypeDef}, util::TypeWrapper, }; +use super::{define_derive, Derive}; + pub struct DeriveGetAddress; define_derive!(DeriveGetAddress); diff --git a/tasks/ast_tools/src/derives/get_span.rs b/tasks/ast_tools/src/derives/get_span.rs index 0183e7a30606a..3f9d0d206b4e4 100644 --- a/tasks/ast_tools/src/derives/get_span.rs +++ b/tasks/ast_tools/src/derives/get_span.rs @@ -2,12 +2,13 @@ use proc_macro2::TokenStream; use quote::quote; use syn::Ident; -use super::{define_derive, Derive}; use crate::{ schema::{EnumDef, GetGenerics, Schema, StructDef, ToType, TypeDef}, util::{ToIdent, TypeWrapper}, }; +use super::{define_derive, Derive}; + pub struct DeriveGetSpan; define_derive!(DeriveGetSpan); diff --git a/tasks/ast_tools/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs index 590c8f5463195..b7edfe115562d 100644 --- a/tasks/ast_tools/src/generators/assert_layouts.rs +++ b/tasks/ast_tools/src/generators/assert_layouts.rs @@ -2,7 +2,6 @@ use proc_macro2::TokenStream; use quote::quote; use syn::Type; -use super::define_generator; use crate::{ output::{output_path, Output}, schema::{FieldDef, Schema, ToType, TypeDef}, @@ -10,6 +9,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct AssertLayouts; define_generator!(AssertLayouts); diff --git a/tasks/ast_tools/src/generators/ast_builder.rs b/tasks/ast_tools/src/generators/ast_builder.rs index a63b7af8a1c65..bebe0185d2bd2 100644 --- a/tasks/ast_tools/src/generators/ast_builder.rs +++ b/tasks/ast_tools/src/generators/ast_builder.rs @@ -6,7 +6,6 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote, ToTokens}; use syn::{parse_quote, Ident, Type}; -use super::define_generator; use crate::{ output::{output_path, Output}, schema::{ @@ -16,6 +15,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub const BLACK_LIST: [&str; 1] = ["Span"]; pub struct AstBuilderGenerator; diff --git a/tasks/ast_tools/src/generators/ast_kind.rs b/tasks/ast_tools/src/generators/ast_kind.rs index f6553d239358f..154b8a393f12d 100644 --- a/tasks/ast_tools/src/generators/ast_kind.rs +++ b/tasks/ast_tools/src/generators/ast_kind.rs @@ -3,13 +3,14 @@ use itertools::Itertools; use quote::{format_ident, quote}; use syn::{parse_quote, Arm, ImplItemFn, Variant}; -use super::define_generator; use crate::{ output::{output_path, Output}, schema::{GetIdent, Schema, ToType}, Generator, }; +use super::define_generator; + pub struct AstKindGenerator; define_generator!(AstKindGenerator); diff --git a/tasks/ast_tools/src/generators/get_id.rs b/tasks/ast_tools/src/generators/get_id.rs index e478957bf60c5..e487f8c01dcbe 100644 --- a/tasks/ast_tools/src/generators/get_id.rs +++ b/tasks/ast_tools/src/generators/get_id.rs @@ -6,7 +6,6 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use super::define_generator; use crate::{ output::{output_path, Output}, schema::{Schema, TypeDef}, @@ -14,6 +13,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct GetIdGenerator; define_generator!(GetIdGenerator); diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index 4408c8dd099fd..ff4c67afd2173 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -2,7 +2,6 @@ use convert_case::{Case, Casing}; use itertools::Itertools; use rustc_hash::{FxHashMap, FxHashSet}; -use super::define_generator; use crate::{ output::Output, schema::{ @@ -12,6 +11,8 @@ use crate::{ Generator, TypeId, }; +use super::define_generator; + const CUSTOM_TYPESCRIPT: &str = include_str!("../../../../crates/oxc_ast/custom_types.d.ts"); pub struct TypescriptGenerator; diff --git a/tasks/ast_tools/src/generators/visit.rs b/tasks/ast_tools/src/generators/visit.rs index ba81ba55e91ac..97b6453557341 100644 --- a/tasks/ast_tools/src/generators/visit.rs +++ b/tasks/ast_tools/src/generators/visit.rs @@ -7,7 +7,6 @@ use quote::{format_ident, quote, ToTokens}; use rustc_hash::FxHashMap; use syn::{parse_quote, Ident}; -use super::define_generator; use crate::{ generators::ast_kind::BLACK_LIST as KIND_BLACK_LIST, markers::VisitArg, @@ -17,6 +16,8 @@ use crate::{ Generator, }; +use super::define_generator; + pub struct VisitGenerator; define_generator!(VisitGenerator); diff --git a/tasks/ast_tools/src/logger.rs b/tasks/ast_tools/src/logger.rs index ab09b008e3c04..fafb163eb3057 100644 --- a/tasks/ast_tools/src/logger.rs +++ b/tasks/ast_tools/src/logger.rs @@ -18,18 +18,21 @@ macro_rules! log { } } } +pub(crate) use log; macro_rules! log_success { () => { $crate::log!("Done!\n"); }; } +pub(crate) use log_success; macro_rules! log_failed { () => { $crate::log!("FAILED\n"); }; } +pub(crate) use log_failed; macro_rules! log_result { ($result:expr) => { @@ -43,8 +46,4 @@ macro_rules! log_result { } }; } - -pub(crate) use log; -pub(crate) use log_failed; pub(crate) use log_result; -pub(crate) use log_success; diff --git a/tasks/ast_tools/src/passes/calc_layout.rs b/tasks/ast_tools/src/passes/calc_layout.rs index 45c8ddeacf07e..d113caef693d9 100644 --- a/tasks/ast_tools/src/passes/calc_layout.rs +++ b/tasks/ast_tools/src/passes/calc_layout.rs @@ -7,7 +7,6 @@ use quote::ToTokens; use rustc_hash::FxHashMap; use syn::Type; -use super::{define_pass, Pass}; use crate::{ codegen::EarlyCtx, layout::{KnownLayout, Layout}, @@ -16,6 +15,8 @@ use crate::{ Result, }; +use super::{define_pass, Pass}; + /// We use compiler to infer 64bit type layouts. #[cfg(not(target_pointer_width = "64"))] compile_error!("This module only supports 64bit architectures."); diff --git a/tasks/ast_tools/src/passes/linker.rs b/tasks/ast_tools/src/passes/linker.rs index 0be7ad08606f2..247c52cfa1124 100644 --- a/tasks/ast_tools/src/passes/linker.rs +++ b/tasks/ast_tools/src/passes/linker.rs @@ -2,9 +2,10 @@ use std::borrow::Cow; use syn::parse_quote; -use super::{define_pass, AstType, Pass, Result}; use crate::{codegen::EarlyCtx, rust_ast::Inherit, util::NormalizeError}; +use super::{define_pass, AstType, Pass, Result}; + pub trait Unresolved { fn unresolved(&self) -> bool; diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 1eed746c92f22..433d5f05be2f0 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -1,7 +1,6 @@ use serde::Serialize; use syn::Ident; -use super::TypeName; use crate::{ markers::{ DeriveAttributes, ESTreeEnumAttribute, ESTreeStructAttribute, ScopeAttribute, ScopeMarkers, @@ -11,6 +10,8 @@ use crate::{ TypeId, }; +use super::TypeName; + #[derive(Debug, Serialize)] #[serde(untagged)] #[expect(clippy::large_enum_variant)] diff --git a/tasks/ast_tools/src/schema/get_ident.rs b/tasks/ast_tools/src/schema/get_ident.rs index 03fb62e964f95..1f1f5f8769085 100644 --- a/tasks/ast_tools/src/schema/get_ident.rs +++ b/tasks/ast_tools/src/schema/get_ident.rs @@ -1,8 +1,9 @@ use syn::Ident; -use super::defs::{EnumDef, StructDef, TypeDef}; use crate::util::ToIdent; +use super::defs::{EnumDef, StructDef, TypeDef}; + pub trait GetIdent { fn ident(&self) -> Ident; } diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs index 517c41d0be4ee..8f83219c0207c 100644 --- a/tasks/ast_tools/src/schema/serialize.rs +++ b/tasks/ast_tools/src/schema/serialize.rs @@ -1,9 +1,10 @@ use convert_case::{Case, Casing}; use rustc_hash::FxHashSet; -use super::{EnumDef, StructDef, TypeDef, VariantDef}; use crate::{markers::ESTreeStructTagMode, schema::GetIdent, Schema, TypeId}; +use super::{EnumDef, StructDef, TypeDef, VariantDef}; + pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String { match var.markers.derive_attributes.estree.rename.as_ref() { Some(rename) => rename.to_string(), diff --git a/tasks/compat_data/src/lib.rs b/tasks/compat_data/src/lib.rs index 7a24cde2e4769..c82550cb57f3d 100644 --- a/tasks/compat_data/src/lib.rs +++ b/tasks/compat_data/src/lib.rs @@ -1,11 +1,12 @@ use std::{fs, str::FromStr}; -use oxc_tasks_common::project_root; -use oxc_transformer::EngineTargets; use quote::quote; use serde::Deserialize; use syn::Ident; +use oxc_tasks_common::project_root; +use oxc_transformer::EngineTargets; + #[derive(Debug, Deserialize)] struct Item { name: String, @@ -52,9 +53,10 @@ pub fn generate() { let code = quote! { #![allow(clippy::enum_glob_use, clippy::match_same_arms)] + use std::sync::OnceLock; + use browserslist::Version; use rustc_hash::FxHashMap; - use std::sync::OnceLock; use super::{Engine, EngineTargets}; diff --git a/tasks/coverage/src/driver.rs b/tasks/coverage/src/driver.rs index 17bc9857b1ed0..bec0b0bbfa511 100644 --- a/tasks/coverage/src/driver.rs +++ b/tasks/coverage/src/driver.rs @@ -1,5 +1,7 @@ use std::{ops::ControlFlow, path::PathBuf}; +use rustc_hash::FxHashSet; + use oxc::{ allocator::Allocator, ast::{ast::Program, Comment}, @@ -14,7 +16,6 @@ use oxc::{ CompilerInterface, }; use oxc_tasks_transform_checker::{check_semantic_after_transform, check_semantic_ids}; -use rustc_hash::FxHashSet; use crate::suite::TestResult; diff --git a/tasks/coverage/src/runtime/mod.rs b/tasks/coverage/src/runtime/mod.rs index b4976b3c86a70..efa10670fbc1e 100644 --- a/tasks/coverage/src/runtime/mod.rs +++ b/tasks/coverage/src/runtime/mod.rs @@ -1,10 +1,10 @@ -mod test262_status; - use std::{ path::{Path, PathBuf}, time::Duration, }; +use serde_json::json; + use oxc::{ allocator::Allocator, codegen::{CodeGenerator, CodegenOptions}, @@ -15,8 +15,6 @@ use oxc::{ transformer::{HelperLoaderMode, TransformOptions, Transformer}, }; use oxc_tasks_common::agent; -use serde_json::json; -use test262_status::get_v8_test262_failure_paths; use crate::{ suite::{Case, TestResult}, @@ -24,6 +22,9 @@ use crate::{ workspace_root, }; +mod test262_status; +use test262_status::get_v8_test262_failure_paths; + static SKIP_FEATURES: &[&str] = &[ // Node's version of V8 doesn't implement these "hashbang", diff --git a/tasks/coverage/src/typescript/meta.rs b/tasks/coverage/src/typescript/meta.rs index d43b1d8d92d74..368b2ef6edf55 100644 --- a/tasks/coverage/src/typescript/meta.rs +++ b/tasks/coverage/src/typescript/meta.rs @@ -2,6 +2,9 @@ use std::{fs, path::Path, sync::Arc}; +use regex::Regex; +use rustc_hash::FxHashMap; + use oxc::{ allocator::Allocator, codegen::CodeGenerator, @@ -9,8 +12,6 @@ use oxc::{ parser::Parser, span::SourceType, }; -use regex::Regex; -use rustc_hash::FxHashMap; use crate::workspace_root; diff --git a/tasks/transform_checker/src/lib.rs b/tasks/transform_checker/src/lib.rs index 368f2c814eb52..9b7c5aef92684 100644 --- a/tasks/transform_checker/src/lib.rs +++ b/tasks/transform_checker/src/lib.rs @@ -92,6 +92,8 @@ use std::{ }; use indexmap::IndexMap; +use rustc_hash::FxBuildHasher; + use oxc_allocator::{Allocator, CloneIn}; use oxc_ast::{ast::*, visit::walk, Visit}; use oxc_diagnostics::OxcDiagnostic; @@ -102,7 +104,6 @@ use oxc_syntax::{ scope::{ScopeFlags, ScopeId}, symbol::SymbolId, }; -use rustc_hash::FxBuildHasher; type FxIndexMap = IndexMap; diff --git a/tasks/transform_conformance/src/test_case.rs b/tasks/transform_conformance/src/test_case.rs index 0494cdeb1877e..7ca647d79fab4 100644 --- a/tasks/transform_conformance/src/test_case.rs +++ b/tasks/transform_conformance/src/test_case.rs @@ -4,6 +4,7 @@ use std::{ }; use cow_utils::CowUtils; + use oxc::{ allocator::Allocator, codegen::{CodeGenerator, CodegenOptions},