Skip to content

Commit

Permalink
Fix eslint Tilegarden warnings
Browse files Browse the repository at this point in the history
Use --fix to auto-apply updates to eslint rules.
  • Loading branch information
flibbertigibbet authored and KlaasH committed Dec 2, 2020
1 parent b58c783 commit 9ce2ae8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/tilegarden/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getPositionalFilters = (req) => {
}

// Parses out the configuration specifications
const processConfig = req => ({
const processConfig = (req) => ({
s3bucket: req.queryStringParameters ? req.queryStringParameters.s3bucket : null,
config: req.pathParameters.config,
})
Expand Down Expand Up @@ -100,7 +100,7 @@ const writeToS3 = (tile, req) => {
return tile
})
}
return new Promise(resolve => resolve(tile))
return new Promise((resolve) => resolve(tile))
}

// Get tile for some zxy bounds
Expand All @@ -114,8 +114,8 @@ api.get(

logger.debug('api.get: creating imageTile')
return imageTile(createMap(z, x, y, filters, configOptions))
.then(tile => writeToS3(tile, req))
.then(img => new APIBuilder.ApiResponse(img, IMAGE_HEADERS, 200))
.then((tile) => writeToS3(tile, req))
.then((img) => new APIBuilder.ApiResponse(img, IMAGE_HEADERS, 200))
.catch(handleError)
} catch (e) {
return handleError(e)
Expand Down Expand Up @@ -175,7 +175,7 @@ api.proxyRouter = (event, context, callback) => {
} else {
origProxyRouter(event, context, callback)
}
}).catch(err => logger.error('Error: ', err))
}).catch((err) => logger.error('Error: ', err))
}

// not es6-ic, but necessary for claudia to find the index
Expand Down
8 changes: 4 additions & 4 deletions src/tilegarden/src/tiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ module.exports.createMap = (z, x, y, filters, configOptions) => {
return fetchMapFile(configOptions)
.then(fillVars)
.then(parseXml)
.then(xmlJsObj => addParamFilters(xmlJsObj, filters))
.then((xmlJsObj) => addParamFilters(xmlJsObj, filters))
.then(buildXml)
.then(xml => new Promise((resolve, reject) => {
.then((xml) => new Promise((resolve, reject) => {
logger.debug('createMap: calling map.FromString')
map.fromString(xml, (err, result) => {
if (err) {
Expand Down Expand Up @@ -136,14 +136,14 @@ module.exports.imageTile = (map) => {
// render map to image
// return asynchronous rendering method as a promise
return map
.then(m => new Promise((resolve, reject) => {
.then((m) => new Promise((resolve, reject) => {
logger.debug('imageTile: rendering')
m.render(img, {}, (err, result) => {
if (err) reject(err)
else resolve(result)
})
}))
.then(renderedTile => new Promise((resolve, reject) => {
.then((renderedTile) => new Promise((resolve, reject) => {
logger.debug('imageTile: encoding')
renderedTile.encode('png', {}, (err, result) => {
if (err) reject(err)
Expand Down
6 changes: 3 additions & 3 deletions src/tilegarden/src/util/param-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
const sqlString = require('sql-escape-string')

// Helper function to escape col but replace outer '-s with "-s to make a delimited identifier
const processCol = col => `"${sqlString(col).slice(1, -1)}"`
const processCol = (col) => `"${sqlString(col).slice(1, -1)}"`

// Combine parameters and values into a series of SQL conditions, ANDed
function composeFilterQuery(filters) {
return Object.entries(filters)
.map(entry => `${processCol(entry[0])} = ${sqlString(entry[1])}`)
.map((entry) => `${processCol(entry[0])} = ${sqlString(entry[1])}`)
.join(' AND ')
}

Expand All @@ -20,7 +20,7 @@ function composeFilterQuery(filters) {
function applyFilterQuery(xmlJson, filterQuery) {
xmlJson.Map.Layer.forEach((layer) => {
// Get the <Datasource><Parameter name="table"> element, which contains the default query
const queryObj = layer.Datasource[0].Parameter.filter(p => p.$.name === 'table')[0]
const queryObj = layer.Datasource[0].Parameter.filter((p) => p.$.name === 'table')[0]

// Add the filters onto it
const query = `SELECT * FROM ${queryObj._} WHERE ${filterQuery}`
Expand Down

0 comments on commit 9ce2ae8

Please sign in to comment.