@@ -75,7 +75,10 @@ function limitOptions<TOption>(params: LimitOptionsParams<TOption>): string[] {
75
75
let slidingWindowLocation = 0 ;
76
76
77
77
if ( cursor >= slidingWindowLocation + maxItems - 3 ) {
78
- slidingWindowLocation = Math . max ( Math . min ( cursor - maxItems + 3 , options . length - maxItems ) , 0 ) ;
78
+ slidingWindowLocation = Math . max (
79
+ Math . min ( cursor - maxItems + 3 , options . length - maxItems ) ,
80
+ 0
81
+ ) ;
79
82
} else if ( cursor < slidingWindowLocation + 2 ) {
80
83
slidingWindowLocation = Math . max ( cursor - 2 , 0 ) ;
81
84
}
@@ -219,7 +222,10 @@ export type SelectOptions<Value> = {
219
222
} ;
220
223
221
224
export function select < Value > ( opts : SelectOptions < Value > ) {
222
- const opt = ( option : Option < Value > , state : "inactive" | "active" | "selected" | "cancelled" ) => {
225
+ const opt = (
226
+ option : Option < Value > ,
227
+ state : "inactive" | "active" | "selected" | "cancelled"
228
+ ) => {
223
229
const label = option . label ?? String ( option . value ) ;
224
230
switch ( state ) {
225
231
case "selected" :
@@ -436,8 +442,10 @@ export function groupMultiselect<Value>(opts: GroupMultiSelectOptions<Value>) {
436
442
options : Option < Value > [ ] = [ ]
437
443
) => {
438
444
const label = option . label ?? String ( option . value ) ;
445
+ // eslint-disable-next-line ts/no-explicit-any
439
446
const isItem = typeof ( option as any ) . group === "string" ;
440
447
const next = isItem && ( options [ options . indexOf ( option ) + 1 ] ?? { group : true } ) ;
448
+ // eslint-disable-next-line ts/no-explicit-any
441
449
const isLast = isItem && ( next as any ) . group === true ;
442
450
const prefix = isItem ? `${ isLast ? S_BAR_END : S_BAR } ` : "" ;
443
451
@@ -515,7 +523,11 @@ export function groupMultiselect<Value>(opts: GroupMultiSelectOptions<Value>) {
515
523
typeof option . group === "string" &&
516
524
this . options [ this . cursor ] ! . value === option . group ;
517
525
if ( groupActive ) {
518
- return opt ( option , selected ? "group-active-selected" : "group-active" , options ) ;
526
+ return opt (
527
+ option ,
528
+ selected ? "group-active-selected" : "group-active" ,
529
+ options
530
+ ) ;
519
531
}
520
532
if ( active && selected ) {
521
533
return opt ( option , "active-selected" , options ) ;
@@ -539,7 +551,11 @@ export function groupMultiselect<Value>(opts: GroupMultiSelectOptions<Value>) {
539
551
typeof option . group === "string" &&
540
552
this . options [ this . cursor ] ! . value === option . group ;
541
553
if ( groupActive ) {
542
- return opt ( option , selected ? "group-active-selected" : "group-active" , options ) ;
554
+ return opt (
555
+ option ,
556
+ selected ? "group-active-selected" : "group-active" ,
557
+ options
558
+ ) ;
543
559
}
544
560
if ( active && selected ) {
545
561
return opt ( option , "active-selected" , options ) ;
@@ -603,7 +619,10 @@ export const log = {
603
619
const parts = [ `${ color . gray ( S_BAR ) } ` ] ;
604
620
if ( message ) {
605
621
const [ firstLine , ...lines ] = message . split ( "\n" ) ;
606
- parts . push ( `${ symbol } ${ firstLine } ` , ...lines . map ( ( ln ) => `${ color . gray ( S_BAR ) } ${ ln } ` ) ) ;
622
+ parts . push (
623
+ `${ symbol } ${ firstLine } ` ,
624
+ ...lines . map ( ( ln ) => `${ color . gray ( S_BAR ) } ${ ln } ` )
625
+ ) ;
607
626
}
608
627
process . stdout . write ( `${ parts . join ( "\n" ) } \n` ) ;
609
628
} ,
@@ -714,6 +733,7 @@ export function spinner() {
714
733
// Adapted from https://github.com/chalk/ansi-regex
715
734
// @see LICENSE
716
735
function ansiRegex ( ) {
736
+ // eslint-disable-next-line regexp/no-useless-non-capturing-group, regexp/no-trivially-nested-quantifier, regexp/no-useless-quantifier, regexp/prefer-w, regexp/no-useless-escape
717
737
const pattern = [
718
738
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)" ,
719
739
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))" ,
@@ -736,7 +756,6 @@ export type PromptGroupOptions<T> = {
736
756
737
757
type Prettify < T > = {
738
758
[ P in keyof T ] : T [ P ] ;
739
- // eslint-disable-next-line ts/ban-types
740
759
} & { } ;
741
760
742
761
export type PromptGroup < T > = {
@@ -753,6 +772,7 @@ export async function group<T>(
753
772
prompts : PromptGroup < T > ,
754
773
opts ?: PromptGroupOptions < T >
755
774
) : Promise < Prettify < PromptGroupAwaitedReturn < T > > > {
775
+ // eslint-disable-next-line ts/no-explicit-any
756
776
const results = { } as any ;
757
777
const promptNames = Object . keys ( prompts ) ;
758
778
0 commit comments