diff --git a/scripts/lint.ts b/scripts/lint.ts new file mode 100644 index 000000000..f1e67ec68 --- /dev/null +++ b/scripts/lint.ts @@ -0,0 +1,30 @@ + +/* + * This script reads all theme and layer files and reformats them inplace + * Use with caution, make a commit beforehand! + */ + + +import ScriptUtils from "./ScriptUtils"; +import {readFileSync, writeFileSync} from "fs"; +import {tag} from "@turf/turf"; + +const layerFiles = ScriptUtils.getLayerFiles(); +for (const layerFile of layerFiles) { + console.log("Handling ", layerFile.path) + + for (const tagRendering of layerFile.parsed.tagRenderings) { + if(tagRendering["#"] !== undefined){ + tagRendering["id"] = tagRendering["#"] + delete tagRendering["#"] + } + if(tagRendering["id"] === undefined){ + if(tagRendering["freeform"]?.key !== undefined ) { + tagRendering["id"] = layerFile.parsed.id+"-"+tagRendering["freeform"]["key"] + } + } + } + + + writeFileSync(layerFile.path, JSON.stringify(layerFile.parsed, null, " ")) +} \ No newline at end of file