diff --git a/app/controllers/payments.js b/app/controllers/payments.js index b7ef4bfc66..16a5c42c54 100644 --- a/app/controllers/payments.js +++ b/app/controllers/payments.js @@ -2,7 +2,7 @@ const config = require('config') const stripe = require('stripe')(config.stripe.api_secret) exports.post = (req, res) => { - let amount = 1000 + const amount = 1000 stripe.customers.create({ email: req.body.stripeEmail, diff --git a/app/db/config/config.js b/app/db/config/config.js index 579695957f..2d46de9764 100644 --- a/app/db/config/config.js +++ b/app/db/config/config.js @@ -1,24 +1,24 @@ require('dotenv').config() module.exports = { - 'development': { - 'database': 'streetmix_dev', - 'host': process.env.PGHOST || '127.0.0.1', - 'port': process.env.PGPORT || 5432, - 'dialect': 'postgres' + development: { + database: 'streetmix_dev', + host: process.env.PGHOST || '127.0.0.1', + port: process.env.PGPORT || 5432, + dialect: 'postgres' }, - 'test': { - 'database': 'streetmix_test', - 'host': process.env.PGHOST || '127.0.0.1', - 'port': process.env.PGPORT || 5432, - 'dialect': 'postgres' + test: { + database: 'streetmix_test', + host: process.env.PGHOST || '127.0.0.1', + port: process.env.PGPORT || 5432, + dialect: 'postgres' }, - 'staging': { - 'use_env_variable': 'DATABASE_URL', - 'dialect': 'postgres' + staging: { + use_env_variable: 'DATABASE_URL', + dialect: 'postgres' }, - 'production': { - 'use_env_variable': 'DATABASE_URL', - 'dialect': 'postgres' + production: { + use_env_variable: 'DATABASE_URL', + dialect: 'postgres' } } diff --git a/app/db/migrations/20180729103424-create-street.js b/app/db/migrations/20180729103424-create-street.js index bd2b52cba5..80427aace8 100644 --- a/app/db/migrations/20180729103424-create-street.js +++ b/app/db/migrations/20180729103424-create-street.js @@ -12,7 +12,7 @@ module.exports = { }, status: { type: Sequelize.ENUM, - values: [ 'ACTIVE', 'DELETED' ], + values: ['ACTIVE', 'DELETED'], defaultValue: 'ACTIVE' }, name: { diff --git a/app/db/models/street.js b/app/db/models/street.js index 77e7d54f42..6b2ddcc5a7 100644 --- a/app/db/models/street.js +++ b/app/db/models/street.js @@ -9,7 +9,7 @@ module.exports = (sequelize, DataTypes) => { namespaced_id: DataTypes.INTEGER, status: { type: DataTypes.ENUM, - values: [ 'ACTIVE', 'DELETED' ], + values: ['ACTIVE', 'DELETED'], defaultValue: 'ACTIVE' }, name: DataTypes.STRING, diff --git a/app/models/__mocks__/sequence.js b/app/models/__mocks__/sequence.js index a612153a0d..d8328073fa 100644 --- a/app/models/__mocks__/sequence.js +++ b/app/models/__mocks__/sequence.js @@ -2,7 +2,7 @@ const dummySequence = { _id: 'streets', - '__v': 0, + __v: 0, seq: 65 } diff --git a/app/models/__mocks__/street.js b/app/models/__mocks__/street.js index d6ef979e3b..4459998c98 100644 --- a/app/models/__mocks__/street.js +++ b/app/models/__mocks__/street.js @@ -1,7 +1,7 @@ /* eslint-env jest */ const dummySequence = { _id: 'streets', - '__v': 0, + __v: 0, seq: 65 } diff --git a/app/models/__mocks__/user.js b/app/models/__mocks__/user.js index 15795a96dd..d70952634c 100644 --- a/app/models/__mocks__/user.js +++ b/app/models/__mocks__/user.js @@ -1,7 +1,7 @@ /* eslint-env jest */ const mockUsers = { user1: { - login_tokens: [ 'xxxxxxxx-xxxx-xxxx-xxxx-1111111111111' ], + login_tokens: ['xxxxxxxx-xxxx-xxxx-xxxx-1111111111111'], _id: '1', id: 'user1', last_street_id: '3e888ae0-5f48-11e8-82e7-c3447c17015a', @@ -15,7 +15,7 @@ const mockUsers = { roles: [] }, user2: { - login_tokens: [ 'xxxxxxxx-xxxx-xxxx-xxxx-2222222222222' ], + login_tokens: ['xxxxxxxx-xxxx-xxxx-xxxx-2222222222222'], _id: '2', id: 'user2', twitter_id: '2', @@ -28,7 +28,7 @@ const mockUsers = { roles: [] }, admin: { - login_tokens: [ 'xxxxxxxx-xxxx-xxxx-xxxx-3333333333333' ], + login_tokens: ['xxxxxxxx-xxxx-xxxx-xxxx-3333333333333'], _id: '3', id: 'admin', twitter_id: '3', @@ -38,7 +38,7 @@ const mockUsers = { }, updated_at: '2018-05-22T14:18:09.853Z', created_at: '2018-05-21T19:35:10.807Z', - roles: [ 'ADMIN' ] + roles: ['ADMIN'] } } diff --git a/app/models/street.js b/app/models/street.js index 15fc34a7ac..d522084017 100644 --- a/app/models/street.js +++ b/app/models/street.js @@ -5,7 +5,7 @@ const User = require('./user.js') const streetSchema = new mongoose.Schema({ id: { type: String, index: { unique: true } }, namespaced_id: { type: Number, index: true }, - status: { type: String, enum: [ 'ACTIVE', 'DELETED' ], default: 'ACTIVE' }, + status: { type: String, enum: ['ACTIVE', 'DELETED'], default: 'ACTIVE' }, name: String, creator_id: { type: mongoose.Schema.ObjectId, diff --git a/app/models/street_data.js b/app/models/street_data.js index 95c7596826..27f993d1c8 100644 --- a/app/models/street_data.js +++ b/app/models/street_data.js @@ -40,7 +40,7 @@ function incrementSchemaVersion (street) { } break case 4: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-lamp') { variant = getVariantArray(segment.type, segment.variantString) @@ -50,7 +50,7 @@ function incrementSchemaVersion (street) { } break case 5: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'streetcar') { variant = getVariantArray(segment.type, segment.variantString) @@ -60,7 +60,7 @@ function incrementSchemaVersion (street) { } break case 6: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bus-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -74,7 +74,7 @@ function incrementSchemaVersion (street) { } break case 7: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bike-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -84,7 +84,7 @@ function incrementSchemaVersion (street) { } break case 8: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'drive-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -94,7 +94,7 @@ function incrementSchemaVersion (street) { } break case 9: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk') { variant = getVariantArray(segment.type, segment.variantString) @@ -104,7 +104,7 @@ function incrementSchemaVersion (street) { } break case 10: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'planting-strip') { segment.type = 'divider' @@ -119,7 +119,7 @@ function incrementSchemaVersion (street) { } break case 11: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'divider') { if (segment.variantString === 'small-tree') { @@ -133,7 +133,7 @@ function incrementSchemaVersion (street) { } break case 12: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-bike-rack') { variant = getVariantArray(segment.type, segment.variantString) @@ -143,7 +143,7 @@ function incrementSchemaVersion (street) { } break case 13: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-wayfinding') { variant = getVariantArray(segment.type, segment.variantString) @@ -153,7 +153,7 @@ function incrementSchemaVersion (street) { } break case 14: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk') { segment.randSeed = 35 @@ -163,7 +163,7 @@ function incrementSchemaVersion (street) { case 15: break case 16: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bike-lane') { variant = getVariantArray(segment.type, segment.variantString) diff --git a/app/models/user.js b/app/models/user.js index 0babba147d..1128b121fe 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -6,14 +6,14 @@ const userSchema = new mongoose.Schema({ twitter_credentials: mongoose.Schema.Types.Mixed, auth0_id: String, email: { type: String, index: { unique: true, sparse: true } }, - login_tokens: [ String ], + login_tokens: [String], profile_image_url: String, data: mongoose.Schema.Types.Mixed, created_at: Date, updated_at: Date, last_street_id: Number, flags: mongoose.Schema.Types.Mixed, - roles: [ String ] + roles: [String] }) userSchema.pre('save', function (next) { diff --git a/app/resources/v1/flags.js b/app/resources/v1/flags.js index ec3db452ca..9fc87e410c 100644 --- a/app/resources/v1/flags.js +++ b/app/resources/v1/flags.js @@ -24,7 +24,7 @@ async function readFlags (res) { function sendSuccessResponse (res, flags) { res.set({ 'Content-Type': 'application/json; charset=utf-8', - 'Location': config.restapi.baseuri + '/v1/flags', + Location: config.restapi.baseuri + '/v1/flags', 'Cache-Control': 'max-age=86400' }) @@ -32,7 +32,7 @@ function sendSuccessResponse (res, flags) { } exports.get = async function (req, res) { - let flags = await readFlags(res) + const flags = await readFlags(res) if (flags) { sendSuccessResponse(res, flags) diff --git a/app/resources/v1/streets.js b/app/resources/v1/streets.js index 030b1c69e3..37c2d2495c 100644 --- a/app/resources/v1/streets.js +++ b/app/resources/v1/streets.js @@ -32,12 +32,12 @@ exports.post = async function (req, res) { try { if (street.creator_id) { const row = await User.findByIdAndUpdate(street.creator_id, - { $inc: { 'last_street_id': 1 } }, + { $inc: { last_street_id: 1 } }, { new: true, upsert: true }) namespacedId = (row) ? row.last_street_id : null } else { const row = await Sequence.findByIdAndUpdate('streets', - { $inc: { 'seq': 1 } }, + { $inc: { seq: 1 } }, { new: true, upsert: true }) namespacedId = (row) ? row.seq : null } @@ -112,7 +112,7 @@ exports.post = async function (req, res) { if (req.loginToken) { let user try { - user = await User.findOne({ login_tokens: { $in: [ req.loginToken ] } }) + user = await User.findOne({ login_tokens: { $in: [req.loginToken] } }) } catch (err) { logger.error(err) handleErrors(ERRORS.USER_NOT_FOUND) @@ -147,7 +147,7 @@ exports.delete = async function (req, res) { async function deleteStreet (street) { let user try { - user = await User.findOne({ login_tokens: { $in: [ req.loginToken ] } }) + user = await User.findOne({ login_tokens: { $in: [req.loginToken] } }) } catch (err) { logger.error(err) throw new Error(ERRORS.USER_NOT_FOUND) @@ -327,9 +327,8 @@ exports.find = function (req, res) { } if (start + streets.length < totalNumStreets) { - let nextStart, nextCount - nextStart = start + count - nextCount = Math.min(count, totalNumStreets - start - streets.length) + const nextStart = start + count + const nextCount = Math.min(count, totalNumStreets - start - streets.length) json.meta.links.next = config.restapi.baseuri + '/v1/streets?start=' + nextStart + '&count=' + nextCount } @@ -431,7 +430,7 @@ exports.put = async function (req, res) { async function updateStreetWithCreatorId (street) { let user try { - user = await User.findOne({ login_tokens: { $in: [ req.loginToken ] } }) + user = await User.findOne({ login_tokens: { $in: [req.loginToken] } }) } catch (err) { logger.error(err) handleErrors(ERRORS.CANNOT_UPDATE_STREET) diff --git a/app/resources/v1/streets_pg.js b/app/resources/v1/streets_pg.js index 0d15686e08..adfc05e551 100644 --- a/app/resources/v1/streets_pg.js +++ b/app/resources/v1/streets_pg.js @@ -139,7 +139,7 @@ exports.post = async function (req, res) { let user try { user = await User.findOne({ - where: { login_tokens: { [Op.contains]: [ req.loginToken ] } } + where: { login_tokens: { [Op.contains]: [req.loginToken] } } }) } catch (err) { logger.error(err) @@ -176,7 +176,7 @@ exports.delete = async function (req, res) { let user try { user = await User.findOne({ - where: { login_tokens: { [Op.contains]: [ req.loginToken ] } } + where: { login_tokens: { [Op.contains]: [req.loginToken] } } }) } catch (err) { logger.error(err) @@ -307,7 +307,7 @@ exports.find = async function (req, res) { const findStreets = async function (start, count) { return Street.findAndCountAll({ where: { status: 'ACTIVE' }, - order: [ ['updated_at', 'DESC'] ], + order: [['updated_at', 'DESC']], offset: start, limit: count }) @@ -378,9 +378,8 @@ exports.find = async function (req, res) { } if (start + streets.length < totalNumStreets) { - let nextStart, nextCount - nextStart = start + count - nextCount = Math.min(count, totalNumStreets - start - streets.length) + const nextStart = start + count + const nextCount = Math.min(count, totalNumStreets - start - streets.length) json.meta.links.next = config.restapi.baseuri + '/v1/streets?start=' + nextStart + '&count=' + nextCount } res.status(200).send(json) @@ -484,7 +483,7 @@ exports.put = async function (req, res) { let user try { user = await User.findOne({ - where: { login_tokens: { [Op.contains]: [ req.loginToken ] } } + where: { login_tokens: { [Op.contains]: [req.loginToken] } } }) } catch (err) { logger.error(err) diff --git a/app/resources/v1/translate.js b/app/resources/v1/translate.js index f6c78183bc..62591c9ba2 100644 --- a/app/resources/v1/translate.js +++ b/app/resources/v1/translate.js @@ -27,7 +27,7 @@ async function getLocalTranslation (res, locale, resource) { function sendSuccessResponse (res, locale, resource, translation) { res.set({ 'Content-Type': 'application/json; charset=utf-8', - 'Location': config.restapi.baseuri + '/v1/translate/' + locale + '/' + resource, + Location: config.restapi.baseuri + '/v1/translate/' + locale + '/' + resource, 'Cache-Control': 'max-age=86400' }) diff --git a/app/resources/v1/user.js b/app/resources/v1/user.js index 1b4ecc9051..6bf7487ea8 100644 --- a/app/resources/v1/user.js +++ b/app/resources/v1/user.js @@ -34,7 +34,7 @@ exports.get = async function (req, res) { const findUserByLoginToken = async function (loginToken) { try { - requestUser = await User.findOne({ login_tokens: { $in: [ loginToken ] } }) + requestUser = await User.findOne({ login_tokens: { $in: [loginToken] } }) } catch (err) { logger.error(err) throw new Error(ERRORS.CANNOT_GET_USER) diff --git a/app/resources/v1/users.js b/app/resources/v1/users.js index 42c31552e1..98d0982ab0 100644 --- a/app/resources/v1/users.js +++ b/app/resources/v1/users.js @@ -47,7 +47,7 @@ exports.post = function (req, res) { const u = new User({ id: credentials.screenName, auth0_id: credentials.auth0_id, - login_tokens: [ loginToken ], + login_tokens: [loginToken], profile_image_url: credentials.profile_image_url }) u.save(handleCreateUser) @@ -80,7 +80,7 @@ exports.post = function (req, res) { access_token_key: twitterCredentials.oauthAccessTokenKey, access_token_secret: twitterCredentials.oauthAccessTokenSecret }, - login_tokens: [ loginToken ] + login_tokens: [loginToken] }) u.save(handleCreateUser) } else { @@ -145,7 +145,7 @@ exports.post = function (req, res) { id: credentials.nickname, auth0_id: credentials.auth0_id, email: credentials.email, - login_tokens: [ loginToken ], + login_tokens: [loginToken], profile_image_url: credentials.profile_image_url }) u.save(handleCreateUser) @@ -155,7 +155,7 @@ exports.post = function (req, res) { id: id, auth0_id: credentials.auth0_id, email: credentials.email, - login_tokens: [ loginToken ], + login_tokens: [loginToken], profile_image_url: credentials.profile_image_url }) u.save(handleCreateUser) @@ -184,11 +184,11 @@ exports.post = function (req, res) { return } - if (body.hasOwnProperty('twitter')) { + if (Object.prototype.hasOwnProperty.call(body, 'twitter')) { handleTwitterSignIn(body.twitter) - } else if (body.hasOwnProperty('auth0_twitter')) { + } else if (Object.prototype.hasOwnProperty.call(body, 'auth0_twitter')) { handleAuth0TwitterSignIn(body.auth0_twitter) - } else if (body.hasOwnProperty('auth0')) { + } else if (Object.prototype.hasOwnProperty.call(body, 'auth0')) { handleAuth0SignIn(body.auth0) } else { res.status(400).send('Unknown sign-in method used.') @@ -242,7 +242,7 @@ exports.get = function (req, res) { } const handleFindUsers = function (users) { - let usersArray = [] + const usersArray = [] const getUserJson = function (user) { user.asJson({ auth: true }, function (err, userJson) { diff --git a/app/resources/v1/users_pg.js b/app/resources/v1/users_pg.js index 8014522c99..83dab12827 100644 --- a/app/resources/v1/users_pg.js +++ b/app/resources/v1/users_pg.js @@ -45,7 +45,7 @@ exports.post = async function (req, res) { // } loginToken = uuid.v1() - if (body.hasOwnProperty('twitter')) { + if (Object.prototype.hasOwnProperty.call(body, 'twitter')) { const credentials = body.twitter return { id: credentials.screenName, @@ -54,23 +54,23 @@ exports.post = async function (req, res) { access_token_key: credentials.oauthAccessTokenKey, access_token_secret: credentials.oauthAccessTokenSecret }, - login_tokens: [ loginToken ] + login_tokens: [loginToken] } - } else if (body.hasOwnProperty('auth0_twitter')) { + } else if (Object.prototype.hasOwnProperty.call(body, 'auth0_twitter')) { const credentials = body.auth0_twitter return { id: credentials.screenName, auth0_id: credentials.auth0_id, - login_tokens: [ loginToken ], + login_tokens: [loginToken], profile_image_url: credentials.profile_image_url } - } else if (body.hasOwnProperty('auth0_email')) { + } else if (Object.prototype.hasOwnProperty.call(body, 'auth0_email')) { const credentials = body.auth0_email return { id: credentials.nickname, auth0_id: credentials.auth0_id, email: credentials.email, - login_tokens: [ loginToken ], + login_tokens: [loginToken], profile_image_url: credentials.profile_image_url } } @@ -209,7 +209,7 @@ exports.get = async function (req, res) { let user try { user = await User.findOne({ - where: { login_tokens: { [Op.contains]: [ loginToken ] } } + where: { login_tokens: { [Op.contains]: [loginToken] } } }) } catch (err) { logger.error(err) diff --git a/app/resources/v1/users_streets_pg.js b/app/resources/v1/users_streets_pg.js index ca1ee815c9..e4be1b7f29 100644 --- a/app/resources/v1/users_streets_pg.js +++ b/app/resources/v1/users_streets_pg.js @@ -16,7 +16,7 @@ exports.get = async function (req, res) { model: User, where: { creator_id: userId } }], - order: [ ['updated_at', 'DESC'] ] + order: [['updated_at', 'DESC']] }) } catch (err) { logger.error(err) diff --git a/assets/scripts/app/DebugInfo.jsx b/assets/scripts/app/DebugInfo.jsx index bc9b189cf9..9fcfd17c8a 100644 --- a/assets/scripts/app/DebugInfo.jsx +++ b/assets/scripts/app/DebugInfo.jsx @@ -48,22 +48,22 @@ export class DebugInfo extends React.Component { const debugUndo = cloneDeep(this.props.undo) // Some things just shouldn't be seen... - for (let i in debugStreetData.segments) { + for (const i in debugStreetData.segments) { delete debugStreetData.segments[i].el } - for (let j in debugUndo) { - for (let k in debugUndo[j].segments) { + for (const j in debugUndo) { + for (const k in debugUndo[j].segments) { delete debugUndo[j].segments[k].el } } // Create a JSON object, this parses better in editors const debugObj = { - 'DATA': debugStreetData, - 'SETTINGS': this.props.settings, - 'FLAGS': this.props.flags, - 'UNDO': debugUndo + DATA: debugStreetData, + SETTINGS: this.props.settings, + FLAGS: this.props.flags, + UNDO: debugUndo } return JSON.stringify(debugObj, null, 2) diff --git a/assets/scripts/app/SkyBackground.jsx b/assets/scripts/app/SkyBackground.jsx index 1412ca4399..6b77a6a679 100644 --- a/assets/scripts/app/SkyBackground.jsx +++ b/assets/scripts/app/SkyBackground.jsx @@ -74,7 +74,7 @@ export class SkyBackground extends React.PureComponent { opacity: environs.cloudOpacity || null } - let foregroundStyle = {} + const foregroundStyle = {} if (environs.foregroundGradient) { foregroundStyle.backgroundImage = makeCSSGradientDeclaration(environs.foregroundGradient) foregroundStyle.opacity = 1 diff --git a/assets/scripts/app/StreetView.jsx b/assets/scripts/app/StreetView.jsx index befe07322e..d6b5857e31 100644 --- a/assets/scripts/app/StreetView.jsx +++ b/assets/scripts/app/StreetView.jsx @@ -138,7 +138,7 @@ class StreetView extends React.Component { onResize = () => { const { viewportWidth, viewportHeight } = this.props.system let streetSectionTop - let streetSectionHeight = this.streetSectionInner.offsetHeight + const streetSectionHeight = this.streetSectionInner.offsetHeight if (viewportHeight - streetSectionHeight > 450) { streetSectionTop = ((viewportHeight - streetSectionHeight - 450) / 2) + 450 + 80 @@ -150,7 +150,7 @@ class StreetView extends React.Component { streetSectionTop += 80 } - let scrollTop = (streetSectionTop + streetSectionHeight) + const scrollTop = (streetSectionTop + streetSectionHeight) // Not sure what 255 does, but it keeps it from getting too tall // `skyHeight` is needed so that when gallery opens and the diff --git a/assets/scripts/app/WelcomePanel/NewStreet.jsx b/assets/scripts/app/WelcomePanel/NewStreet.jsx index ced074992b..219700618e 100644 --- a/assets/scripts/app/WelcomePanel/NewStreet.jsx +++ b/assets/scripts/app/WelcomePanel/NewStreet.jsx @@ -35,7 +35,7 @@ function NewStreet (props) { break } - const [ state, setState ] = useState({ selectedNewStreetType }) + const [state, setState] = useState({ selectedNewStreetType }) // Handles changing the "checked" state of the input buttons. function onChangeNewStreetType (event) { diff --git a/assets/scripts/app/event_tracking.js b/assets/scripts/app/event_tracking.js index 832f705975..5ab9aff603 100644 --- a/assets/scripts/app/event_tracking.js +++ b/assets/scripts/app/event_tracking.js @@ -2,7 +2,7 @@ // Contains identifiers for actions that should only be tracked // once per user session, as defined by the boolean value of // onlyFirstTime passed to eventTracking.track() -let alreadyTracked = [] +const alreadyTracked = [] // These constants define what are valid actions, labels and categories for Streetmix. // They're stored as strings so that they can be passed around instead of needing to @@ -12,35 +12,35 @@ let alreadyTracked = [] // constants to define action types. // Strings are not namespaced to keep trackEvent() calls shorter. const TRACK_CATEGORY = { - 'INTERACTION': 'Interaction', - 'EVENT': 'Event', - 'ERROR': 'Error', - 'SYSTEM': 'System', - 'SHARING': 'Sharing' + INTERACTION: 'Interaction', + EVENT: 'Event', + ERROR: 'Error', + SYSTEM: 'System', + SHARING: 'Sharing' } const TRACK_ACTION = { - 'TOUCH_CAPABLE': 'Touch capability detected', - 'OPEN_GALLERY': 'Open gallery', - 'UNDO': 'Undo', - 'CHANGE_WIDTH': 'Change width', - 'REMOVE_SEGMENT': 'Remove segment', - 'LEARN_MORE': 'Learn more about segment', - 'FACEBOOK': 'Facebook', - 'TWITTER': 'Twitter', - 'ERROR_15A': 'Error 15A (sign in API failure)', - 'ERROR_RM1': 'Error RM1 (auth 401 failure on load)', - 'ERROR_RM2': 'Error RM2 (auth 401 failure mid-flight)', - 'ERROR_GEOLOCATION_TIMEOUT': 'Geolocation timeout', - 'STREET_MODIFIED_ELSEWHERE': 'Street modified elsewhere' + TOUCH_CAPABLE: 'Touch capability detected', + OPEN_GALLERY: 'Open gallery', + UNDO: 'Undo', + CHANGE_WIDTH: 'Change width', + REMOVE_SEGMENT: 'Remove segment', + LEARN_MORE: 'Learn more about segment', + FACEBOOK: 'Facebook', + TWITTER: 'Twitter', + ERROR_15A: 'Error 15A (sign in API failure)', + ERROR_RM1: 'Error RM1 (auth 401 failure on load)', + ERROR_RM2: 'Error RM2 (auth 401 failure mid-flight)', + ERROR_GEOLOCATION_TIMEOUT: 'Geolocation timeout', + STREET_MODIFIED_ELSEWHERE: 'Street modified elsewhere' } const TRACK_LABEL = { - 'BUTTON': 'Button', - 'DRAGGING': 'Dragging', - 'INPUT_FIELD': 'Input field', - 'INCREMENT_BUTTON': 'Increment button', - 'KEYBOARD': 'Keyboard' + BUTTON: 'Button', + DRAGGING: 'Dragging', + INPUT_FIELD: 'Input field', + INCREMENT_BUTTON: 'Increment button', + KEYBOARD: 'Keyboard' } /** diff --git a/assets/scripts/app/flag_utils.js b/assets/scripts/app/flag_utils.js index e8211a4044..d9b7915e23 100644 --- a/assets/scripts/app/flag_utils.js +++ b/assets/scripts/app/flag_utils.js @@ -3,9 +3,9 @@ import store, { observeStore } from '../store' import { setFlagOverrides } from '../store/actions/flags' export const PRIORITY_LEVELS = { - 'initial': 0, - 'user': 1, - 'session': 2 + initial: 0, + user: 1, + session: 2 } export function initializeFlagSubscribers () { diff --git a/assets/scripts/app/initialization.js b/assets/scripts/app/initialization.js index 7ed2936a77..fd72b34a5a 100644 --- a/assets/scripts/app/initialization.js +++ b/assets/scripts/app/initialization.js @@ -84,7 +84,7 @@ export async function initialize () { const geo = await detectGeolocation() // Parallel tasks - await Promise.all([ loadImages(), geo, initLocale() ]) + await Promise.all([loadImages(), geo, initLocale()]) if (geo && geo.country_code) { updateSettingsFromCountryCode(geo.country_code) diff --git a/assets/scripts/app/keypress.js b/assets/scripts/app/keypress.js index 7f3cac370b..3d54cd27c0 100644 --- a/assets/scripts/app/keypress.js +++ b/assets/scripts/app/keypress.js @@ -18,48 +18,48 @@ import { isFocusOnBody } from '../util/focus' // TODO: Flesh out this dictionary const KEYS = { - 'left': 37, - 'right': 39, - 'enter': 13, - 'backspace': 8, - 'delete': 46, - 'esc': 27, - '0': 48, - '1': 49, - '2': 50, - '3': 51, - '4': 52, - '5': 53, - '6': 54, - '7': 55, - '8': 56, - '9': 57, - 'a': 65, - 'b': 66, - 'c': 67, - 'd': 68, - 'e': 69, - 'f': 70, - 'g': 71, - 'h': 72, - 'i': 73, - 'j': 74, - 'k': 75, - 'l': 76, - 'm': 77, - 'n': 78, - 'o': 79, - 'p': 80, - 'q': 81, - 'r': 82, - 's': 83, - 't': 84, - 'u': 85, - 'v': 86, - 'w': 87, - 'x': 88, - 'y': 89, - 'z': 90, + left: 37, + right: 39, + enter: 13, + backspace: 8, + delete: 46, + esc: 27, + 0: 48, + 1: 49, + 2: 50, + 3: 51, + 4: 52, + 5: 53, + 6: 54, + 7: 55, + 8: 56, + 9: 57, + a: 65, + b: 66, + c: 67, + d: 68, + e: 69, + f: 70, + g: 71, + h: 72, + i: 73, + j: 74, + k: 75, + l: 76, + m: 77, + n: 78, + o: 79, + p: 80, + q: 81, + r: 82, + s: 83, + t: 84, + u: 85, + v: 86, + w: 87, + x: 88, + y: 89, + z: 90, // '=': [187, 61], '+': [187, 61, 107], // = or +; 61 for Firefox; 107 for keypad '-': [189, 173, 109], // 109 for keypad; 173 for Firefox @@ -68,7 +68,7 @@ const KEYS = { } // Keep track of all registered commands here -let inputs = {} +const inputs = {} // Utility functions const noop = function () {} @@ -197,12 +197,12 @@ export function registerKeypress (commands, options, callback) { const commandObj = processCommands(commands) // Process each command input - for (let keyCode in commandObj) { - let commands = commandObj[keyCode] + for (const keyCode in commandObj) { + const commands = commandObj[keyCode] - for (let command of commands) { + for (const command of commands) { // Get default settings - for (let key in defaults) { + for (const key in defaults) { if (typeof command[key] === 'undefined') { command[key] = defaults[key] } @@ -227,7 +227,7 @@ export function registerKeypress (commands, options, callback) { // This basically allows other code to override settings via the // options object - it's dumb, but there's no protection against it, // and who knows, could be useful in edge cases - for (let k in options) { + for (const k in options) { command[k] = options[k] } @@ -264,16 +264,16 @@ export function deregisterKeypress (commands, callback) { const commandObj = processCommands(commands) // Process each command input - for (let keyCode in commandObj) { + for (const keyCode in commandObj) { const commands = commandObj[keyCode] - for (let command of commands) { - let items = inputs[keyCode] + for (const command of commands) { + const items = inputs[keyCode] let x = items.length // A reverse while loop quickly removes all duplicates that matches while (x--) { - let item = items[x] + const item = items[x] if (item.onKeypress === callback || typeof callback === 'undefined') { // Check for equality for command + function if ((item.shiftKey === command.shiftKey || item.shiftKey === 'optional') && @@ -304,7 +304,7 @@ function processCommands (commands) { commands = new Array(commands) } - let commandsObj = {} + const commandsObj = {} // Process each command input for (let command of commands) { @@ -315,7 +315,7 @@ function processCommands (commands) { .replace(/(command|cmd|control|ctrl)/g, 'meta') .split(' ') - let settings = { + const settings = { shiftKey: false, altKey: false, metaKey: false @@ -323,19 +323,19 @@ function processCommands (commands) { // Check for existence of modifier keys // Modifier keys are removed from input array - let isShift = command.indexOf('shift') + const isShift = command.indexOf('shift') if (isShift > -1) { settings.shiftKey = true command.splice(isShift, 1) } - let isAlt = command.indexOf('alt') + const isAlt = command.indexOf('alt') if (isAlt > -1) { settings.altKey = true command.splice(isAlt, 1) } - let isMeta = command.indexOf('meta') + const isMeta = command.indexOf('meta') if (isMeta > -1) { settings.metaKey = true command.splice(isMeta, 1) @@ -343,7 +343,7 @@ function processCommands (commands) { // First remaining item in the input array is the key code to test for. // Does not support multi-keys, so rest of input (if provided) is ignored. - let keyCode = KEYS[command[0]] + const keyCode = KEYS[command[0]] // Keycodes might be a single number or an array if (keyCode) { @@ -356,7 +356,7 @@ function processCommands (commands) { keys = keyCode } - for (let key of keys) { + for (const key of keys) { settings.keyCode = key if (typeof commandsObj[key] === 'undefined') { commandsObj[key] = [] @@ -371,14 +371,14 @@ function processCommands (commands) { } function onGlobalKeyDown (event) { - let toExecute = [] + const toExecute = [] // Find the right command object const commandsForKeyCode = inputs[event.keyCode] if (!commandsForKeyCode || commandsForKeyCode.length === 0) return // Check if the right meta keys are down - for (let item of commandsForKeyCode) { + for (const item of commandsForKeyCode) { if ((item.shiftKey === event.shiftKey || item.shiftKey === 'optional') && (item.altKey === event.altKey || item.altKey === 'optional') && (item.metaKey === event.metaKey || item.metaKey === event.ctrlKey || item.metaKey === 'optional')) { @@ -387,7 +387,7 @@ function onGlobalKeyDown (event) { } // Execute input's callbacks, if found - for (let input of toExecute) { + for (const input of toExecute) { execute(input, event) } } diff --git a/assets/scripts/app/load_resources.js b/assets/scripts/app/load_resources.js index 9512d2659a..cf21f5de24 100644 --- a/assets/scripts/app/load_resources.js +++ b/assets/scripts/app/load_resources.js @@ -23,10 +23,10 @@ const IMAGES_TO_BE_LOADED = [ ] const SVGStagingEl = document.getElementById('svg') -let loading = [] +const loading = [] export async function loadImages () { - for (let url of IMAGES_TO_BE_LOADED) { + for (const url of IMAGES_TO_BE_LOADED) { loading.push(loadImage(url)) } @@ -48,9 +48,9 @@ async function loadImage (url) { // later rendering to canvas // Get all the s - let symbolEls = SVGStagingEl.querySelectorAll('symbol') + const symbolEls = SVGStagingEl.querySelectorAll('symbol') - for (let svg of symbolEls) { + for (const svg of symbolEls) { // Skip icons, we don't need to cache these if (svg.id.indexOf('icon-') === 0) continue @@ -65,9 +65,9 @@ async function loadImage (url) { // Captures anything with its own viewbox, whether that's an svg file // or symbol elements within a svg. - let svgEls = SVGStagingEl.querySelectorAll('svg[viewBox]') + const svgEls = SVGStagingEl.querySelectorAll('svg[viewBox]') - for (let svg of svgEls) { + for (const svg of svgEls) { // Right now none of these have ids, use the url const id = url diff --git a/assets/scripts/dialogs/About/Credits.jsx b/assets/scripts/dialogs/About/Credits.jsx index 4944076798..7687062f55 100644 --- a/assets/scripts/dialogs/About/Credits.jsx +++ b/assets/scripts/dialogs/About/Credits.jsx @@ -33,24 +33,24 @@ function alphabetizeNames (a, b) { // because right now we don't have a way to fall back when a label is untranslated. // We can remove this once this has been built into our localization infrastructure. const UNTRANSLATED_LABELS = { - 'advisors': 'Advisors', + advisors: 'Advisors', 'additional-illustrations': 'Additional illustrations', 'additional-code': 'Additional code', 'additional-contributors': 'Additional contributors', 'special-thanks': 'Special thanks to', - 'ar': 'Arabic', - 'de': 'German', - 'en': 'English', - 'es': 'Spanish', + ar: 'Arabic', + de: 'German', + en: 'English', + es: 'Spanish', 'es-mx': 'Spanish (Mexico)', - 'fi': 'Finnish', - 'fr': 'French', - 'ja': 'Japanese', - 'pl': 'Polish', + fi: 'Finnish', + fr: 'French', + ja: 'Japanese', + pl: 'Polish', 'pt-br': 'Portuguese (Brazil)', - 'ru': 'Russian', - 'sv': 'Swedish', - 'zh': 'Chinese' + ru: 'Russian', + sv: 'Swedish', + zh: 'Chinese' } function Credits (props) { diff --git a/assets/scripts/dialogs/AnalyticsDialog.jsx b/assets/scripts/dialogs/AnalyticsDialog.jsx index 99633afdac..05561647e0 100644 --- a/assets/scripts/dialogs/AnalyticsDialog.jsx +++ b/assets/scripts/dialogs/AnalyticsDialog.jsx @@ -17,12 +17,12 @@ import './AnalyticsDialog.scss' const NO_CAPACITY = { average: 0, potential: 0 } const CAPACITIES = { - 'sidewalk': { average: 19000, potential: 19000 }, + sidewalk: { average: 19000, potential: 19000 }, 'drive-lane': { average: 1500, potential: 2000 }, 'bike-lane': { average: 14000, potential: 14000 }, - 'scooter': { average: 14000, potential: 14000 }, + scooter: { average: 14000, potential: 14000 }, 'light-rail': { average: 18000, potential: 20000 }, - 'streetcar': { average: 18000, potential: 20000 }, + streetcar: { average: 18000, potential: 20000 }, 'bus-lane': { average: 5000, potential: 8000 } } diff --git a/assets/scripts/dialogs/NewsletterDialog.jsx b/assets/scripts/dialogs/NewsletterDialog.jsx index cedb939783..11e249b83d 100644 --- a/assets/scripts/dialogs/NewsletterDialog.jsx +++ b/assets/scripts/dialogs/NewsletterDialog.jsx @@ -11,7 +11,7 @@ const NewsletterDialog = (props) => { const closeDialogFunc = useRef(() => {}) const subscribeButton = useRef(null) useEffect(() => { - let handler = closeDialogFunc.current + const handler = closeDialogFunc.current subscribeButton.current = document.querySelector('#mc-embedded-subscribe') if (subscribeButton.current) { subscribeButton.current.addEventListener('click', handler) diff --git a/assets/scripts/gallery/fetch_data.js b/assets/scripts/gallery/fetch_data.js index 95e1862d4d..5cb4b5249d 100644 --- a/assets/scripts/gallery/fetch_data.js +++ b/assets/scripts/gallery/fetch_data.js @@ -13,7 +13,7 @@ export function fetchGalleryData () { if (galleryUserId) { const url = API_URL + 'v1/users/' + galleryUserId + '/streets' const options = { - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } } window.fetch(url, options) diff --git a/assets/scripts/gallery/fetch_street.js b/assets/scripts/gallery/fetch_street.js index 37a2b98a21..4b231c2942 100644 --- a/assets/scripts/gallery/fetch_street.js +++ b/assets/scripts/gallery/fetch_street.js @@ -21,7 +21,7 @@ export function fetchGalleryStreet (streetId) { const url = API_URL + 'v1/streets/' + streetId const options = { - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } } window.fetch(url, options) diff --git a/assets/scripts/gallery/thumbnail.js b/assets/scripts/gallery/thumbnail.js index 03174eda50..1b9b9b886b 100644 --- a/assets/scripts/gallery/thumbnail.js +++ b/assets/scripts/gallery/thumbnail.js @@ -139,7 +139,7 @@ function drawBackgroundGradient (ctx, dpi, width, height, backgroundGradient) { // Make color stops const stops = makeCanvasGradientStopArray(backgroundGradient) for (let i = 0; i < stops.length; i++) { - const [ color, stop ] = stops[i] + const [color, stop] = stops[i] gradient.addColorStop(stop, color) } @@ -235,7 +235,7 @@ export function drawStreetThumbnail (ctx, street, thumbnailWidth, thumbnailHeigh // Determine how wide the street is let occupiedWidth = 0 - for (let segment of street.segments) { + for (const segment of street.segments) { occupiedWidth += segment.width } @@ -325,7 +325,7 @@ export function drawStreetThumbnail (ctx, street, thumbnailWidth, thumbnailHeigh // Collect z-indexes const zIndexes = [] - for (let segment of street.segments) { + for (const segment of street.segments) { const segmentInfo = getSegmentInfo(segment.type) if (zIndexes.indexOf(segmentInfo.zIndex) === -1) { @@ -334,10 +334,10 @@ export function drawStreetThumbnail (ctx, street, thumbnailWidth, thumbnailHeigh } // Render objects at each z-index level - for (let zIndex of zIndexes) { + for (const zIndex of zIndexes) { let offsetLeft = originalOffsetLeft - for (let segment of street.segments) { + for (const segment of street.segments) { const segmentInfo = getSegmentInfo(segment.type) if (segmentInfo.zIndex === zIndex) { @@ -373,7 +373,7 @@ export function drawStreetThumbnail (ctx, street, thumbnailWidth, thumbnailHeigh ctx.textAlign = 'center' ctx.textBaseline = 'top' - for (let i in street.segments) { + for (const i in street.segments) { const segment = street.segments[i] const availableWidth = segment.width * TILE_SIZE * multiplier diff --git a/assets/scripts/info_bubble/DescriptionPanel.jsx b/assets/scripts/info_bubble/DescriptionPanel.jsx index 53b600c716..83c747023d 100644 --- a/assets/scripts/info_bubble/DescriptionPanel.jsx +++ b/assets/scripts/info_bubble/DescriptionPanel.jsx @@ -75,7 +75,7 @@ export default class DescriptionPanel extends React.Component { retargetAnchors = () => { if (!this.text) return const links = this.text.querySelectorAll('a') - for (let link of links) { + for (const link of links) { link.target = '_blank' link.rel = 'noopener noreferrer' } diff --git a/assets/scripts/info_bubble/EditableLabel.jsx b/assets/scripts/info_bubble/EditableLabel.jsx index 2afaf6b1f5..6b88a7bc85 100644 --- a/assets/scripts/info_bubble/EditableLabel.jsx +++ b/assets/scripts/info_bubble/EditableLabel.jsx @@ -51,7 +51,7 @@ EditableLabel.propTypes = { segment: PropTypes.object, position: PropTypes.oneOfType([ PropTypes.number, - PropTypes.oneOf([ 'left', 'right' ]) + PropTypes.oneOf(['left', 'right']) ]), // Provided by Redux mapStateToProps diff --git a/assets/scripts/info_bubble/Variants.jsx b/assets/scripts/info_bubble/Variants.jsx index 0f24582138..0b0c72ad0d 100644 --- a/assets/scripts/info_bubble/Variants.jsx +++ b/assets/scripts/info_bubble/Variants.jsx @@ -155,7 +155,7 @@ export class Variants extends React.Component { let first = true // Each segment has some allowed variant sets (e.g. "direction") - for (let variant in this.state.variantSets) { + for (const variant in this.state.variantSets) { const set = this.state.variantSets[variant] // New row for each variant set @@ -171,7 +171,7 @@ export class Variants extends React.Component { // each of the selections are and data for building an icon. // Different segments may refer to the same variant set // ("direction" is a good example of this) - for (let selection in VARIANT_ICONS[set]) { + for (const selection in VARIANT_ICONS[set]) { const el = this.renderButton(set, selection) variantEls.push(el) diff --git a/assets/scripts/info_bubble/__tests__/Variants.test.js b/assets/scripts/info_bubble/__tests__/Variants.test.js index f8b048beaa..0cf15b486c 100644 --- a/assets/scripts/info_bubble/__tests__/Variants.test.js +++ b/assets/scripts/info_bubble/__tests__/Variants.test.js @@ -102,7 +102,7 @@ describe('Variants', () => { const type = INFO_BUBBLE_TYPE_SEGMENT const streetSegment = { variantString: 'inbound|regular', segmentType: 'streetcar' } - const flags = { 'flag': { value: 't' } } + const flags = { flag: { value: 't' } } it('renders with flag correctly', () => { const wrapper = shallow() diff --git a/assets/scripts/info_bubble/__tests__/Warnings.test.js b/assets/scripts/info_bubble/__tests__/Warnings.test.js index 0f5696b2dd..c75e76ef77 100644 --- a/assets/scripts/info_bubble/__tests__/Warnings.test.js +++ b/assets/scripts/info_bubble/__tests__/Warnings.test.js @@ -14,7 +14,7 @@ describe('Warnings', () => { it('renders warning 1', () => { const segment = { - warnings: [ null, true ] + warnings: [null, true] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() @@ -22,7 +22,7 @@ describe('Warnings', () => { it('renders warning 2', () => { const segment = { - warnings: [ null, false, true, false ] + warnings: [null, false, true, false] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() @@ -30,7 +30,7 @@ describe('Warnings', () => { it('renders warning 3', () => { const segment = { - warnings: [ null, false, false, true ] + warnings: [null, false, false, true] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() @@ -38,7 +38,7 @@ describe('Warnings', () => { it('renders two warnings', () => { const segment = { - warnings: [ null, true, false, true ] + warnings: [null, true, false, true] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() @@ -46,7 +46,7 @@ describe('Warnings', () => { it('renders three warnings', () => { const segment = { - warnings: [ null, true, true, true ] + warnings: [null, true, true, true] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() @@ -54,7 +54,7 @@ describe('Warnings', () => { it('renders no warnings', () => { const segment = { - warnings: [ null, false, false, false ] + warnings: [null, false, false, false] } const wrapper = shallow() expect(wrapper).toMatchSnapshot() diff --git a/assets/scripts/segments/Building.jsx b/assets/scripts/segments/Building.jsx index 5746953f64..9ad832d366 100644 --- a/assets/scripts/segments/Building.jsx +++ b/assets/scripts/segments/Building.jsx @@ -164,7 +164,7 @@ class Building extends React.Component { // editCount, rightBuildingVariant (or leftBuildingVariant), and updatedAt shouldBuildingAnimate = (oldStreet, newStreet) => { let userUpdated = true - for (let key in newStreet) { + for (const key in newStreet) { if (oldStreet[key] !== newStreet[key]) { userUpdated = ['editCount', this.state.variant, 'updatedAt'].includes(key) if (!userUpdated) return false diff --git a/assets/scripts/segments/__tests__/segment-dict.test.js b/assets/scripts/segments/__tests__/segment-dict.test.js index 996d0b3161..479a03c934 100644 --- a/assets/scripts/segments/__tests__/segment-dict.test.js +++ b/assets/scripts/segments/__tests__/segment-dict.test.js @@ -41,21 +41,21 @@ describe('getSegmentComponentInfo()', () => { describe('applySegmentInfoOverridesAndRules()', () => { it('returns rules and information for a segment type and variant', () => { - const segmentRules = { 'minWidth': 0, 'maxWidth': 2 } + const segmentRules = { minWidth: 0, maxWidth: 2 } const details = { - 'name': 'Bar', - 'nameKey': 'bar', - 'rules': { - 'minWidth': 1 + name: 'Bar', + nameKey: 'bar', + rules: { + minWidth: 1 } } const variantInfo = applySegmentInfoOverridesAndRules(details, segmentRules) expect(variantInfo).toEqual({ - 'name': 'Bar', - 'nameKey': 'bar', - 'minWidth': 1, - 'maxWidth': 2 + name: 'Bar', + nameKey: 'bar', + minWidth: 1, + maxWidth: 2 }) }) }) diff --git a/assets/scripts/segments/__tests__/variant_utils.test.js b/assets/scripts/segments/__tests__/variant_utils.test.js index 7eb1e47f54..e6d3a08ad8 100644 --- a/assets/scripts/segments/__tests__/variant_utils.test.js +++ b/assets/scripts/segments/__tests__/variant_utils.test.js @@ -4,7 +4,7 @@ import { getVariantArray, getVariantString } from '../variant_utils' describe('getVariantArray', () => { it('returns an object', () => { const result = getVariantArray('streetcar', 'inbound|regular') - expect(result).toEqual({ 'direction': 'inbound', 'public-transit-asphalt': 'regular' }) + expect(result).toEqual({ direction: 'inbound', 'public-transit-asphalt': 'regular' }) }) it('returns an empty object if the segment is not found', () => { @@ -15,7 +15,7 @@ describe('getVariantArray', () => { describe('getVariantString', () => { it('returns a string', () => { - const obj = { 'direction': 'inbound', 'public-transit-asphalt': 'regular' } + const obj = { direction: 'inbound', 'public-transit-asphalt': 'regular' } const result = getVariantString(obj) expect(result).toEqual('inbound|regular') }) diff --git a/assets/scripts/segments/buildings.js b/assets/scripts/segments/buildings.js index e8870d7f5c..13c40e090b 100644 --- a/assets/scripts/segments/buildings.js +++ b/assets/scripts/segments/buildings.js @@ -38,14 +38,14 @@ export const GROUND_BASELINE_HEIGHT = 44 * overhangWidth (number) in ??, amount to overhang the sidewalk (adjusts OVERHANG_WIDTH) */ export const BUILDINGS = { - 'grass': { + grass: { id: 'grass', label: 'Grass', spriteId: 'buildings--grass', hasFloors: false, sameOnBothSides: true }, - 'fence': { + fence: { id: 'fence', label: 'Empty lot', spriteId: 'buildings--fenced-lot', @@ -58,7 +58,7 @@ export const BUILDINGS = { hasFloors: false, repeatHalf: true }, - 'waterfront': { + waterfront: { id: 'waterfront', label: 'Waterfront', spriteId: 'buildings--waterfront', @@ -66,7 +66,7 @@ export const BUILDINGS = { alignAtBaseline: true, repeatHalf: true }, - 'residential': { + residential: { id: 'residential', label: 'Home', spriteId: 'buildings--residential', @@ -76,7 +76,7 @@ export const BUILDINGS = { roofHeight: 6, mainFloorHeight: 24.5 }, - 'narrow': { + narrow: { id: 'narrow', label: 'Building', spriteId: 'buildings--apartments-narrow', @@ -87,7 +87,7 @@ export const BUILDINGS = { mainFloorHeight: 14, overhangWidth: 16 }, - 'wide': { + wide: { id: 'wide', label: 'Building', spriteId: 'buildings--apartments-wide', diff --git a/assets/scripts/segments/default.js b/assets/scripts/segments/default.js index 8894264458..93f005ff28 100644 --- a/assets/scripts/segments/default.js +++ b/assets/scripts/segments/default.js @@ -1,33 +1,33 @@ export const DEFAULT_SEGMENTS = { - 'false': [ // Right-hand traffic + false: [ // Right-hand traffic { type: 'sidewalk', variant: { 'sidewalk-density': 'dense' }, width: 6 }, { type: 'sidewalk-tree', variant: { 'tree-type': 'big' }, width: 2 }, - { type: 'transit-shelter', variant: { 'orientation': 'left', 'transit-shelter-elevation': 'street-level' }, width: 9 }, + { type: 'transit-shelter', variant: { orientation: 'left', 'transit-shelter-elevation': 'street-level' }, width: 9 }, { type: 'sidewalk-lamp', variant: { 'lamp-orientation': 'right', 'lamp-type': 'modern' }, width: 2 }, - { type: 'bus-lane', variant: { 'direction': 'inbound', 'bus-asphalt': 'shared' }, width: 12 }, - { type: 'drive-lane', variant: { 'direction': 'inbound', 'car-type': 'car' }, width: 9 }, + { type: 'bus-lane', variant: { direction: 'inbound', 'bus-asphalt': 'shared' }, width: 12 }, + { type: 'drive-lane', variant: { direction: 'inbound', 'car-type': 'car' }, width: 9 }, { type: 'divider', variant: { 'divider-type': 'bush' }, width: 3 }, - { type: 'turn-lane', variant: { 'direction': 'outbound', 'turn-lane-orientation': 'left-straight' }, width: 10 }, + { type: 'turn-lane', variant: { direction: 'outbound', 'turn-lane-orientation': 'left-straight' }, width: 10 }, { type: 'parking-lane', variant: { 'parking-lane-direction': 'outbound', 'parking-lane-orientation': 'right' }, width: 7 }, { type: 'divider', variant: { 'divider-type': 'planter-box' }, width: 4 }, - { type: 'bike-lane', variant: { 'direction': 'outbound', 'bike-asphalt': 'green' }, width: 6 }, + { type: 'bike-lane', variant: { direction: 'outbound', 'bike-asphalt': 'green' }, width: 6 }, { type: 'sidewalk-lamp', variant: { 'lamp-orientation': 'left', 'lamp-type': 'modern' }, width: 2 }, { type: 'sidewalk-tree', variant: { 'tree-type': 'big' }, width: 2 }, { type: 'sidewalk', variant: { 'sidewalk-density': 'normal' }, width: 6 } ], - 'true': [ // Left-hand traffic + true: [ // Left-hand traffic { type: 'sidewalk', variant: { 'sidewalk-density': 'normal' }, width: 6 }, { type: 'sidewalk-tree', variant: { 'tree-type': 'big' }, width: 2 }, { type: 'sidewalk-lamp', variant: { 'lamp-orientation': 'right', 'lamp-type': 'modern' }, width: 2 }, - { type: 'bike-lane', variant: { 'direction': 'outbound', 'bike-asphalt': 'green' }, width: 6 }, + { type: 'bike-lane', variant: { direction: 'outbound', 'bike-asphalt': 'green' }, width: 6 }, { type: 'divider', variant: { 'divider-type': 'planter-box' }, width: 4 }, { type: 'parking-lane', variant: { 'parking-lane-direction': 'outbound', 'parking-lane-orientation': 'left' }, width: 7 }, - { type: 'turn-lane', variant: { 'direction': 'outbound', 'turn-lane-orientation': 'right-straight' }, width: 10 }, + { type: 'turn-lane', variant: { direction: 'outbound', 'turn-lane-orientation': 'right-straight' }, width: 10 }, { type: 'divider', variant: { 'divider-type': 'bush' }, width: 3 }, - { type: 'drive-lane', variant: { 'direction': 'inbound', 'car-type': 'car' }, width: 9 }, - { type: 'bus-lane', variant: { 'direction': 'inbound', 'bus-asphalt': 'shared' }, width: 12 }, + { type: 'drive-lane', variant: { direction: 'inbound', 'car-type': 'car' }, width: 9 }, + { type: 'bus-lane', variant: { direction: 'inbound', 'bus-asphalt': 'shared' }, width: 12 }, { type: 'sidewalk-lamp', variant: { 'lamp-orientation': 'left', 'lamp-type': 'modern' }, width: 2 }, - { type: 'transit-shelter', variant: { 'orientation': 'right', 'transit-shelter-elevation': 'street-level' }, width: 9 }, + { type: 'transit-shelter', variant: { orientation: 'right', 'transit-shelter-elevation': 'street-level' }, width: 9 }, { type: 'sidewalk-tree', variant: { 'tree-type': 'big' }, width: 2 }, { type: 'sidewalk', variant: { 'sidewalk-density': 'dense' }, width: 6 } ] diff --git a/assets/scripts/segments/info.js b/assets/scripts/segments/info.js index 053a01abe9..5fd188ff53 100644 --- a/assets/scripts/segments/info.js +++ b/assets/scripts/segments/info.js @@ -101,8 +101,7 @@ const SPRITE_DEFS = { 'lamps--lamp-traditional-left': { id: 'lamps--lamp-traditional-left', offsetX: -36 }, 'lamps--pride-banner-right': { id: 'lamps--pride-banner-right', offsetX: -60, originY: -423 }, 'lamps--pride-banner-left': { id: 'lamps--pride-banner-left', offsetX: -60, originY: -423 }, - - 'missing': { id: 'missing' }, + missing: { id: 'missing' }, 'people--people-01': { id: 'people--people-01', originY: 10 }, 'people--people-02': { id: 'people--people-02', originY: 10 }, diff --git a/assets/scripts/segments/people.js b/assets/scripts/segments/people.js index 81089c6f20..1d7520f6f8 100644 --- a/assets/scripts/segments/people.js +++ b/assets/scripts/segments/people.js @@ -9,7 +9,7 @@ import PEOPLE from './people.json' // TODO magic number - randSeed defaults to 35: why? export function drawProgrammaticPeople (ctx, width, offsetLeft, groundLevel, randSeed = 35, multiplier, variantString, dpi) { - let people = [] + const people = [] let peopleWidth = 0 // Depending on the type of sidewalk, we would have different densities of people. @@ -73,7 +73,7 @@ export function drawProgrammaticPeople (ctx, width, offsetLeft, groundLevel, ran startLeft += (firstPersonCorrection + lastPersonCorrection) / 2 } - for (let person of people) { + for (const person of people) { // Change person.id to 1-index instead of 0-index, // convert to string & zero-pad to two digits const type = ('0' + (person.id + 1).toString()).slice(-2) diff --git a/assets/scripts/segments/segment-dict.js b/assets/scripts/segments/segment-dict.js index c6eacc50d6..aac1752bf3 100644 --- a/assets/scripts/segments/segment-dict.js +++ b/assets/scripts/segments/segment-dict.js @@ -89,7 +89,7 @@ function getComponentGroupVariants (groupItems, componentGroupInfo) { // variantInfo - graphics definition for specific variants defined by group item let variantInfo = groupItemVariants[variantName] || SEGMENT_UNKNOWN_VARIANT - const variantKeys = Array.isArray(variantKey) ? variantKey : [ variantKey ] + const variantKeys = Array.isArray(variantKey) ? variantKey : [variantKey] variantKeys.forEach((key) => { variantInfo = (variantInfo && variantInfo[key]) || SEGMENT_UNKNOWN_VARIANT }) @@ -183,7 +183,7 @@ const gatherAnalytics = (componentArray, mapSection) => { // serves up complete analytics data the a set of component variants that make up a segment export function getSegmentAnalytics ({ objects, lanes, vehicles, markings }) { // 1) Loop through each component group that makes up the segment. - let analytics = {} + const analytics = {} analytics.vehicles = gatherAnalytics(vehicles, 'vehicles') analytics.objects = gatherAnalytics(objects, 'objects') analytics.lanes = gatherAnalytics(lanes, 'lanes') @@ -203,7 +203,7 @@ export function getSegmentAnalytics ({ objects, lanes, vehicles, markings }) { export function getSegmentSprites (components) { // 1) Loop through each component group that makes up the segment. const sprites = Object.entries(components).reduce((graphicsArray, componentGroup) => { - const [ group, groupItems ] = componentGroup + const [group, groupItems] = componentGroup // 2) For each component group, look up the segment information for every item that makes up the component group. // componentGroupInfo = [ { characteristics, rules, variants } ] diff --git a/assets/scripts/segments/variant_utils.js b/assets/scripts/segments/variant_utils.js index a1d5848b3d..f08d0ce46d 100644 --- a/assets/scripts/segments/variant_utils.js +++ b/assets/scripts/segments/variant_utils.js @@ -23,7 +23,7 @@ export function getVariantArray (segmentType, variantString) { const segment = getSegmentInfo(segmentType) if (segment && segment.variants) { - for (let i in segment.variants) { + for (const i in segment.variants) { const variantName = segment.variants[i] variantArray[variantName] = variantSplit[i] } diff --git a/assets/scripts/store/index.js b/assets/scripts/store/index.js index 8a4abe4553..604691d85b 100644 --- a/assets/scripts/store/index.js +++ b/assets/scripts/store/index.js @@ -25,14 +25,14 @@ export function observeStore (select, onChange) { let currentState function handleChange () { - let nextState = select(store.getState()) + const nextState = select(store.getState()) if (nextState !== currentState) { currentState = nextState onChange(currentState) } } - let unsubscribe = store.subscribe(handleChange) + const unsubscribe = store.subscribe(handleChange) // handleChange() return unsubscribe } diff --git a/assets/scripts/store/reducers/__tests__/flags.test.js b/assets/scripts/store/reducers/__tests__/flags.test.js index 32370179c2..6626928388 100644 --- a/assets/scripts/store/reducers/__tests__/flags.test.js +++ b/assets/scripts/store/reducers/__tests__/flags.test.js @@ -18,13 +18,13 @@ jest.mock('../../../../../app/data/flags', () => { describe('flags reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual({ - 'BAZ_QUX': { - 'source': 'initial', - 'value': true + BAZ_QUX: { + source: 'initial', + value: true }, - 'FOO_BAR': { - 'source': 'initial', - 'value': false + FOO_BAR: { + source: 'initial', + value: false } }) }) @@ -32,13 +32,13 @@ describe('flags reducer', () => { it('should set a user-defined value', () => { const action = reducer(undefined, actions.setFeatureFlag('BAZ_QUX', false)) const result = { - 'BAZ_QUX': { - 'source': 'session', - 'value': false + BAZ_QUX: { + source: 'session', + value: false }, - 'FOO_BAR': { - 'source': 'initial', - 'value': false + FOO_BAR: { + source: 'initial', + value: false } } expect(action).toEqual(result) diff --git a/assets/scripts/streets/EnvironmentEditor.jsx b/assets/scripts/streets/EnvironmentEditor.jsx index 9f6dfeecab..dddf306fb7 100644 --- a/assets/scripts/streets/EnvironmentEditor.jsx +++ b/assets/scripts/streets/EnvironmentEditor.jsx @@ -33,7 +33,7 @@ class EnvironmentEditor extends Component { render () { const envs = getAllEnvirons() - const show = [ this.props.visible ] + const show = [this.props.visible] return ( { it('fills in all empty stops', () => { const result = makeCanvasGradientStopArray(MOCK_ENVIRONS.foo.backgroundGradient) expect(result).toEqual([ - [ '#020b1a', 0.0 ], - [ '#3e5879', 0.14285714285714285 ], - [ '#9ba5ae', 0.2857142857142857 ], - [ '#dcb697', 0.42857142857142855 ], - [ '#fc7001', 0.5714285714285714 ], - [ '#dd723c', 0.7142857142857142 ], - [ '#ad4a28', 0.857142857142857 ], - [ '#040308', 1.0 ] + ['#020b1a', 0.0], + ['#3e5879', 0.14285714285714285], + ['#9ba5ae', 0.2857142857142857], + ['#dcb697', 0.42857142857142855], + ['#fc7001', 0.5714285714285714], + ['#dd723c', 0.7142857142857142], + ['#ad4a28', 0.857142857142857], + ['#040308', 1.0] ]) }) it('fills in empty stops between known stops', () => { const result = makeCanvasGradientStopArray(MOCK_ENVIRONS.bar.backgroundGradient) expect(result).toEqual([ - [ '#020b1a', 0.0 ], - [ '#3e5879', 0.2 ], - [ '#9ba5ae', 0.4 ], - [ '#dcb697', 0.7 ], - [ '#fc7001', 1.0 ] + ['#020b1a', 0.0], + ['#3e5879', 0.2], + ['#9ba5ae', 0.4], + ['#dcb697', 0.7], + ['#fc7001', 1.0] ]) }) }) @@ -54,12 +54,12 @@ describe('environs helpers', () => { it('gets info for a single environs, with React-ready style object', () => { const result = getEnvirons('foo') expect(result).toEqual({ - 'id': 'foo', - 'name': 'Foo', - 'backgroundGradient': [ '#020b1a', '#3e5879', ['#9ba5ae'], ['#dcb697'], ['#fc7001'], ['#dd723c'], ['#ad4a28'], ['#040308'] ], - 'cloudOpacity': 0.85, - 'style': { - 'background': 'linear-gradient(#020b1a, #3e5879, #9ba5ae, #dcb697, #fc7001, #dd723c, #ad4a28, #040308)' + id: 'foo', + name: 'Foo', + backgroundGradient: ['#020b1a', '#3e5879', ['#9ba5ae'], ['#dcb697'], ['#fc7001'], ['#dd723c'], ['#ad4a28'], ['#040308']], + cloudOpacity: 0.85, + style: { + background: 'linear-gradient(#020b1a, #3e5879, #9ba5ae, #dcb697, #fc7001, #dd723c, #ad4a28, #040308)' } }) }) diff --git a/assets/scripts/streets/__tests__/width.test.js b/assets/scripts/streets/__tests__/width.test.js index 6007d37b91..849f914e2d 100644 --- a/assets/scripts/streets/__tests__/width.test.js +++ b/assets/scripts/streets/__tests__/width.test.js @@ -43,9 +43,9 @@ describe('recalculateWidth', () => { occupiedWidth: 50, remainingWidth: 0, segments: [ - { width: 10, warnings: [ undefined, false, false, false ] }, - { width: 20, warnings: [ undefined, false, false, false ] }, - { width: 20, warnings: [ undefined, false, false, false ] } + { width: 10, warnings: [undefined, false, false, false] }, + { width: 20, warnings: [undefined, false, false, false] }, + { width: 20, warnings: [undefined, false, false, false] } ] }) }) @@ -62,8 +62,8 @@ describe('recalculateWidth', () => { occupiedWidth: 40, remainingWidth: 10, segments: [ - { width: 10, warnings: [ undefined, false, false, false ] }, - { width: 30, warnings: [ undefined, false, false, false ] } + { width: 10, warnings: [undefined, false, false, false] }, + { width: 30, warnings: [undefined, false, false, false] } ] }) }) @@ -81,9 +81,9 @@ describe('recalculateWidth', () => { occupiedWidth: 70, remainingWidth: -20, segments: [ - { width: 30, warnings: [ undefined, true, false, false ] }, - { width: 10, warnings: [ undefined, false, false, false ] }, - { width: 30, warnings: [ undefined, true, false, false ] } + { width: 30, warnings: [undefined, true, false, false] }, + { width: 10, warnings: [undefined, false, false, false] }, + { width: 30, warnings: [undefined, true, false, false] } ] }) }) @@ -101,9 +101,9 @@ describe('recalculateWidth', () => { occupiedWidth: 70, remainingWidth: -20, segments: [ - { width: 30, warnings: [ undefined, true, false, false ] }, - { width: 10, warnings: [ undefined, false, false, false ] }, - { width: 30, warnings: [ undefined, true, false, false ] } + { width: 30, warnings: [undefined, true, false, false] }, + { width: 10, warnings: [undefined, false, false, false] }, + { width: 30, warnings: [undefined, true, false, false] } ] }) }) @@ -121,9 +121,9 @@ describe('recalculateWidth', () => { occupiedWidth: 30, remainingWidth: 20, segments: [ - { width: 2, type: 'sidewalk', variantString: 'normal', warnings: [ undefined, false, true, false ] }, - { width: 10, type: 'divider', variantString: 'bush', warnings: [ undefined, false, false, false ] }, - { width: 18, type: 'parking-lane', variantString: 'inbound|left', warnings: [ undefined, false, false, true ] } + { width: 2, type: 'sidewalk', variantString: 'normal', warnings: [undefined, false, true, false] }, + { width: 10, type: 'divider', variantString: 'bush', warnings: [undefined, false, false, false] }, + { width: 18, type: 'parking-lane', variantString: 'inbound|left', warnings: [undefined, false, false, true] } ] }) }) diff --git a/assets/scripts/streets/data_model.js b/assets/scripts/streets/data_model.js index b329daa135..cda8e0ed14 100644 --- a/assets/scripts/streets/data_model.js +++ b/assets/scripts/streets/data_model.js @@ -88,7 +88,7 @@ function incrementSchemaVersion (street) { } break case 4: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-lamp') { variant = getVariantArray(segment.type, segment.variantString) @@ -98,7 +98,7 @@ function incrementSchemaVersion (street) { } break case 5: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'streetcar') { variant = getVariantArray(segment.type, segment.variantString) @@ -108,7 +108,7 @@ function incrementSchemaVersion (street) { } break case 6: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bus-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -122,7 +122,7 @@ function incrementSchemaVersion (street) { } break case 7: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bike-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -132,7 +132,7 @@ function incrementSchemaVersion (street) { } break case 8: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'drive-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -142,7 +142,7 @@ function incrementSchemaVersion (street) { } break case 9: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk') { variant = getVariantArray(segment.type, segment.variantString) @@ -152,7 +152,7 @@ function incrementSchemaVersion (street) { } break case 10: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'planting-strip') { segment.type = 'divider' @@ -167,7 +167,7 @@ function incrementSchemaVersion (street) { } break case 11: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'divider') { if (segment.variantString === 'small-tree') { @@ -181,7 +181,7 @@ function incrementSchemaVersion (street) { } break case 12: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-bike-rack') { variant = getVariantArray(segment.type, segment.variantString) @@ -191,7 +191,7 @@ function incrementSchemaVersion (street) { } break case 13: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk-wayfinding') { variant = getVariantArray(segment.type, segment.variantString) @@ -201,7 +201,7 @@ function incrementSchemaVersion (street) { } break case 14: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'sidewalk') { segment.randSeed = 35 @@ -212,7 +212,7 @@ function incrementSchemaVersion (street) { store.dispatch(resetUndoStack()) break case 16: - for (let i in street.segments) { + for (const i in street.segments) { segment = street.segments[i] if (segment.type === 'bike-lane') { variant = getVariantArray(segment.type, segment.variantString) @@ -346,9 +346,9 @@ export function trimStreetData (street, saveSegmentId = true) { function fillDefaultSegments (units) { const segments = [] - let leftHandTraffic = getLeftHandTraffic() + const leftHandTraffic = getLeftHandTraffic() - for (let i in DEFAULT_SEGMENTS[leftHandTraffic]) { + for (const i in DEFAULT_SEGMENTS[leftHandTraffic]) { const segment = DEFAULT_SEGMENTS[leftHandTraffic][i] segment.warnings = [] segment.variantString = getVariantString(segment.variant) diff --git a/assets/scripts/streets/environs.js b/assets/scripts/streets/environs.js index e97aa76b18..1c6d845a53 100644 --- a/assets/scripts/streets/environs.js +++ b/assets/scripts/streets/environs.js @@ -19,7 +19,7 @@ export function makeCSSGradientDeclaration (array) { // If the value is an array, turn it into a string if (Array.isArray(item)) { - const [ color, position ] = item + const [color, position] = item // Position is recorded as a value between 0 and 1, but is optional let percentage @@ -165,8 +165,8 @@ export function getEnvirons (id) { */ export function getAllEnvirons () { return Object.entries(ENVIRONS) - .filter(([ key, value ]) => value.enabled !== false) - .map(([ key, value ]) => getEnvirons(key)) + .filter(([key, value]) => value.enabled !== false) + .map(([key, value]) => getEnvirons(key)) } /** diff --git a/assets/scripts/streets/image.js b/assets/scripts/streets/image.js index 801f32150d..7db0069d4a 100644 --- a/assets/scripts/streets/image.js +++ b/assets/scripts/streets/image.js @@ -123,7 +123,7 @@ export async function saveStreetThumbnail (street, event) { method: 'POST', body: JSON.stringify(details), headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'text/plain' } } @@ -153,7 +153,7 @@ export async function deleteStreetThumbnail (streetId) { const options = { method: 'DELETE', headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'text/plain' } } diff --git a/assets/scripts/streets/remix.js b/assets/scripts/streets/remix.js index 5122f4698a..ac75c0e1c8 100644 --- a/assets/scripts/streets/remix.js +++ b/assets/scripts/streets/remix.js @@ -84,7 +84,7 @@ export function remixStreet () { method: 'POST', body: transmission, headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'application/json' } }, receiveRemixedStreet diff --git a/assets/scripts/streets/xhr.js b/assets/scripts/streets/xhr.js index 55c33563f1..ecad32467b 100644 --- a/assets/scripts/streets/xhr.js +++ b/assets/scripts/streets/xhr.js @@ -96,7 +96,7 @@ export function createNewStreetOnServer () { method: 'POST', body: packServerStreetData(), headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'application/json' } } @@ -149,7 +149,7 @@ export function fetchStreetFromServer () { } function errorReceiveStreet (data) { - let mode = getMode() + const mode = getMode() if ((mode === MODES.CONTINUE) || (mode === MODES.USER_GALLERY) || (mode === MODES.GLOBAL_GALLERY)) { goNewStreet() @@ -184,7 +184,7 @@ export function saveStreetToServer (initial) { method: 'PUT', body: transmission, headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'application/json' } } @@ -410,7 +410,7 @@ export function fetchLastStreet () { // TODO const url: API_URL + 'v1/streets/' + getSettings().priorLastStreetId, method: 'GET', - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } }, receiveLastStreet, cancelReceiveLastStreet ) } @@ -466,6 +466,6 @@ export function sendDeleteStreetToServer (id) { // TODO const url newNonblockingAjaxRequest(API_URL + 'v1/streets/' + id, { method: 'DELETE', - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } }, false) } diff --git a/assets/scripts/ui/Checkbox.jsx b/assets/scripts/ui/Checkbox.jsx index 8b2ca50e14..f39526fa23 100644 --- a/assets/scripts/ui/Checkbox.jsx +++ b/assets/scripts/ui/Checkbox.jsx @@ -50,7 +50,7 @@ function Checkbox (props) { // This is a controlled component. The `useState` hook maintains // this component's internal state, and sets the initial state // based on the `checked` prop (which is `false` by default). - const [ isChecked, setChecked ] = useState(props.checked) + const [isChecked, setChecked] = useState(props.checked) // When the value is changed, we update the state, and we also call // any `onChange` handler that is provided by the parent via props. diff --git a/assets/scripts/users/Avatar.jsx b/assets/scripts/users/Avatar.jsx index c54f1c2603..38b7189f70 100644 --- a/assets/scripts/users/Avatar.jsx +++ b/assets/scripts/users/Avatar.jsx @@ -23,7 +23,7 @@ function Avatar (props) { if (!image) { fetchData() } - }, [ image, userId, rememberUserProfile ]) + }, [image, userId, rememberUserProfile]) return (
diff --git a/assets/scripts/users/authentication.js b/assets/scripts/users/authentication.js index c00142b084..cf0113a426 100644 --- a/assets/scripts/users/authentication.js +++ b/assets/scripts/users/authentication.js @@ -133,7 +133,7 @@ export async function loadSignIn () { async function fetchSignInDetails (userId) { const options = { - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } } try { @@ -234,7 +234,7 @@ function sendSignOutToServer (quiet) { const signInData = getSignInData() const options = { method: 'DELETE', - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } } // TODO const @@ -264,7 +264,7 @@ function _signInLoaded () { let mode = getMode() if ((mode === MODES.CONTINUE) || (mode === MODES.JUST_SIGNED_IN) || (mode === MODES.USER_GALLERY) || (mode === MODES.GLOBAL_GALLERY)) { - let settings = getSettings() + const settings = getSettings() if (settings.lastStreetId) { street.creatorId = settings.lastStreetCreatorId street.id = settings.lastStreetId diff --git a/assets/scripts/users/settings.js b/assets/scripts/users/settings.js index 66514e5b06..098ad23443 100644 --- a/assets/scripts/users/settings.js +++ b/assets/scripts/users/settings.js @@ -38,7 +38,7 @@ function mergeSettings (serverSettings = {}, localSettings = {}) { export function loadSettings () { let serverSettings = {} let localSettings = {} - let signInData = getSignInData() + const signInData = getSignInData() if (isSignedIn() && signInData.details) { serverSettings = signInData.details.data @@ -111,7 +111,7 @@ export function saveSettingsToServer () { method: 'PUT', body: transmission, headers: { - 'Authorization': getAuthHeader(), + Authorization: getAuthHeader(), 'Content-Type': 'application/json' } }, true, null, errorSavingSettingsToServer) diff --git a/assets/scripts/util/api.js b/assets/scripts/util/api.js index bd04135d6f..c5b7f23abd 100644 --- a/assets/scripts/util/api.js +++ b/assets/scripts/util/api.js @@ -13,9 +13,10 @@ class APIClient { responseType: 'json' }) } + getStreet = async (streetId) => { const { data } = await this.client.get(`/streets/${streetId}`, { - headers: { 'Authorization': getAuthHeader() } + headers: { Authorization: getAuthHeader() } }) return data }; diff --git a/assets/scripts/util/fetch_nonblocking.js b/assets/scripts/util/fetch_nonblocking.js index ea8b802ec4..c494e75a42 100644 --- a/assets/scripts/util/fetch_nonblocking.js +++ b/assets/scripts/util/fetch_nonblocking.js @@ -9,7 +9,7 @@ import { showNoConnectionMessage } from '../store/actions/status' const NON_BLOCKING_AJAX_REQUEST_TIME = [10, 500, 1000, 5000, 10000] const NON_BLOCKING_AJAX_REQUEST_BACKOFF_RANGE = 60000 -let nonblockingAjaxRequests = [] +const nonblockingAjaxRequests = [] let nonblockingAjaxRequestTimer = 0 function scheduleNoConnectionMessage () { @@ -170,7 +170,7 @@ function checkIfChangesSaved () { if (getSaveStreetIncomplete()) { showWarning = true } else { - for (let i in nonblockingAjaxRequests) { + for (const i in nonblockingAjaxRequests) { if (!nonblockingAjaxRequests[i].allowToClosePage) { showWarning = true } diff --git a/assets/scripts/util/helpers.js b/assets/scripts/util/helpers.js index ed27dceaf7..eda5099362 100644 --- a/assets/scripts/util/helpers.js +++ b/assets/scripts/util/helpers.js @@ -14,7 +14,7 @@ import slugify from 'slugify' * from the top of the viewport. */ export function getElAbsolutePos (el, includeScroll = false) { - let pos = [0, 0] + const pos = [0, 0] do { pos[0] += el.offsetLeft + (el.cssTransformLeft || 0) @@ -46,7 +46,7 @@ export function normalizeSlug (slug) { slugify.extend({ '|': null, '%': null, - '$': null + $: null }) const slugified = slugify(slug, { diff --git a/assets/scripts/util/width_units.js b/assets/scripts/util/width_units.js index 79a2714af4..9b2443a4da 100644 --- a/assets/scripts/util/width_units.js +++ b/assets/scripts/util/width_units.js @@ -48,7 +48,7 @@ export function processWidthInput (widthInput, units) { widthInput = widthInput.replace(/ /g, '') widthInput = widthInput.replace(/,/g, '.') - for (let i in IMPERIAL_VULGAR_FRACTIONS) { + for (const i in IMPERIAL_VULGAR_FRACTIONS) { if (widthInput.indexOf(IMPERIAL_VULGAR_FRACTIONS[i]) !== -1) { widthInput = widthInput.replace(new RegExp(IMPERIAL_VULGAR_FRACTIONS[i]), i) } @@ -227,7 +227,7 @@ function parseStringForUnits (widthInput, units) { multiplier = 1 } - for (let i in WIDTH_INPUT_CONVERSION) { + for (const i in WIDTH_INPUT_CONVERSION) { if (widthInput.match(new RegExp('[\\d\\.]' + WIDTH_INPUT_CONVERSION[i].text + '$'))) { multiplier = WIDTH_INPUT_CONVERSION[i].multiplier break diff --git a/bin/check_num_logins_per_user.js b/bin/check_num_logins_per_user.js index 8ac57323b9..d2598702d9 100644 --- a/bin/check_num_logins_per_user.js +++ b/bin/check_num_logins_per_user.js @@ -13,4 +13,4 @@ var reducer = function (key, values) { return values.length // { _id: key, value: values.length } } -printjson(db.streets.mapReduce(mapper, reducer, { out: { 'inline': 1 } }).results) +printjson(db.streets.mapReduce(mapper, reducer, { out: { inline: 1 } }).results) diff --git a/bin/compute_street_sizes.js b/bin/compute_street_sizes.js index 8842185538..afbb915fae 100644 --- a/bin/compute_street_sizes.js +++ b/bin/compute_street_sizes.js @@ -25,18 +25,18 @@ var mapper = function () { emit( this._id, { - 'creator_id': this.creator_id, - 'namespaced_id': this.namespaced_id, - 'undo_stack_length': ((this.data && this.data.undoStack) ? this.data.undoStack.length : 0), - 'size_in_bytes': Object.bsonsize(this), - 'updated_at': this.updated_at + creator_id: this.creator_id, + namespaced_id: this.namespaced_id, + undo_stack_length: ((this.data && this.data.undoStack) ? this.data.undoStack.length : 0), + size_in_bytes: Object.bsonsize(this), + updated_at: this.updated_at } ) } var reducer = function (key, values) { return { _id: key, size: values } } -var results = db.streets.mapReduce(mapper, reducer, { out: { 'inline': 1 } }).results +var results = db.streets.mapReduce(mapper, reducer, { out: { inline: 1 } }).results results.forEach(function (result) { var creator = '-' diff --git a/bin/download_translations.js b/bin/download_translations.js index e310ad5602..328c37c01c 100644 --- a/bin/download_translations.js +++ b/bin/download_translations.js @@ -36,8 +36,8 @@ const downloadError = function (locale, resource, label, error) { console.error(chalk`{redBright Error:} {yellowBright ${label} (${locale})} · {magentaBright ${resource}} → {gray ${error}}`) } -for (let r in resources) { - for (let l in languages) { +for (const r in resources) { + for (const l in languages) { // Skip English if (languages[l].value === 'en') { continue diff --git a/lib/transifex.js b/lib/transifex.js index a2b13315f7..7865485eea 100644 --- a/lib/transifex.js +++ b/lib/transifex.js @@ -27,8 +27,8 @@ module.exports = async function getFromTransifex (locale, resource, token) { url: API_BASE_URI + resource + '/translation/' + locale + '?mode=onlytranslated', method: 'get', headers: { - 'Authorization': 'Basic ' + authToken, - 'Accept': 'application/json' + Authorization: 'Basic ' + authToken, + Accept: 'application/json' } }) diff --git a/lib/util.js b/lib/util.js index 03702fff2b..b8d87198be 100644 --- a/lib/util.js +++ b/lib/util.js @@ -17,7 +17,7 @@ exports.parseLoginToken = function (req) { // Convert the auth string to an object const authObject = auth.reduce((accumulator, item) => { - const [ key, value ] = item.split('=') + const [key, value] = item.split('=') accumulator[key] = value.replace(/(^"|"$)/g, '') return accumulator }, {}) diff --git a/lib/variant.js b/lib/variant.js index 6e43223483..b8b563cda2 100644 --- a/lib/variant.js +++ b/lib/variant.js @@ -44,7 +44,7 @@ exports.getVariantArray = function (segmentType, variantString) { const segment = getSegmentInfo(segmentType) if (segment && segment.variants) { - for (let i in segment.variants) { + for (const i in segment.variants) { const variantName = segment.variants[i] variantArray[variantName] = variantSplit[i] } diff --git a/package-lock.json b/package-lock.json index 18cbfc5e5f..c8615f1c6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3084,7 +3084,7 @@ }, "bluebird": { "version": "2.11.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", + "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" }, "bn.js": { @@ -4056,8 +4056,7 @@ "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "optional": true + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "constant-case": { "version": "1.1.2", @@ -6061,9 +6060,9 @@ } }, "eslint-config-standard": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz", - "integrity": "sha512-COUz8FnXhqFitYj4DTqHzidjIL/t4mumGZto5c7DrBpvWoie+Sn3P4sLEzUGeYhRElWuFEf8K1S1EfvD1vixCQ==", + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-13.0.1.tgz", + "integrity": "sha512-zLKp4QOgq6JFgRm1dDCVv1Iu0P5uZ4v5Wa4DTOkg2RFMxdCX/9Qf7lz9ezRj2dBRa955cWQF/O/LWEiYWAHbTw==", "dev": true }, "eslint-config-standard-jsx": { @@ -6102,12 +6101,20 @@ } }, "eslint-plugin-cypress": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-cypress/-/eslint-plugin-cypress-2.2.1.tgz", - "integrity": "sha512-WkH81MEALKhnpeRo/wWHBHR883LdkS8aFzbGAGFxiwRwik2IKBZxb/JrxbiA6+SZskXGcmdEi6rwL7xmiqo9MA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-cypress/-/eslint-plugin-cypress-2.6.1.tgz", + "integrity": "sha512-OVdxKbQ5DGcAGxvgZJRng7g01w/4xqEk65FGc8xELMcTdTjzh1m7FFjEQSglv1Y/TIDsOHaA5b+/ojQp4I2QhA==", "dev": true, "requires": { - "globals": "^11.0.1" + "globals": "^11.12.0" + }, + "dependencies": { + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + } } }, "eslint-plugin-es": { @@ -6344,6 +6351,15 @@ "estraverse": "^4.1.1" } }, + "eslint-stats": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/eslint-stats/-/eslint-stats-1.0.1.tgz", + "integrity": "sha512-5/5v8UvciDsXFNb+e+DMjOX8YZY2l1zpZ8ga3s5pV2CJ/dR0MOFFVXGLItn/jiey+FGBEmCKkFfZlJQra4uQMw==", + "requires": { + "chalk": "^2.4.1", + "lodash": "^4.17.4" + } + }, "eslint-utils": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", @@ -7068,7 +7084,7 @@ "dependencies": { "combined-stream": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { "delayed-stream": "~1.0.0" @@ -7232,8 +7248,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "optional": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "is-fullwidth-code-point": { "version": "1.0.0", @@ -7259,7 +7274,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -10857,7 +10871,6 @@ "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -10866,14 +10879,12 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "optional": true + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } }, @@ -17255,4 +17266,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 1222176f14..ee7b342a2f 100644 --- a/package.json +++ b/package.json @@ -183,9 +183,9 @@ "enzyme-adapter-react-16": "1.14.0", "enzyme-to-json": "3.3.5", "eslint": "6.1.0", - "eslint-config-standard": "12.0.0", + "eslint-config-standard": "13.0.1", "eslint-config-standard-react": "7.0.2", - "eslint-plugin-cypress": "2.2.1", + "eslint-plugin-cypress": "2.6.1", "eslint-plugin-import": "2.18.2", "eslint-plugin-node": "9.1.0", "eslint-plugin-promise": "4.2.1", @@ -207,4 +207,4 @@ "stylelint-scss": "3.9.0", "supertest": "4.0.2" } -} +} \ No newline at end of file