From 2839333086a1a8d63b2602fe3cfd6665c791338b Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Thu, 16 Mar 2023 17:39:23 +0000 Subject: [PATCH] refactor(create): fix all eslint warnings in the plugin Was annoying me how many there were in this file in particular. --- core/create/src/prompts/options.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/create/src/prompts/options.ts b/core/create/src/prompts/options.ts index d54564c4a..55334c0e3 100644 --- a/core/create/src/prompts/options.ts +++ b/core/create/src/prompts/options.ts @@ -12,7 +12,7 @@ import { z } from 'zod' interface OptionSettings { name: string type: z.ZodTypeAny - default?: any + default?: unknown } async function optionsPromptForPlugin( @@ -118,10 +118,12 @@ async function optionsPromptForPlugin( { name: 'option', type: 'multiselect', - choices: (elementType as z.ZodEnum).options.map((choice: string) => ({ - title: choice, - value: choice - })), + choices: (elementType as z.ZodEnum<[string, ...string[]]>).options.map( + (choice: string) => ({ + title: choice, + value: choice + }) + ), message: `Select options for '${styles.option(optionName)}'` + defaultSuffix }, { onCancel } @@ -137,7 +139,7 @@ async function optionsPromptForPlugin( { name: 'option', type: 'select', - choices: (optionType as z.ZodEnum).options.map((choice: string) => ({ + choices: (optionType as z.ZodEnum<[string, ...string[]]>).options.map((choice: string) => ({ title: choice, value: choice })), @@ -223,6 +225,9 @@ export default async ({ logger, config, toolKitConfig, configPath }: OptionsPara } if (!cancelled && generators) { for (const [optionName, generator] of Object.entries(generators)) { + // the object is partial because not all options for a plugin will + // have generators, but all values in the record will be defined + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion toolKitConfig.options[plugin][optionName] = await generator!( winstonLogger.child({ plugin }), prompt,