forked from MapComplete/MapComplete
Refactoring: change order of parameters and remove parameter for Conversion.ts
This commit is contained in:
parent
f9ba3126a4
commit
a0b7a32223
20 changed files with 147 additions and 213 deletions
|
@ -28,9 +28,8 @@ export class ValidateLanguageCompleteness extends DesugaringStep<ThemeConfig> {
|
|||
|
||||
constructor(...languages: string[]) {
|
||||
super(
|
||||
"ValidateLanguageCompleteness",
|
||||
"Checks that the given object is fully translated in the specified languages",
|
||||
[],
|
||||
"ValidateLanguageCompleteness"
|
||||
)
|
||||
this._languages = languages ?? ["en"]
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ export class DoesImageExist extends DesugaringStep<string> {
|
|||
checkExistsSync: (path: string) => boolean = undefined,
|
||||
ignore?: Set<string>
|
||||
) {
|
||||
super("Checks if an image exists", [], "DoesImageExist")
|
||||
super("DoesImageExist", "Checks if an image exists")
|
||||
this._ignore = ignore
|
||||
this._knownImagePaths = knownImagePaths
|
||||
this.doesPathExist = checkExistsSync
|
||||
|
@ -129,9 +128,8 @@ export class DoesImageExist extends DesugaringStep<string> {
|
|||
class OverrideShadowingCheck extends DesugaringStep<ThemeConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"OverrideShadowingCheck",
|
||||
"Checks that an 'overrideAll' does not override a single override",
|
||||
[],
|
||||
"OverrideShadowingCheck"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -170,7 +168,7 @@ class OverrideShadowingCheck extends DesugaringStep<ThemeConfigJson> {
|
|||
|
||||
class MiscThemeChecks extends DesugaringStep<ThemeConfigJson> {
|
||||
constructor() {
|
||||
super("Miscelleanous checks on the theme", [], "MiscThemesChecks")
|
||||
super("Miscelleanous checks on the theme", "MiscThemesChecks")
|
||||
}
|
||||
|
||||
convert(json: ThemeConfigJson, context: ConversionContext): ThemeConfigJson {
|
||||
|
@ -265,9 +263,8 @@ export class PrevalidateTheme extends Fuse<ThemeConfigJson> {
|
|||
export class DetectConflictingAddExtraTags extends DesugaringStep<TagRenderingConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"DetectConflictingAddExtraTags",
|
||||
"The `if`-part in a mapping might set some keys. Those keys are not allowed to be set in the `addExtraTags`, as this might result in conflicting values",
|
||||
[],
|
||||
"DetectConflictingAddExtraTags"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -310,9 +307,8 @@ export class DetectConflictingAddExtraTags extends DesugaringStep<TagRenderingCo
|
|||
export class DetectNonErasedKeysInMappings extends DesugaringStep<QuestionableTagRenderingConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"DetectNonErasedKeysInMappings",
|
||||
"A tagRendering might set a freeform key (e.g. `name` and have an option that _should_ erase this name, e.g. `noname=yes`). Under normal circumstances, every mapping/freeform should affect all touched keys",
|
||||
[],
|
||||
"DetectNonErasedKeysInMappings"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -407,9 +403,8 @@ export class DetectMappingsShadowedByCondition extends DesugaringStep<TagRenderi
|
|||
|
||||
constructor(forceError: boolean = false) {
|
||||
super(
|
||||
"DetectMappingsShadowedByCondition",
|
||||
"Checks that, if the tagrendering has a condition, that a mapping is not contradictory to it, i.e. that there are no dead mappings",
|
||||
[],
|
||||
"DetectMappingsShadowedByCondition"
|
||||
)
|
||||
this._forceError = forceError
|
||||
}
|
||||
|
@ -471,7 +466,7 @@ export class DetectShadowedMappings extends DesugaringStep<TagRenderingConfigJso
|
|||
private readonly _calculatedTagNames: string[]
|
||||
|
||||
constructor(layerConfig?: LayerConfigJson) {
|
||||
super("Checks that the mappings don't shadow each other", [], "DetectShadowedMappings")
|
||||
super("DetectShadowedMappings", "Checks that the mappings don't shadow each other")
|
||||
this._calculatedTagNames = DetectShadowedMappings.extractCalculatedTagNames(layerConfig)
|
||||
}
|
||||
|
||||
|
@ -599,9 +594,8 @@ export class DetectShadowedMappings extends DesugaringStep<TagRenderingConfigJso
|
|||
export class ValidatePossibleLinks extends DesugaringStep<string | Record<string, string>> {
|
||||
constructor() {
|
||||
super(
|
||||
"ValidatePossibleLinks",
|
||||
"Given a possible set of translations, validates that <a href=... target='_blank'> does have `rel='noopener'` set",
|
||||
[],
|
||||
"ValidatePossibleLinks"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -661,9 +655,8 @@ export class CheckTranslation extends DesugaringStep<Translatable> {
|
|||
|
||||
constructor(allowUndefined: boolean = false) {
|
||||
super(
|
||||
"CheckTranslation",
|
||||
"Checks that a translation is valid and internally consistent",
|
||||
["*"],
|
||||
"CheckTranslation"
|
||||
)
|
||||
this._allowUndefined = allowUndefined
|
||||
}
|
||||
|
@ -712,7 +705,7 @@ export class ValidateLayerConfig extends DesugaringStep<LayerConfigJson> {
|
|||
studioValidations: boolean = false,
|
||||
skipDefaultLayers: boolean = false
|
||||
) {
|
||||
super("Thin wrapper around 'ValidateLayer", [], "ValidateLayerConfig")
|
||||
super("ValidateLayerConfig", "Thin wrapper around 'ValidateLayer")
|
||||
this.validator = new ValidateLayer(
|
||||
path,
|
||||
isBuiltin,
|
||||
|
@ -734,7 +727,7 @@ export class ValidateLayerConfig extends DesugaringStep<LayerConfigJson> {
|
|||
|
||||
export class ValidatePointRendering extends DesugaringStep<PointRenderingConfigJson> {
|
||||
constructor() {
|
||||
super("Various checks for pointRenderings", [], "ValidatePOintRendering")
|
||||
super("ValidatePointRendering", "Various checks for pointRenderings")
|
||||
}
|
||||
|
||||
convert(json: PointRenderingConfigJson, context: ConversionContext): PointRenderingConfigJson {
|
||||
|
@ -777,7 +770,7 @@ export class ValidateLayer extends Conversion<
|
|||
studioValidations: boolean = false,
|
||||
skipDefaultLayers: boolean = false
|
||||
) {
|
||||
super("Doesn't change anything, but emits warnings and errors", [], "ValidateLayer")
|
||||
super("ValidateLayer", "Doesn't change anything, but emits warnings and errors")
|
||||
this._prevalidation = new PrevalidateLayer(
|
||||
path,
|
||||
isBuiltin,
|
||||
|
@ -819,7 +812,7 @@ export class ValidateLayer extends Conversion<
|
|||
}
|
||||
|
||||
for (let i = 0; i < (layerConfig.calculatedTags ?? []).length; i++) {
|
||||
const [_, code, __] = layerConfig.calculatedTags[i]
|
||||
const code = layerConfig.calculatedTags[i][1]
|
||||
try {
|
||||
new Function("feat", "return " + code + ";")
|
||||
} catch (e) {
|
||||
|
@ -894,7 +887,7 @@ export class ValidateLayer extends Conversion<
|
|||
|
||||
export class ValidateFilter extends DesugaringStep<FilterConfigJson> {
|
||||
constructor() {
|
||||
super("Detect common errors in the filters", [], "ValidateFilter")
|
||||
super("ValidateFilter", "Detect common errors in the filters")
|
||||
}
|
||||
|
||||
convert(filter: FilterConfigJson, context: ConversionContext): FilterConfigJson {
|
||||
|
@ -931,9 +924,8 @@ export class DetectDuplicateFilters extends DesugaringStep<{
|
|||
}> {
|
||||
constructor() {
|
||||
super(
|
||||
"Tries to detect layers where a shared filter can be used (or where similar filters occur)",
|
||||
[],
|
||||
"DetectDuplicateFilters"
|
||||
"DetectDuplicateFilters",
|
||||
"Tries to detect layers where a shared filter can be used (or where similar filters occur)"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1041,9 +1033,8 @@ export class DetectDuplicateFilters extends DesugaringStep<{
|
|||
export class DetectDuplicatePresets extends DesugaringStep<ThemeConfig> {
|
||||
constructor() {
|
||||
super(
|
||||
"DetectDuplicatePresets",
|
||||
"Detects mappings which have identical (english) names or identical mappings.",
|
||||
["presets"],
|
||||
"DetectDuplicatePresets"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1107,11 +1098,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
>
|
||||
> {
|
||||
constructor() {
|
||||
super(
|
||||
"Validates that all themes together are logical, i.e. no duplicate ids exists within (overriden) themes",
|
||||
[],
|
||||
"ValidateThemeEnsemble"
|
||||
)
|
||||
super("ValidateThemeEnsemble", "Validates that all themes together are logical, i.e. no duplicate ids exists within (overriden) themes")
|
||||
}
|
||||
|
||||
convert(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue