@@ -161,6 +161,26 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
161
161
groups : [ ] ,
162
162
} )
163
163
164
+ let hasUnknownGroup = false
165
+
166
+ for ( let group of options . groups ) {
167
+ if ( Array . isArray ( group ) ) {
168
+ for ( let subGroup of group ) {
169
+ if ( subGroup === 'unknown' ) {
170
+ hasUnknownGroup = true
171
+ }
172
+ }
173
+ } else {
174
+ if ( group === 'unknown' ) {
175
+ hasUnknownGroup = true
176
+ }
177
+ }
178
+ }
179
+
180
+ if ( ! hasUnknownGroup ) {
181
+ options . groups = [ ...options . groups , 'unknown' ]
182
+ }
183
+
164
184
let source = context . getSourceCode ( )
165
185
166
186
let nodes : SortingNode [ ] = [ ]
@@ -218,6 +238,9 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
218
238
)
219
239
}
220
240
241
+ let isExternal = ( value : string ) =>
242
+ ! ( value . startsWith ( '.' ) || value . startsWith ( '/' ) )
243
+
221
244
if ( node . importKind === 'type' ) {
222
245
if ( node . type === 'ImportDeclaration' ) {
223
246
setCustomGroups ( options [ 'custom-groups' ] . type , node . source . value )
@@ -241,9 +264,12 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
241
264
if ( isCoreModule ( node . source . value ) ) {
242
265
defineGroup ( 'builtin-type' )
243
266
}
267
+
268
+ if ( isExternal ( node . source . value ) ) {
269
+ defineGroup ( 'external-type' )
270
+ }
244
271
}
245
272
246
- defineGroup ( 'external-type' )
247
273
defineGroup ( 'type' )
248
274
}
249
275
@@ -278,7 +304,9 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
278
304
defineGroup ( 'builtin' )
279
305
}
280
306
281
- defineGroup ( 'external' )
307
+ if ( isExternal ( node . source . value ) ) {
308
+ defineGroup ( 'external' )
309
+ }
282
310
}
283
311
284
312
return getGroup ( )
0 commit comments