From 06ebf2b619b33e111cc1731389a874b4ef7736d6 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 9 Mar 2023 15:12:16 +0100 Subject: [PATCH] feature(themeconfig): add pragma to disable 'questionHint'-checks --- Models/ThemeConfig/Conversion/Validation.ts | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Models/ThemeConfig/Conversion/Validation.ts b/Models/ThemeConfig/Conversion/Validation.ts index 06ae6f585d..5e5a92d341 100644 --- a/Models/ThemeConfig/Conversion/Validation.ts +++ b/Models/ThemeConfig/Conversion/Validation.ts @@ -593,8 +593,10 @@ export class DetectMappingsWithImages extends DesugaringStep { - constructor() { - super("Miscellanious checks on the tagrendering", ["special"], "MiscTagRenderingChecks") + private _options: { noQuestionHintCheck: boolean } + constructor(options: { noQuestionHintCheck: boolean }) { + super("Miscellaneous checks on the tagrendering", ["special"], "MiscTagRenderingChecks") + this._options = options } convert( @@ -615,7 +617,7 @@ class MiscTagRenderingChecks extends DesugaringStep { ': detected `special` on the top level. Did you mean `{"render":{ "special": ... }}`' ) } - if (json["question"]) { + if (json["question"] && !this._options?.noQuestionHintCheck) { const question = Translations.T( new TypedTranslation(json["question"]), context + ".question" @@ -644,12 +646,16 @@ class MiscTagRenderingChecks extends DesugaringStep { } export class ValidateTagRenderings extends Fuse { - constructor(layerConfig?: LayerConfigJson, doesImageExist?: DoesImageExist) { + constructor( + layerConfig?: LayerConfigJson, + doesImageExist?: DoesImageExist, + options?: { noQuestionHintCheck: boolean } + ) { super( "Various validation on tagRenderingConfigs", new DetectShadowedMappings(layerConfig), new DetectMappingsWithImages(doesImageExist), - new MiscTagRenderingChecks() + new MiscTagRenderingChecks(options) ) } } @@ -835,7 +841,11 @@ export class ValidateLayer extends DesugaringStep { if (json.tagRenderings !== undefined) { const r = new On( "tagRenderings", - new Each(new ValidateTagRenderings(json, this._doesImageExist)) + new Each( + new ValidateTagRenderings(json, this._doesImageExist, { + noQuestionHintCheck: json["#"]?.indexOf("no-question-hint-check") >= 0, + }) + ) ).convert(json, context) warnings.push(...(r.warnings ?? [])) errors.push(...(r.errors ?? []))