Add linting file

This commit is contained in:
pietervdvn 2021-09-26 18:21:29 +02:00
parent d326facf39
commit 0efd83c9b6

30
scripts/lint.ts Normal file
View file

@ -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, " "))
}