@@ -253,6 +253,7 @@ function makeOutOfOrderReport(context, imported) {
253
253
if ( ! outOfOrder . length ) {
254
254
return ;
255
255
}
256
+
256
257
// There are things to report. Try to minimize the number of reported errors.
257
258
const reversedImported = reverse ( imported ) ;
258
259
const reversedOrder = findOutOfOrder ( reversedImported ) ;
@@ -426,11 +427,12 @@ const types = ['builtin', 'external', 'internal', 'unknown', 'parent', 'sibling'
426
427
// Example: { index: 0, sibling: 1, parent: 1, external: 1, builtin: 2, internal: 2 }
427
428
// Will throw an error if it contains a type that does not exist, or has a duplicate
428
429
function convertGroupsToRanks ( groups ) {
430
+ if ( groups . length === 1 ) {
431
+ // TODO: remove this `if` and fix the bug
432
+ return convertGroupsToRanks ( groups [ 0 ] ) ;
433
+ }
429
434
const rankObject = groups . reduce ( function ( res , group , index ) {
430
- if ( typeof group === 'string' ) {
431
- group = [ group ] ;
432
- }
433
- group . forEach ( function ( groupItem ) {
435
+ [ ] . concat ( group ) . forEach ( function ( groupItem ) {
434
436
if ( types . indexOf ( groupItem ) === - 1 ) {
435
437
throw new Error ( `Incorrect configuration of the rule: Unknown type \`${ JSON . stringify ( groupItem ) } \`` ) ;
436
438
}
@@ -443,7 +445,7 @@ function convertGroupsToRanks(groups) {
443
445
} , { } ) ;
444
446
445
447
const omittedTypes = types . filter ( function ( type ) {
446
- return rankObject [ type ] === undefined ;
448
+ return typeof rankObject [ type ] === ' undefined' ;
447
449
} ) ;
448
450
449
451
const ranks = omittedTypes . reduce ( function ( res , type ) {
0 commit comments