From 7e024fa88fbb5c8f0584a3cba00e8a7b916e47cb Mon Sep 17 00:00:00 2001 From: Maiko Tan Date: Wed, 24 Jul 2024 14:03:32 +0800 Subject: [PATCH 1/3] chore: several lint error fix --- resources/regexes.ts | 2 +- ui/config/config.ts | 2 ++ ui/pullcounter/pullcounter.ts | 2 ++ ui/raidboss/popup-text.ts | 2 ++ ui/raidboss/raidboss_config.ts | 6 ++++-- util/logtools/generate_triggers.ts | 8 ++++++-- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/resources/regexes.ts b/resources/regexes.ts index 711f05a31c8..5c5012c73c1 100644 --- a/resources/regexes.ts +++ b/resources/regexes.ts @@ -321,7 +321,7 @@ const parseHelper = ( defaultFieldValue, ); } else { - str += fieldValue; + str += fieldValue?.toString(); } } diff --git a/ui/config/config.ts b/ui/config/config.ts index ea3b898adab..d25f10317a3 100644 --- a/ui/config/config.ts +++ b/ui/config/config.ts @@ -433,6 +433,8 @@ export class CactbotConfigurator { const args = Array.isArray(path) ? path : [path]; const info = JSON.stringify([group, ...args].join(', ')); console.error( + // FIXME: + // eslint-disable-next-line @typescript-eslint/no-base-to-string `Unexpected type: ${info}, ${objOrValue.toString()}, ${typeof objOrValue}, ${typeof defaultValue}`, ); return defaultValue; diff --git a/ui/pullcounter/pullcounter.ts b/ui/pullcounter/pullcounter.ts index 67c6d33f471..6121a95cccc 100644 --- a/ui/pullcounter/pullcounter.ts +++ b/ui/pullcounter/pullcounter.ts @@ -402,6 +402,8 @@ class PullCounter { try { if (typeof e.data !== 'string') + // FIXME: + // eslint-disable-next-line @typescript-eslint/no-base-to-string throw new Error(e.data.toString()); const parsed: unknown = JSON.parse(e.data); diff --git a/ui/raidboss/popup-text.ts b/ui/raidboss/popup-text.ts index faa8dec698b..6a40ffe0497 100644 --- a/ui/raidboss/popup-text.ts +++ b/ui/raidboss/popup-text.ts @@ -1482,6 +1482,8 @@ export class PopupText { if (result !== undefined) { // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (result) + // FIXME: + // eslint-disable-next-line @typescript-eslint/no-base-to-string triggerHelper.ttsText = result?.toString(); } else { triggerHelper.ttsText = triggerHelper.defaultTTSText; diff --git a/ui/raidboss/raidboss_config.ts b/ui/raidboss/raidboss_config.ts index 63df805b7f4..1e3c7262545 100644 --- a/ui/raidboss/raidboss_config.ts +++ b/ui/raidboss/raidboss_config.ts @@ -527,7 +527,7 @@ const setOptionsFromOutputValue = ( options.SoundAlertsEnabled = false; options.SpokenAlertsEnabled = false; } else { - console.error(`unknown output type: ${value.toString()}`); + console.error(`unknown output type: ${JSON.stringify(value)}`); } }; @@ -762,6 +762,7 @@ class RaidbossConfigurator { detailText = this.base.translate(kMiscTranslations.valueIsFunction); detailCls.push('function-text'); } else { + // eslint-disable-next-line @typescript-eslint/no-base-to-string detailText = trigFunc.toString(); } @@ -1345,7 +1346,8 @@ class RaidbossConfigurator { if (result === null || result === undefined) return false; - // Super hack: + // FIXME: Super hack: + // eslint-disable-next-line @typescript-eslint/no-base-to-string const resultStr = result.toString(); if (resultStr.includes('undefined') || resultStr.includes('NaN')) return false; diff --git a/util/logtools/generate_triggers.ts b/util/logtools/generate_triggers.ts index 093de51125a..3a1ec937361 100644 --- a/util/logtools/generate_triggers.ts +++ b/util/logtools/generate_triggers.ts @@ -108,7 +108,11 @@ type XIVAPINpcYellResponse = { // These return types are identical type XIVAPIBattleTalk2Response = XIVAPINpcYellResponse; -type TriggerSuggestTypes = typeof triggerSuggestOptions[number]; +type TriggerSuggestTypes = + | typeof triggerSuggestOptions[number] + | `AoE (circle, range = ${number})` + | `Rectangle AoE, CastType = ${number}` + | 'Plus AoE'; type GenerateTriggersArgs = { 'files': string[] | null; @@ -1248,7 +1252,7 @@ const generateTriggersTextFromTriggerInfo = async ( // TODO: More default suggestions. Figure out how things work for square (CastType=12) // vs left/right/etc positioning const castTypeSuggestions = new Set(); - const castTypeFullSuggestions = new Set(); + const castTypeFullSuggestions = new Set(); if (xivapiAbilityInfo !== undefined) { const xivApiAbilities = mapInfo.fights .flatMap((fight) => fight.instances.filter((instance) => instance.groups?.type === '20')) From 74ba36b19e266b08421a6e0c00d356706f35f8e1 Mon Sep 17 00:00:00 2001 From: Maiko Tan Date: Fri, 26 Jul 2024 09:33:08 +0800 Subject: [PATCH 2/3] better type for castTypeFullSuggestions --- util/logtools/generate_triggers.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/logtools/generate_triggers.ts b/util/logtools/generate_triggers.ts index 3a1ec937361..f78c4401694 100644 --- a/util/logtools/generate_triggers.ts +++ b/util/logtools/generate_triggers.ts @@ -108,8 +108,9 @@ type XIVAPINpcYellResponse = { // These return types are identical type XIVAPIBattleTalk2Response = XIVAPINpcYellResponse; -type TriggerSuggestTypes = - | typeof triggerSuggestOptions[number] +type TriggerSuggestTypes = typeof triggerSuggestOptions[number]; +type TriggerSuggestTypesFull = + | TriggerSuggestTypes | `AoE (circle, range = ${number})` | `Rectangle AoE, CastType = ${number}` | 'Plus AoE'; @@ -1252,7 +1253,7 @@ const generateTriggersTextFromTriggerInfo = async ( // TODO: More default suggestions. Figure out how things work for square (CastType=12) // vs left/right/etc positioning const castTypeSuggestions = new Set(); - const castTypeFullSuggestions = new Set(); + const castTypeFullSuggestions = new Set(); if (xivapiAbilityInfo !== undefined) { const xivApiAbilities = mapInfo.fights .flatMap((fight) => fight.instances.filter((instance) => instance.groups?.type === '20')) From 6bb96828963a5dab0ad673fdd1625bf0008beaf9 Mon Sep 17 00:00:00 2001 From: Maiko Tan Date: Fri, 26 Jul 2024 13:16:47 +0800 Subject: [PATCH 3/3] revert and leave fixme comment --- resources/regexes.ts | 5 ++++- ui/raidboss/raidboss_config.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/regexes.ts b/resources/regexes.ts index 5c5012c73c1..588c8c3264a 100644 --- a/resources/regexes.ts +++ b/resources/regexes.ts @@ -321,7 +321,10 @@ const parseHelper = ( defaultFieldValue, ); } else { - str += fieldValue?.toString(); + // FIXME: handle lint error here + // ref: https://github.com/OverlayPlugin/cactbot/pull/274#discussion_r1692439720 + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands + str += fieldValue; } } diff --git a/ui/raidboss/raidboss_config.ts b/ui/raidboss/raidboss_config.ts index 1e3c7262545..a3d69988b39 100644 --- a/ui/raidboss/raidboss_config.ts +++ b/ui/raidboss/raidboss_config.ts @@ -527,7 +527,10 @@ const setOptionsFromOutputValue = ( options.SoundAlertsEnabled = false; options.SpokenAlertsEnabled = false; } else { - console.error(`unknown output type: ${JSON.stringify(value)}`); + // FIXME: handle lint error here + // ref: https://github.com/OverlayPlugin/cactbot/pull/274#discussion_r1692375852 + // eslint-ignore-next-line @typescript-eslint/no-base-to-string + console.error(`unknown output type: ${value.toString()}`); } };