export interface Options { readonly [ key ] : boolean | string ; } export interface MutableOptions { [ key ] : boolean | string ; } /**
 * Converts ruleArguments in format
 * ["foo-bar", {do-it: "foo"}, "do-not-do-it"]
 * to options in format
 * {fooBar: true, doIt: "foo", doNotDoIt: true}
 */ export function parseOptions < TOptions > ( ruleArguments ) { let options = { } ; for ( const o of ruleArguments ) { if ( typeof o === "string" ) { options [ camelize ( o ) ] = true ; } else if ( typeof o === "object" ) { const o2 = { } ; for ( const key of Object . keys ( o ) ) { o2 [ camelize ( key ) ] = o [ key ] ; } options = { ... options , ... o2 } ; } } return options as any ; } function upFirst ( word ) { return word [ 0 ] . toUpperCase ( ) + word . toLowerCase ( ) . slice ( 1 ) ; } function camelize ( text ) { let words = text . split ( /[-_]/g ) ; return ( words [ 0 ] . toLowerCase ( ) + words . slice ( 1 ) . map ( upFirst ) . join ( "" ) ) ; }