From 907afa29f07344d7183ede9f12abc66e0b909311 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Mon, 27 May 2019 16:31:48 +0100 Subject: [PATCH] Lint single quotes --- app/.eslintrc | 3 ++- app/package.json | 1 + app/src/api/building.js | 26 ++++++++++---------- app/src/frontend/building-edit.js | 34 +++++++++++++------------- app/src/frontend/building-view.js | 16 ++++++------- app/src/frontend/legend.js | 40 +++++++++++++++---------------- app/src/frontend/map.js | 4 ++-- app/src/frontend/overview.js | 4 ++-- app/src/frontend/search-box.js | 8 +++---- app/src/frontend/tooltip.js | 2 +- app/src/parse.js | 2 +- app/src/server.js | 16 ++++++------- app/src/tiles/cache.js | 2 +- app/src/tiles/tileserver.js | 4 ++-- 14 files changed, 82 insertions(+), 80 deletions(-) diff --git a/app/.eslintrc b/app/.eslintrc index 89468957..8f94e0c1 100644 --- a/app/.eslintrc +++ b/app/.eslintrc @@ -20,7 +20,8 @@ "rules": { "no-console": "off", "strict": ["error", "global"], - "curly": "warn" + "curly": "warn", + "quotes": ["warn", "single"] }, "plugins": [ "react" diff --git a/app/package.json b/app/package.json index a5eaf014..62fce878 100644 --- a/app/package.json +++ b/app/package.json @@ -8,6 +8,7 @@ "start": "razzle start", "build": "razzle build", "test": "razzle test --env=jsdom", + "lint": "eslint .", "start:prod": "NODE_ENV=production node build/server.js" }, "dependencies": { diff --git a/app/src/api/building.js b/app/src/api/building.js index 2a4eb547..21a86c25 100644 --- a/app/src/api/building.js +++ b/app/src/api/building.js @@ -77,7 +77,7 @@ function queryBuildingsByReference(key, id) { function getBuildingById(id) { return db.one( - "SELECT * FROM buildings WHERE building_id = $1", + 'SELECT * FROM buildings WHERE building_id = $1', [id] ).catch(function (error) { console.error(error); @@ -87,7 +87,7 @@ function getBuildingById(id) { function getBuildingLikeById(building_id, user_id) { return db.oneOrNone( - "SELECT true as like FROM building_user_likes WHERE building_id = $1 and user_id = $2 LIMIT 1", + 'SELECT true as like FROM building_user_likes WHERE building_id = $1 and user_id = $2 LIMIT 1', [building_id, user_id] ).then(res => { return res && res.like @@ -99,7 +99,7 @@ function getBuildingLikeById(building_id, user_id) { function getBuildingUPRNsById(id) { return db.any( - "SELECT uprn, parent_uprn FROM building_properties WHERE building_id = $1", + 'SELECT uprn, parent_uprn FROM building_properties WHERE building_id = $1', [id] ).catch(function (error) { console.error(error); @@ -126,15 +126,15 @@ function saveBuilding(building_id, building, user_id) { // commit or rollback (repeated-read sufficient? or serializable?) return db.tx(t => { return t.one( - `SELECT * FROM buildings WHERE building_id = $1 FOR UPDATE;`, + 'SELECT * FROM buildings WHERE building_id = $1 FOR UPDATE;', [building_id] ).then(old_building => { const patches = compare(old_building, building, BUILDING_FIELD_WHITELIST); - console.log("Patching", building_id, patches) + console.log('Patching', building_id, patches) const forward = patches[0]; const reverse = patches[1]; if (Object.keys(forward).length === 0) { - return Promise.reject("No change provided") + return Promise.reject('No change provided') } return t.one( `INSERT INTO logs ( @@ -146,7 +146,7 @@ function saveBuilding(building_id, building, user_id) { [forward, reverse, building_id, user_id] ).then(revision => { const sets = db.$config.pgp.helpers.sets(forward); - console.log("Setting", building_id, sets) + console.log('Setting', building_id, sets) return t.one( `UPDATE buildings @@ -181,11 +181,11 @@ function likeBuilding(building_id, user_id) { // commit or rollback (serializable - could be more compact?) return db.tx({ serializable }, t => { return t.none( - "INSERT INTO building_user_likes ( building_id, user_id ) VALUES ($1, $2);", + 'INSERT INTO building_user_likes ( building_id, user_id ) VALUES ($1, $2);', [building_id, user_id] ).then(() => { return t.one( - "SELECT count(*) as likes FROM building_user_likes WHERE building_id = $1;", + 'SELECT count(*) as likes FROM building_user_likes WHERE building_id = $1;', [building_id] ).then(building => { return t.one( @@ -217,7 +217,7 @@ function likeBuilding(building_id, user_id) { }); }).catch(function (error) { console.error(error); - if (error.detail && error.detail.includes("already exists")) { + if (error.detail && error.detail.includes('already exists')) { // 'already exists' is thrown if user already liked it return { error: 'It looks like you already like that building!' }; } else { @@ -236,11 +236,11 @@ function unlikeBuilding(building_id, user_id) { // commit or rollback (serializable - could be more compact?) return db.tx({ serializable }, t => { return t.none( - "DELETE FROM building_user_likes WHERE building_id = $1 AND user_id = $2;", + 'DELETE FROM building_user_likes WHERE building_id = $1 AND user_id = $2;', [building_id, user_id] ).then(() => { return t.one( - "SELECT count(*) as likes FROM building_user_likes WHERE building_id = $1;", + 'SELECT count(*) as likes FROM building_user_likes WHERE building_id = $1;', [building_id] ).then(building => { return t.one( @@ -272,7 +272,7 @@ function unlikeBuilding(building_id, user_id) { }); }).catch(function (error) { console.error(error); - if (error.detail && error.detail.includes("already exists")) { + if (error.detail && error.detail.includes('already exists')) { // 'already exists' is thrown if user already liked it return { error: 'It looks like you already like that building!' }; } else { diff --git a/app/src/frontend/building-edit.js b/app/src/frontend/building-edit.js index c85a2cbe..93e25b80 100644 --- a/app/src/frontend/building-edit.js +++ b/app/src/frontend/building-edit.js @@ -29,7 +29,7 @@ const BuildingEdit = (props) => { return ( { CONFIG.map((conf_props) => { @@ -169,8 +169,8 @@ class EditForm extends Component { const match = this.props.cat === this.props.slug; const building_like = this.props.building_like; return ( -
-
+
+
{ switch (props.type) { - case "text": + case 'text': return - case "text_list": + case 'text_list': return - case "text_long": + case 'text_long': return - case "number": + case 'number': return - case "year_estimator": + case 'year_estimator': return - case "text_multi": + case 'text_multi': return - case "checkbox": + case 'checkbox': return - case "like": + case 'like': return @@ -265,7 +265,7 @@ const TextInput = (props) => (