1const osmBoundarySources = require('./osmBoundarySources.json') 2const zoneCfg = require('./timezones.json') 3const expectedZoneOverlaps = require('./expectedZoneOverlaps.json') 4 5let numErrors = 0 6 7const sourcesUsage = {} 8Object.keys(osmBoundarySources).forEach(source => { 9 sourcesUsage[source] = false 10}) 11 12Object.keys(zoneCfg).forEach(zone => { 13 zoneCfg[zone].forEach((operation, idx) => { 14 if (operation.source === 'overpass') { 15 // check if source is defined 16 if (!osmBoundarySources[operation.id]) { 17 numErrors++ 18 19 console.error(`No osmBoundarySources config found for entry: ${operation.id}`) 20 } else { 21 sourcesUsage[operation.id] = true 22 } 23 } else if (operation.source.indexOf('manual') > -1 && 24 (!operation.description || 25 operation.description.length < 3)) { 26 numErrors++ 27 28 console.error(`No description of ${operation.source} for operation ${idx} of zone: ${zone}`) 29 } 30 }) 31}) 32 33// check for sources not used in timezone building 34Object.keys(sourcesUsage).forEach(source => { 35 if (!sourcesUsage[source]) { 36 numErrors++ 37 console.error(`osmBoundarySources config "${source}" is never used in timezone boundary building`) 38 } 39}) 40 41// Make sure all expected zone overlaps have a description 42Object.keys(expectedZoneOverlaps).forEach(zoneOverlap => { 43 expectedZoneOverlaps[zoneOverlap].forEach((overlapBounds, idx) => { 44 if (!overlapBounds.description || overlapBounds.description.length < 3) { 45 numErrors++ 46 console.error(`Expected overlap #${idx} of zones ${zoneOverlap} missing description`) 47 } 48 }) 49}) 50 51if (numErrors > 0) { 52 console.error(`${numErrors} errors found`) 53 process.exit(1) 54} else { 55 console.log('No linting errors!') 56} 57