feature(themeconfig): add pragma to disable 'questionHint'-checks

This commit is contained in:
Pieter Vander Vennet 2023-03-09 15:12:16 +01:00
parent eb6093dd9f
commit 06ebf2b619

View file

@ -593,8 +593,10 @@ export class DetectMappingsWithImages extends DesugaringStep<TagRenderingConfigJ
} }
class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> { class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
constructor() { private _options: { noQuestionHintCheck: boolean }
super("Miscellanious checks on the tagrendering", ["special"], "MiscTagRenderingChecks") constructor(options: { noQuestionHintCheck: boolean }) {
super("Miscellaneous checks on the tagrendering", ["special"], "MiscTagRenderingChecks")
this._options = options
} }
convert( convert(
@ -615,7 +617,7 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
': detected `special` on the top level. Did you mean `{"render":{ "special": ... }}`' ': detected `special` on the top level. Did you mean `{"render":{ "special": ... }}`'
) )
} }
if (json["question"]) { if (json["question"] && !this._options?.noQuestionHintCheck) {
const question = Translations.T( const question = Translations.T(
new TypedTranslation(json["question"]), new TypedTranslation(json["question"]),
context + ".question" context + ".question"
@ -644,12 +646,16 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
} }
export class ValidateTagRenderings extends Fuse<TagRenderingConfigJson> { export class ValidateTagRenderings extends Fuse<TagRenderingConfigJson> {
constructor(layerConfig?: LayerConfigJson, doesImageExist?: DoesImageExist) { constructor(
layerConfig?: LayerConfigJson,
doesImageExist?: DoesImageExist,
options?: { noQuestionHintCheck: boolean }
) {
super( super(
"Various validation on tagRenderingConfigs", "Various validation on tagRenderingConfigs",
new DetectShadowedMappings(layerConfig), new DetectShadowedMappings(layerConfig),
new DetectMappingsWithImages(doesImageExist), new DetectMappingsWithImages(doesImageExist),
new MiscTagRenderingChecks() new MiscTagRenderingChecks(options)
) )
} }
} }
@ -835,7 +841,11 @@ export class ValidateLayer extends DesugaringStep<LayerConfigJson> {
if (json.tagRenderings !== undefined) { if (json.tagRenderings !== undefined) {
const r = new On( const r = new On(
"tagRenderings", "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) ).convert(json, context)
warnings.push(...(r.warnings ?? [])) warnings.push(...(r.warnings ?? []))
errors.push(...(r.errors ?? [])) errors.push(...(r.errors ?? []))