@@ -6,9 +6,9 @@ use serde_json::Value;
66
77use oxc_formatter:: {
88 ArrowParentheses , AttributePosition , BracketSameLine , BracketSpacing , CustomGroupDefinition ,
9- EmbeddedLanguageFormatting , Expand , FormatOptions , IndentStyle , IndentWidth , LineEnding ,
10- LineWidth , QuoteProperties , QuoteStyle , Semicolons , SortImportsOptions , SortOrder ,
11- TailwindcssOptions , TrailingCommas ,
9+ EmbeddedLanguageFormatting , Expand , FormatOptions , ImportModifier , ImportSelector , IndentStyle ,
10+ IndentWidth , LineEnding , LineWidth , QuoteProperties , QuoteStyle , Semicolons ,
11+ SortImportsOptions , SortOrder , TailwindcssOptions , TrailingCommas ,
1212} ;
1313use oxc_toml:: Options as TomlFormatterOptions ;
1414
@@ -428,6 +428,13 @@ impl FormatConfig {
428428 . map ( |c| CustomGroupDefinition {
429429 group_name : c. group_name ,
430430 element_name_pattern : c. element_name_pattern ,
431+ selector : c. selector . as_deref ( ) . and_then ( ImportSelector :: parse) ,
432+ modifiers : c
433+ . modifiers
434+ . unwrap_or_default ( )
435+ . iter ( )
436+ . filter_map ( |s| ImportModifier :: parse ( s) )
437+ . collect ( ) ,
431438 } )
432439 . collect ( ) ;
433440 }
@@ -650,10 +657,6 @@ pub struct SortImportsConfig {
650657 /// - `default` — Imports containing the default specifier.
651658 /// - `wildcard` — Imports containing the wildcard (`* as`) specifier.
652659 /// - `named` — Imports containing at least one named specifier.
653- /// - `multiline` — Imports on multiple lines.
654- /// - `singleline` — Imports on a single line.
655- ///
656- /// See also <https://perfectionist.dev/rules/sort-imports#groups> for details.
657660 ///
658661 /// - Default: See below
659662 /// ```json
@@ -677,6 +680,9 @@ pub struct SortImportsConfig {
677680 /// If you want a predefined group to take precedence over a custom group,
678681 /// you must write a custom group definition that does the same as what the predefined group does, and put it first in the list.
679682 ///
683+ /// If you specify multiple conditions like `elementNamePattern`, `selector`, and `modifiers`,
684+ /// all conditions must be met for an import to match the custom group (AND logic).
685+ ///
680686 /// - Default: `[]`
681687 #[ serde( skip_serializing_if = "Option::is_none" ) ]
682688 pub custom_groups : Option < Vec < CustomGroupItemConfig > > ,
@@ -712,6 +718,18 @@ pub struct CustomGroupItemConfig {
712718 pub group_name : String ,
713719 /// List of glob patterns to match import sources for this group.
714720 pub element_name_pattern : Vec < String > ,
721+ /// Selector to match the import kind.
722+ ///
723+ /// Possible values: `"type"`, `"side-effect-style"`, `"side-effect"`, `"style"`, `"index"`,
724+ /// `"sibling"`, `"parent"`, `"subpath"`, `"internal"`, `"builtin"`, `"external"`, `"import"`
725+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
726+ pub selector : Option < String > ,
727+ /// Modifiers to match the import characteristics.
728+ /// All specified modifiers must be present (AND logic).
729+ ///
730+ /// Possible values: `"side-effect"`, `"type"`, `"value"`, `"default"`, `"wildcard"`, `"named"`
731+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
732+ pub modifiers : Option < Vec < String > > ,
715733}
716734
717735// ---
0 commit comments