blob: 9884ccff291cc13e65469a2097eeed4ca30c4fd2 [file] [log] [blame]
const osmBoundarySources = require('./osmBoundarySources.json')
const zoneCfg = require('./timezones.json')
let numErrors = 0
const sourcesUsage = {}
Object.keys(osmBoundarySources).forEach(source => {
sourcesUsage[source] = false
})
Object.keys(zoneCfg).forEach(zone => {
zoneCfg[zone].forEach((operation, idx) => {
if (operation.source === 'overpass') {
// check if source is defined
if (!osmBoundarySources[operation.id]) {
numErrors++
console.error(`No osmBoundarySources config found for entry: ${operation.id}`)
} else {
sourcesUsage[operation.id] = true
}
} else if (operation.source.indexOf('manual') > -1 &&
(!operation.description ||
operation.description.length < 3)) {
numErrors++
console.error(`No description of ${operation.source} for operation ${idx} of zone: ${zone}`)
}
})
})
// check for sources not used in timezone building
Object.keys(sourcesUsage).forEach(source => {
if (!sourcesUsage[source]) {
numErrors++
console.error(`osmBoundarySources config "${source}" is never used in timezone boundary building`)
}
})
if (numErrors > 0) {
console.error(`${numErrors} errors found`)
process.exit(1)
} else {
console.log('No linting errors!')
}