diff --git a/services/chat/.eslintrc b/services/chat/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/chat/.eslintrc +++ b/services/chat/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/clsi/.eslintrc b/services/clsi/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/clsi/.eslintrc +++ b/services/clsi/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/clsi/app/js/Errors.js b/services/clsi/app/js/Errors.js index 07cb48baad..a3eb8d9fd9 100644 --- a/services/clsi/app/js/Errors.js +++ b/services/clsi/app/js/Errors.js @@ -7,7 +7,7 @@ const OError = require('@overleaf/o-error') let Errors -var NotFoundError = function (message) { +function NotFoundError(message) { const error = new Error(message) error.name = 'NotFoundError' error.__proto__ = NotFoundError.prototype @@ -15,7 +15,7 @@ var NotFoundError = function (message) { } NotFoundError.prototype.__proto__ = Error.prototype -var FilesOutOfSyncError = function (message) { +function FilesOutOfSyncError(message) { const error = new Error(message) error.name = 'FilesOutOfSyncError' error.__proto__ = FilesOutOfSyncError.prototype @@ -23,7 +23,7 @@ var FilesOutOfSyncError = function (message) { } FilesOutOfSyncError.prototype.__proto__ = Error.prototype -var AlreadyCompilingError = function (message) { +function AlreadyCompilingError(message) { const error = new Error(message) error.name = 'AlreadyCompilingError' error.__proto__ = AlreadyCompilingError.prototype diff --git a/services/clsi/app/js/UrlFetcher.js b/services/clsi/app/js/UrlFetcher.js index a04f1f682b..3a13ad7a57 100644 --- a/services/clsi/app/js/UrlFetcher.js +++ b/services/clsi/app/js/UrlFetcher.js @@ -50,7 +50,7 @@ module.exports = UrlFetcher = { ) { url = `${settings.filestoreDomainOveride}${u.pathname}${u.search}` } - var timeoutHandler = setTimeout( + let timeoutHandler = setTimeout( function () { timeoutHandler = null logger.error({ url, filePath }, 'Timed out downloading file to cache') diff --git a/services/clsi/test/acceptance/js/ExampleDocumentTests.js b/services/clsi/test/acceptance/js/ExampleDocumentTests.js index 84758c4d65..5b0d518a65 100644 --- a/services/clsi/test/acceptance/js/ExampleDocumentTests.js +++ b/services/clsi/test/acceptance/js/ExampleDocumentTests.js @@ -103,7 +103,7 @@ const compareMultiplePages = function (project_id, callback) { if (callback == null) { callback = function (error) {} } - var compareNext = function (page_no, callback) { + function compareNext(page_no, callback) { const path = `tmp/${project_id}-source-${page_no}.png` return fs.stat(fixturePath(path), (error, stat) => { if (error != null) { diff --git a/services/clsi/test/acceptance/js/helpers/Client.js b/services/clsi/test/acceptance/js/helpers/Client.js index af8e0e30fa..d68d9a34a0 100644 --- a/services/clsi/test/acceptance/js/helpers/Client.js +++ b/services/clsi/test/acceptance/js/helpers/Client.js @@ -142,7 +142,7 @@ module.exports = Client = { let entities = fs.readdirSync(`${baseDirectory}/${directory}`) let rootResourcePath = 'main.tex' while (entities.length > 0) { - var entity = entities.pop() + const entity = entities.pop() const stat = fs.statSync(`${baseDirectory}/${directory}/${entity}`) if (stat.isDirectory()) { entities = entities.concat( diff --git a/services/contacts/.eslintrc b/services/contacts/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/contacts/.eslintrc +++ b/services/contacts/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/contacts/app/js/Errors.js b/services/contacts/app/js/Errors.js index a950b6de20..21036bcaec 100644 --- a/services/contacts/app/js/Errors.js +++ b/services/contacts/app/js/Errors.js @@ -5,7 +5,7 @@ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. let Errors -var NotFoundError = function (message) { +function NotFoundError(message) { const error = new Error(message) error.name = 'NotFoundError' error.__proto__ = NotFoundError.prototype diff --git a/services/docstore/.eslintrc b/services/docstore/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/docstore/.eslintrc +++ b/services/docstore/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/document-updater/.eslintrc b/services/document-updater/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/document-updater/.eslintrc +++ b/services/document-updater/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/document-updater/app/js/DeleteQueueManager.js b/services/document-updater/app/js/DeleteQueueManager.js index 58d56c7e41..cddc2ca56c 100644 --- a/services/document-updater/app/js/DeleteQueueManager.js +++ b/services/document-updater/app/js/DeleteQueueManager.js @@ -85,7 +85,7 @@ module.exports = DeleteQueueManager = { } ) - var flushNextProject = function () { + function flushNextProject() { const now = Date.now() if (now - startTime > options.timeout) { logger.debug('hit time limit on flushing old projects') @@ -126,7 +126,7 @@ module.exports = DeleteQueueManager = { startBackgroundFlush() { const SHORT_DELAY = 10 const LONG_DELAY = 1000 - var doFlush = function () { + function doFlush() { if (Settings.shuttingDown) { logger.info('discontinuing background flush due to shutdown') return diff --git a/services/document-updater/app/js/DispatchManager.js b/services/document-updater/app/js/DispatchManager.js index 55f64a72a9..b029d8f0ae 100644 --- a/services/document-updater/app/js/DispatchManager.js +++ b/services/document-updater/app/js/DispatchManager.js @@ -36,7 +36,7 @@ module.exports = DispatchManager = { } const client = redis.createClient(Settings.redis.documentupdater) - var worker = { + const worker = { client, _waitForUpdateThenDispatchWorker(callback) { if (callback == null) { diff --git a/services/document-updater/app/js/Errors.js b/services/document-updater/app/js/Errors.js index 78afd925bf..f402343b14 100644 --- a/services/document-updater/app/js/Errors.js +++ b/services/document-updater/app/js/Errors.js @@ -5,7 +5,7 @@ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. let Errors -var NotFoundError = function (message) { +function NotFoundError(message) { const error = new Error(message) error.name = 'NotFoundError' error.__proto__ = NotFoundError.prototype @@ -13,7 +13,7 @@ var NotFoundError = function (message) { } NotFoundError.prototype.__proto__ = Error.prototype -var OpRangeNotAvailableError = function (message) { +function OpRangeNotAvailableError(message) { const error = new Error(message) error.name = 'OpRangeNotAvailableError' error.__proto__ = OpRangeNotAvailableError.prototype @@ -21,7 +21,7 @@ var OpRangeNotAvailableError = function (message) { } OpRangeNotAvailableError.prototype.__proto__ = Error.prototype -var ProjectStateChangedError = function (message) { +function ProjectStateChangedError(message) { const error = new Error(message) error.name = 'ProjectStateChangedError' error.__proto__ = ProjectStateChangedError.prototype @@ -29,7 +29,7 @@ var ProjectStateChangedError = function (message) { } ProjectStateChangedError.prototype.__proto__ = Error.prototype -var DeleteMismatchError = function (message) { +function DeleteMismatchError(message) { const error = new Error(message) error.name = 'DeleteMismatchError' error.__proto__ = DeleteMismatchError.prototype diff --git a/services/document-updater/app/js/ProjectFlusher.js b/services/document-updater/app/js/ProjectFlusher.js index 725cda36dc..355e7b2f52 100644 --- a/services/document-updater/app/js/ProjectFlusher.js +++ b/services/document-updater/app/js/ProjectFlusher.js @@ -22,7 +22,7 @@ const ProjectManager = require('./ProjectManager') const _ = require('lodash') const logger = require('@overleaf/logger') -var ProjectFlusher = { +const ProjectFlusher = { // iterate over keys asynchronously using redis scan (non-blocking) // handle all the cluster nodes or single redis server _getKeys(pattern, limit, callback) { @@ -42,7 +42,7 @@ var ProjectFlusher = { const keySet = {} // use hash to avoid duplicate results const batchSize = limit != null ? Math.min(limit, 1000) : 1000 // scan over all keys looking for pattern - var doIteration = ( + const doIteration = ( cb // avoid hitting redis too hard ) => node.scan( diff --git a/services/document-updater/app/js/RangesTracker.js b/services/document-updater/app/js/RangesTracker.js index 2cc8869d99..33bb69012d 100644 --- a/services/document-updater/app/js/RangesTracker.js +++ b/services/document-updater/app/js/RangesTracker.js @@ -324,7 +324,7 @@ const load = function () { // delete is fully after comment, nothing to do } else { // delete and comment overlap - var remaining_after, remaining_before + let remaining_after, remaining_before if (op_start <= comment_start) { remaining_before = '' } else { @@ -402,7 +402,7 @@ const load = function () { } } } else if (change.op.i != null) { - var offset + let offset const change_end = change_start + change.op.i.length const is_change_overlapping = op_start >= change_start && op_start <= change_end @@ -537,7 +537,7 @@ const load = function () { // offset indexes as we go. const op_modifications = [] for (change of Array.from(this.changes)) { - var change_start + let change_start if (change.op.i != null) { change_start = change.op.p const change_end = change_start + change.op.i.length @@ -551,7 +551,7 @@ const load = function () { // When the new delete overlaps an insert, we should remove the part of the insert that // is now deleted, and also remove the part of the new delete that overlapped. I.e. // the two cancel out where they overlap. - var delete_remaining_after, + let delete_remaining_after, delete_remaining_before, insert_remaining_after, insert_remaining_before diff --git a/services/document-updater/app/js/RealTimeRedisManager.js b/services/document-updater/app/js/RealTimeRedisManager.js index 053321897f..c84583a7dc 100644 --- a/services/document-updater/app/js/RealTimeRedisManager.js +++ b/services/document-updater/app/js/RealTimeRedisManager.js @@ -50,7 +50,7 @@ module.exports = RealTimeRedisManager = { } const updates = [] for (jsonUpdate of Array.from(jsonUpdates)) { - var update + let update try { update = JSON.parse(jsonUpdate) } catch (e) { diff --git a/services/document-updater/app/js/UpdateManager.js b/services/document-updater/app/js/UpdateManager.js index def2e41e32..96c4e3fb2b 100644 --- a/services/document-updater/app/js/UpdateManager.js +++ b/services/document-updater/app/js/UpdateManager.js @@ -165,7 +165,7 @@ module.exports = UpdateManager = { return _callback(error) } - var profile = new Profiler('applyUpdate', { project_id, doc_id }) + const profile = new Profiler('applyUpdate', { project_id, doc_id }) UpdateManager._sanitizeUpdate(update) profile.log('sanitizeUpdate', { sync: true }) return DocumentManager.getDoc( diff --git a/services/document-updater/app/js/sharejs/helpers.js b/services/document-updater/app/js/sharejs/helpers.js index b1ab3c2a26..0342655bc4 100644 --- a/services/document-updater/app/js/sharejs/helpers.js +++ b/services/document-updater/app/js/sharejs/helpers.js @@ -46,7 +46,7 @@ exports._bt = bootstrapTransform = function ( let k = 0 while (k < leftOp.length) { - var l + let l const nextC = [] transformComponentX(leftOp[k], rightComponent, newLeftOp, nextC) k++ diff --git a/services/document-updater/app/js/sharejs/json-api.js b/services/document-updater/app/js/sharejs/json-api.js index f429f2b397..ed791cd323 100644 --- a/services/document-updater/app/js/sharejs/json-api.js +++ b/services/document-updater/app/js/sharejs/json-api.js @@ -226,12 +226,12 @@ json.api = { return (() => { const result = [] for (const c of Array.from(op)) { - var i + let i if (c.na !== undefined || c.si !== undefined || c.sd !== undefined) { // no change to structure continue } - var to_remove = [] + const to_remove = [] for (i = 0; i < this._listeners.length; i++) { // Transform a dummy op by the incoming op to work out what // should happen to the listener. @@ -267,14 +267,14 @@ json.api = { return this.on('remoteop', function (op) { return (() => { const result = [] - for (var c of Array.from(op)) { - var match_path = + for (const c of Array.from(op)) { + const match_path = c.na === undefined ? c.p.slice(0, c.p.length - 1) : c.p result.push( (() => { const result1 = [] for (const { path, event, cb } of Array.from(this._listeners)) { - var common + let common if (pathEquals(path, match_path)) { switch (event) { case 'insert': diff --git a/services/document-updater/app/js/sharejs/json.js b/services/document-updater/app/js/sharejs/json.js index 14c3cbb519..3422d6158e 100644 --- a/services/document-updater/app/js/sharejs/json.js +++ b/services/document-updater/app/js/sharejs/json.js @@ -264,7 +264,7 @@ json.normalize = function (op) { // hax, copied from test/types/json. Apparently this is still the fastest way to deep clone an object, assuming // we have browser support for JSON. // http://jsperf.com/cloning-an-object/12 -var clone = o => JSON.parse(JSON.stringify(o)) +const clone = o => JSON.parse(JSON.stringify(o)) json.commonPath = function (p1, p2) { p1 = p1.slice() diff --git a/services/document-updater/app/js/sharejs/model.js b/services/document-updater/app/js/sharejs/model.js index 9489f7c005..a14f806d72 100644 --- a/services/document-updater/app/js/sharejs/model.js +++ b/services/document-updater/app/js/sharejs/model.js @@ -421,7 +421,7 @@ module.exports = Model = function (db, options) { // Documents are stored so long as either: // - They have been accessed within the past #{PERIOD} // - At least one client has the document open - var refreshReapingTimeout = function (docName) { + function refreshReapingTimeout(docName) { const doc = docs[docName] if (!doc) { return @@ -461,7 +461,7 @@ module.exports = Model = function (db, options) { }) } - var tryWriteSnapshot = function (docName, callback) { + function tryWriteSnapshot(docName, callback) { if (!db) { return typeof callback === 'function' ? callback() : undefined } @@ -784,7 +784,7 @@ module.exports = Model = function (db, options) { return (() => { const result = [] for (const op of Array.from(data)) { - var needle + let needle listener(op) // The listener may well remove itself during the catchup phase. If this happens, break early. diff --git a/services/document-updater/app/js/sharejs/server/model.js b/services/document-updater/app/js/sharejs/server/model.js index 6ad3eb25ca..8d029c7ac7 100644 --- a/services/document-updater/app/js/sharejs/server/model.js +++ b/services/document-updater/app/js/sharejs/server/model.js @@ -434,7 +434,7 @@ module.exports = Model = function (db, options) { // Documents are stored so long as either: // - They have been accessed within the past #{PERIOD} // - At least one client has the document open - var refreshReapingTimeout = function (docName) { + function refreshReapingTimeout(docName) { const doc = docs[docName] if (!doc) { return @@ -474,7 +474,7 @@ module.exports = Model = function (db, options) { }) } - var tryWriteSnapshot = function (docName, callback) { + function tryWriteSnapshot(docName, callback) { if (!db) { return typeof callback === 'function' ? callback() : undefined } @@ -797,7 +797,7 @@ module.exports = Model = function (db, options) { return (() => { const result = [] for (const op of Array.from(data)) { - var needle + let needle listener(op) // The listener may well remove itself during the catchup phase. If this happens, break early. diff --git a/services/document-updater/app/js/sharejs/server/syncqueue.js b/services/document-updater/app/js/sharejs/server/syncqueue.js index 7b83c5b436..77959230b6 100644 --- a/services/document-updater/app/js/sharejs/server/syncqueue.js +++ b/services/document-updater/app/js/sharejs/server/syncqueue.js @@ -38,7 +38,7 @@ module.exports = function (process) { enqueue.busy = false - var flush = function () { + function flush() { if (enqueue.busy || queue.length === 0) { return } diff --git a/services/document-updater/app/js/sharejs/syncqueue.js b/services/document-updater/app/js/sharejs/syncqueue.js index 7b83c5b436..77959230b6 100644 --- a/services/document-updater/app/js/sharejs/syncqueue.js +++ b/services/document-updater/app/js/sharejs/syncqueue.js @@ -38,7 +38,7 @@ module.exports = function (process) { enqueue.busy = false - var flush = function () { + function flush() { if (enqueue.busy || queue.length === 0) { return } diff --git a/services/document-updater/app/js/sharejs/text-composable.js b/services/document-updater/app/js/sharejs/text-composable.js index 58c4df2b28..ebee536d9d 100644 --- a/services/document-updater/app/js/sharejs/text-composable.js +++ b/services/document-updater/app/js/sharejs/text-composable.js @@ -228,7 +228,7 @@ exports.transform = function (op, otherOp, side) { const [take, peek] = Array.from(makeTake(op)) for (component of Array.from(otherOp)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip length = component @@ -306,7 +306,7 @@ exports.compose = function (op1, op2) { const [take, _] = Array.from(makeTake(op1)) for (component of Array.from(op2)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip length = component diff --git a/services/document-updater/app/js/sharejs/text-tp2-api.js b/services/document-updater/app/js/sharejs/text-tp2-api.js index 8ffbd60c50..1e1b40d176 100644 --- a/services/document-updater/app/js/sharejs/text-tp2-api.js +++ b/services/document-updater/app/js/sharejs/text-tp2-api.js @@ -99,7 +99,7 @@ type.api = { const docPos = { index: 0, offset: 0 } for (const component of Array.from(op)) { - var part, remainder + let part, remainder if (typeof component === 'number') { // Skip remainder = component diff --git a/services/document-updater/app/js/sharejs/text-tp2.js b/services/document-updater/app/js/sharejs/text-tp2.js index 67a70439c7..7173c696b0 100644 --- a/services/document-updater/app/js/sharejs/text-tp2.js +++ b/services/document-updater/app/js/sharejs/text-tp2.js @@ -39,7 +39,7 @@ // would be represented by a document snapshot of ['Hello ', 5, 'world'] let append, appendDoc, takeDoc -var type = { +const type = { name: 'text-tp2', tp2: true, create() { @@ -183,7 +183,7 @@ type.apply = function (doc, op) { const position = { index: 0, offset: 0 } for (const component of Array.from(op)) { - var part, remainder + let part, remainder if (typeof component === 'number') { remainder = component while (remainder > 0) { @@ -337,7 +337,7 @@ const transformer = function (op, otherOp, goForwards, side) { const [take, peek] = Array.from(makeTake(op)) for (component of Array.from(otherOp)) { - var chunk + let chunk let length = componentLength(component) if (component.i !== undefined) { @@ -431,7 +431,7 @@ type.compose = function (op1, op2) { const [take, _] = Array.from(makeTake(op1)) for (component of Array.from(op2)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip // Just copy from op1. diff --git a/services/document-updater/app/js/sharejs/types/helpers.js b/services/document-updater/app/js/sharejs/types/helpers.js index b1ab3c2a26..0342655bc4 100644 --- a/services/document-updater/app/js/sharejs/types/helpers.js +++ b/services/document-updater/app/js/sharejs/types/helpers.js @@ -46,7 +46,7 @@ exports._bt = bootstrapTransform = function ( let k = 0 while (k < leftOp.length) { - var l + let l const nextC = [] transformComponentX(leftOp[k], rightComponent, newLeftOp, nextC) k++ diff --git a/services/document-updater/app/js/sharejs/types/json-api.js b/services/document-updater/app/js/sharejs/types/json-api.js index f429f2b397..ed791cd323 100644 --- a/services/document-updater/app/js/sharejs/types/json-api.js +++ b/services/document-updater/app/js/sharejs/types/json-api.js @@ -226,12 +226,12 @@ json.api = { return (() => { const result = [] for (const c of Array.from(op)) { - var i + let i if (c.na !== undefined || c.si !== undefined || c.sd !== undefined) { // no change to structure continue } - var to_remove = [] + const to_remove = [] for (i = 0; i < this._listeners.length; i++) { // Transform a dummy op by the incoming op to work out what // should happen to the listener. @@ -267,14 +267,14 @@ json.api = { return this.on('remoteop', function (op) { return (() => { const result = [] - for (var c of Array.from(op)) { - var match_path = + for (const c of Array.from(op)) { + const match_path = c.na === undefined ? c.p.slice(0, c.p.length - 1) : c.p result.push( (() => { const result1 = [] for (const { path, event, cb } of Array.from(this._listeners)) { - var common + let common if (pathEquals(path, match_path)) { switch (event) { case 'insert': diff --git a/services/document-updater/app/js/sharejs/types/json.js b/services/document-updater/app/js/sharejs/types/json.js index 14c3cbb519..3422d6158e 100644 --- a/services/document-updater/app/js/sharejs/types/json.js +++ b/services/document-updater/app/js/sharejs/types/json.js @@ -264,7 +264,7 @@ json.normalize = function (op) { // hax, copied from test/types/json. Apparently this is still the fastest way to deep clone an object, assuming // we have browser support for JSON. // http://jsperf.com/cloning-an-object/12 -var clone = o => JSON.parse(JSON.stringify(o)) +const clone = o => JSON.parse(JSON.stringify(o)) json.commonPath = function (p1, p2) { p1 = p1.slice() diff --git a/services/document-updater/app/js/sharejs/types/model.js b/services/document-updater/app/js/sharejs/types/model.js index 9489f7c005..a14f806d72 100644 --- a/services/document-updater/app/js/sharejs/types/model.js +++ b/services/document-updater/app/js/sharejs/types/model.js @@ -421,7 +421,7 @@ module.exports = Model = function (db, options) { // Documents are stored so long as either: // - They have been accessed within the past #{PERIOD} // - At least one client has the document open - var refreshReapingTimeout = function (docName) { + function refreshReapingTimeout(docName) { const doc = docs[docName] if (!doc) { return @@ -461,7 +461,7 @@ module.exports = Model = function (db, options) { }) } - var tryWriteSnapshot = function (docName, callback) { + function tryWriteSnapshot(docName, callback) { if (!db) { return typeof callback === 'function' ? callback() : undefined } @@ -784,7 +784,7 @@ module.exports = Model = function (db, options) { return (() => { const result = [] for (const op of Array.from(data)) { - var needle + let needle listener(op) // The listener may well remove itself during the catchup phase. If this happens, break early. diff --git a/services/document-updater/app/js/sharejs/types/syncqueue.js b/services/document-updater/app/js/sharejs/types/syncqueue.js index 7b83c5b436..77959230b6 100644 --- a/services/document-updater/app/js/sharejs/types/syncqueue.js +++ b/services/document-updater/app/js/sharejs/types/syncqueue.js @@ -38,7 +38,7 @@ module.exports = function (process) { enqueue.busy = false - var flush = function () { + function flush() { if (enqueue.busy || queue.length === 0) { return } diff --git a/services/document-updater/app/js/sharejs/types/text-composable.js b/services/document-updater/app/js/sharejs/types/text-composable.js index ce0f3ac226..eccbde4439 100644 --- a/services/document-updater/app/js/sharejs/types/text-composable.js +++ b/services/document-updater/app/js/sharejs/types/text-composable.js @@ -228,7 +228,7 @@ moduleExport.transform = function (op, otherOp, side) { const [take, peek] = Array.from(makeTake(op)) for (component of Array.from(otherOp)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip length = component @@ -305,7 +305,7 @@ moduleExport.compose = function (op1, op2) { const [take, _] = Array.from(makeTake(op1)) for (component of Array.from(op2)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip length = component diff --git a/services/document-updater/app/js/sharejs/types/text-tp2-api.js b/services/document-updater/app/js/sharejs/types/text-tp2-api.js index 8ffbd60c50..1e1b40d176 100644 --- a/services/document-updater/app/js/sharejs/types/text-tp2-api.js +++ b/services/document-updater/app/js/sharejs/types/text-tp2-api.js @@ -99,7 +99,7 @@ type.api = { const docPos = { index: 0, offset: 0 } for (const component of Array.from(op)) { - var part, remainder + let part, remainder if (typeof component === 'number') { // Skip remainder = component diff --git a/services/document-updater/app/js/sharejs/types/text-tp2.js b/services/document-updater/app/js/sharejs/types/text-tp2.js index 67a70439c7..7173c696b0 100644 --- a/services/document-updater/app/js/sharejs/types/text-tp2.js +++ b/services/document-updater/app/js/sharejs/types/text-tp2.js @@ -39,7 +39,7 @@ // would be represented by a document snapshot of ['Hello ', 5, 'world'] let append, appendDoc, takeDoc -var type = { +const type = { name: 'text-tp2', tp2: true, create() { @@ -183,7 +183,7 @@ type.apply = function (doc, op) { const position = { index: 0, offset: 0 } for (const component of Array.from(op)) { - var part, remainder + let part, remainder if (typeof component === 'number') { remainder = component while (remainder > 0) { @@ -337,7 +337,7 @@ const transformer = function (op, otherOp, goForwards, side) { const [take, peek] = Array.from(makeTake(op)) for (component of Array.from(otherOp)) { - var chunk + let chunk let length = componentLength(component) if (component.i !== undefined) { @@ -431,7 +431,7 @@ type.compose = function (op1, op2) { const [take, _] = Array.from(makeTake(op1)) for (component of Array.from(op2)) { - var chunk, length + let chunk, length if (typeof component === 'number') { // Skip // Just copy from op1. diff --git a/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js b/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js index 283f7bd9b1..91823dfa0e 100644 --- a/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js +++ b/services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js @@ -180,7 +180,7 @@ describe('DispatchManager', function () { this.worker.run() - var checkStatus = () => { + const checkStatus = () => { if (!this.settings.shuttingDown) { // retry until shutdown setTimeout(checkStatus, 100) diff --git a/services/document-updater/test/unit/js/ShareJS/TextTransformTests.js b/services/document-updater/test/unit/js/ShareJS/TextTransformTests.js index 0946a78442..118cf339c2 100644 --- a/services/document-updater/test/unit/js/ShareJS/TextTransformTests.js +++ b/services/document-updater/test/unit/js/ShareJS/TextTransformTests.js @@ -350,7 +350,7 @@ describe('ShareJS text type', function () { asc1 ? p <= end1 : p >= end1; asc1 ? p++ : p-- ) { - var asc2, end2 + let asc2, end2 for ( length = 1, end2 = SNAPSHOT.length - p, asc2 = end2 >= 1; asc2 ? length <= end2 : length >= end2; @@ -364,7 +364,7 @@ describe('ShareJS text type', function () { asc3 ? p <= end3 : p >= end3; asc3 ? p++ : p-- ) { - var asc4, end4 + let asc4, end4 for ( length = 1, end4 = SNAPSHOT.length - p, asc4 = end4 >= 1; asc4 ? length <= end4 : length >= end4; @@ -376,7 +376,7 @@ describe('ShareJS text type', function () { return (() => { const result = [] - for (var op1 of Array.from(OPS)) { + for (const op1 of Array.from(OPS)) { result.push( (() => { const result1 = [] diff --git a/services/filestore/.eslintrc b/services/filestore/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/filestore/.eslintrc +++ b/services/filestore/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/notifications/.eslintrc b/services/notifications/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/notifications/.eslintrc +++ b/services/notifications/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/real-time/.eslintrc b/services/real-time/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/real-time/.eslintrc +++ b/services/real-time/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/real-time/app/js/Router.js b/services/real-time/app/js/Router.js index 7458139285..251ee4100c 100644 --- a/services/real-time/app/js/Router.js +++ b/services/real-time/app/js/Router.js @@ -43,7 +43,7 @@ module.exports = Router = { attrs.method = method if (Joi.isError(error)) { logger.info(attrs, 'validation error') - var message = 'invalid' + let message = 'invalid' try { message = error.details[0].message } catch (e) { diff --git a/services/real-time/test/acceptance/libs/XMLHttpRequest.js b/services/real-time/test/acceptance/libs/XMLHttpRequest.js index b0436718e3..6539588ded 100644 --- a/services/real-time/test/acceptance/libs/XMLHttpRequest.js +++ b/services/real-time/test/acceptance/libs/XMLHttpRequest.js @@ -557,7 +557,7 @@ exports.XMLHttpRequest = function () { * * @param int state New state */ - var setState = function (state) { + function setState(state) { if (self.readyState !== state) { self.readyState = state diff --git a/services/spelling/.eslintrc b/services/spelling/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/spelling/.eslintrc +++ b/services/spelling/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/spelling/app/js/ASpell.js b/services/spelling/app/js/ASpell.js index fb864e7b82..95b15736cd 100644 --- a/services/spelling/app/js/ASpell.js +++ b/services/spelling/app/js/ASpell.js @@ -112,7 +112,7 @@ class ASpellRunner { const lines = output.split('\n') const suggestions = {} for (const line of Array.from(lines)) { - var parts, word + let parts, word if (line[0] === '&') { // Suggestions found parts = line.split(' ') @@ -187,5 +187,5 @@ ASpell.promises = promises module.exports = ASpell -var WorkerPool = new ASpellWorkerPool() +const WorkerPool = new ASpellWorkerPool() module.exports.cacheDump = cacheDump diff --git a/services/spelling/app/js/ASpellWorker.js b/services/spelling/app/js/ASpellWorker.js index 02d760acf3..761fccdedf 100644 --- a/services/spelling/app/js/ASpellWorker.js +++ b/services/spelling/app/js/ASpellWorker.js @@ -112,7 +112,7 @@ class ASpellWorker { }) this.pipe.stdout.setEncoding('utf8') // ensure utf8 output is handled correctly - var output = '' + let output = '' const endMarkerRegex = new RegExp('^[a-z][a-z]', 'gm') this.pipe.stdout.on('data', data => { // We receive the language code from Aspell as the end of data marker in @@ -143,7 +143,7 @@ class ASpellWorker { } }) - var error = '' + let error = '' this.pipe.stderr.on('data', chunk => { return (error = error + chunk) }) diff --git a/services/track-changes/.eslintrc b/services/track-changes/.eslintrc index a97661b15f..6421c6cfbf 100644 --- a/services/track-changes/.eslintrc +++ b/services/track-changes/.eslintrc @@ -24,7 +24,6 @@ // START of temporary overrides "array-callback-return": "off", "no-dupe-else-if": "off", - "no-var": "off", "no-empty": "off", "node/handle-callback-err": "off", "no-loss-of-precision": "off", diff --git a/services/track-changes/app/js/DiffGenerator.js b/services/track-changes/app/js/DiffGenerator.js index 0d8ef0be94..4d9c7a986f 100644 --- a/services/track-changes/app/js/DiffGenerator.js +++ b/services/track-changes/app/js/DiffGenerator.js @@ -13,7 +13,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ let DiffGenerator -var ConsistencyError = function (message) { +function ConsistencyError(message) { const error = new Error(message) error.name = 'ConsistencyError' error.__proto__ = ConsistencyError.prototype diff --git a/services/track-changes/app/js/RedisManager.js b/services/track-changes/app/js/RedisManager.js index 4998c4757f..78822da0cd 100644 --- a/services/track-changes/app/js/RedisManager.js +++ b/services/track-changes/app/js/RedisManager.js @@ -93,7 +93,7 @@ module.exports = RedisManager = { let cursor = 0 // redis iterator const keySet = {} // use hash to avoid duplicate results // scan over all keys looking for pattern - var doIteration = cb => + const doIteration = cb => node.scan( cursor, 'MATCH', diff --git a/services/track-changes/app/js/UpdatesManager.js b/services/track-changes/app/js/UpdatesManager.js index 574278f1a9..c07ed839e0 100644 --- a/services/track-changes/app/js/UpdatesManager.js +++ b/services/track-changes/app/js/UpdatesManager.js @@ -142,7 +142,7 @@ module.exports = UpdatesManager = { // some old large ops in redis need to be rejected, they predate // the size limit that now prevents them going through the system const REJECT_LARGE_OP_SIZE = 4 * 1024 * 1024 - for (var rawUpdate of Array.from(rawUpdates)) { + for (const rawUpdate of Array.from(rawUpdates)) { const opSizes = (() => { const result = [] for (op of Array.from( @@ -801,7 +801,7 @@ module.exports = UpdatesManager = { const summarizedUpdates = existingSummarizedUpdates.slice() let previousUpdateWasBigDelete = false for (const update of Array.from(updates)) { - var doc_id + let doc_id const earliestUpdate = summarizedUpdates[summarizedUpdates.length - 1] let shouldConcat = false diff --git a/services/web/.eslintrc b/services/web/.eslintrc index c8b816d242..9ab3408661 100644 --- a/services/web/.eslintrc +++ b/services/web/.eslintrc @@ -15,10 +15,6 @@ } }, "rules": { - // Disable some rules after upgrading ESLint - // TODO: re-enable and fix - "no-var": "off", - // do not allow importing of implicit dependencies. "import/no-extraneous-dependencies": "error" }, diff --git a/services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceHelper.js b/services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceHelper.js index 674a8d6406..bbe9058e5c 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceHelper.js +++ b/services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceHelper.js @@ -1,4 +1,4 @@ -var RefererParser = require('referer-parser') +const RefererParser = require('referer-parser') const { URL } = require('url') const AnalyticsManager = require('./AnalyticsManager') @@ -18,7 +18,7 @@ const UTM_KEYS = [ ] function parseUtm(query) { - var utmValues = {} + const utmValues = {} for (const utmKey of UTM_KEYS) { if (query[utmKey]) { utmValues[utmKey] = query[utmKey] diff --git a/services/web/app/src/Features/Documents/DocumentHelper.js b/services/web/app/src/Features/Documents/DocumentHelper.js index be9840bb64..959cc91de4 100644 --- a/services/web/app/src/Features/Documents/DocumentHelper.js +++ b/services/web/app/src/Features/Documents/DocumentHelper.js @@ -22,7 +22,7 @@ module.exports = DocumentHelper = { for (const line of Array.from( DocumentHelper._getLinesFromContent(content, maxContentToScan) )) { - var match + let match if ( (match = line.match(TITLE_WITH_CURLY_BRACES) || diff --git a/services/web/app/src/Features/Editor/EditorRealTimeController.js b/services/web/app/src/Features/Editor/EditorRealTimeController.js index 6f551950fd..726fb582f3 100644 --- a/services/web/app/src/Features/Editor/EditorRealTimeController.js +++ b/services/web/app/src/Features/Editor/EditorRealTimeController.js @@ -27,7 +27,7 @@ module.exports = EditorRealTimeController = { emitToRoom(room_id, message, ...payload) { // create a unique message id using a counter const message_id = `web:${HOST}:${RND}-${COUNT++}` - var channel + let channel if (room_id === 'all' || !Settings.publishOnIndividualChannels) { channel = 'editor-events' } else { diff --git a/services/web/app/src/Features/Email/EmailBuilder.js b/services/web/app/src/Features/Email/EmailBuilder.js index cf67cf6831..2683d71cf6 100644 --- a/services/web/app/src/Features/Email/EmailBuilder.js +++ b/services/web/app/src/Features/Email/EmailBuilder.js @@ -273,7 +273,7 @@ templates.projectInvite = ctaTemplate({ }, message(opts, isPlainText) { // build message depending on spam-safe variables - var message = [`You have been invited to an ${settings.appName} project.`] + const message = [`You have been invited to an ${settings.appName} project.`] if (SpamSafe.isSafeProjectName(opts.project.name)) { message.push('
Project:') diff --git a/services/web/app/src/Features/Institutions/InstitutionsAPI.js b/services/web/app/src/Features/Institutions/InstitutionsAPI.js index 210a5c3175..4f27fc3e91 100644 --- a/services/web/app/src/Features/Institutions/InstitutionsAPI.js +++ b/services/web/app/src/Features/Institutions/InstitutionsAPI.js @@ -204,7 +204,7 @@ const InstitutionsAPI = { }, } -var makeAffiliationRequest = function (requestOptions, callback) { +function makeAffiliationRequest(requestOptions, callback) { if (!settings.apis.v1.url) { return callback(null) } // service is not configured diff --git a/services/web/app/src/Features/Institutions/InstitutionsController.js b/services/web/app/src/Features/Institutions/InstitutionsController.js index 3c26d3a296..1269fd13a9 100644 --- a/services/web/app/src/Features/Institutions/InstitutionsController.js +++ b/services/web/app/src/Features/Institutions/InstitutionsController.js @@ -17,7 +17,7 @@ module.exports = { }, } -var affiliateUsers = function (hostname, callback) { +function affiliateUsers(hostname, callback) { const reversedHostname = hostname.trim().split('').reverse().join('') UserGetter.getUsersByHostname(hostname, { _id: 1 }, function (error, users) { if (error) { @@ -40,11 +40,7 @@ var affiliateUsers = function (hostname, callback) { }) } -var affiliateUserByReversedHostname = function ( - user, - reversedHostname, - callback -) { +function affiliateUserByReversedHostname(user, reversedHostname, callback) { const matchingEmails = user.emails.filter( email => email.reversedHostname === reversedHostname ) diff --git a/services/web/app/src/Features/Institutions/InstitutionsManager.js b/services/web/app/src/Features/Institutions/InstitutionsManager.js index e346057e26..16c3de08b4 100644 --- a/services/web/app/src/Features/Institutions/InstitutionsManager.js +++ b/services/web/app/src/Features/Institutions/InstitutionsManager.js @@ -254,7 +254,7 @@ const InstitutionsManager = { }, } -var fetchInstitutionAndAffiliations = (institutionId, callback) => +const fetchInstitutionAndAffiliations = (institutionId, callback) => async.waterfall( [ cb => @@ -271,12 +271,12 @@ var fetchInstitutionAndAffiliations = (institutionId, callback) => callback ) -var refreshFeatures = function (affiliation, callback) { +function refreshFeatures(affiliation, callback) { const userId = ObjectId(affiliation.user_id) FeaturesUpdater.refreshFeatures(userId, 'refresh-institution-users', callback) } -var refreshFeaturesAndNotify = function (affiliation, callback) { +function refreshFeaturesAndNotify(affiliation, callback) { const userId = ObjectId(affiliation.user_id) async.waterfall( [ @@ -297,7 +297,7 @@ var refreshFeaturesAndNotify = function (affiliation, callback) { ) } -var getUserInfo = (userId, callback) => +const getUserInfo = (userId, callback) => async.waterfall( [ cb => UserGetter.getUser(userId, cb), @@ -309,7 +309,13 @@ var getUserInfo = (userId, callback) => callback ) -var notifyUser = (user, affiliation, subscription, featuresChanged, callback) => +const notifyUser = ( + user, + affiliation, + subscription, + featuresChanged, + callback +) => async.parallel( [ function (cb) { diff --git a/services/web/app/src/Features/Metadata/MetaHandler.js b/services/web/app/src/Features/Metadata/MetaHandler.js index c65e30051e..a37b3ddcc0 100644 --- a/services/web/app/src/Features/Metadata/MetaHandler.js +++ b/services/web/app/src/Features/Metadata/MetaHandler.js @@ -86,10 +86,10 @@ module.exports = MetaHandler = { const package_re = MetaHandler.usepackageRegex() const req_package_re = MetaHandler.ReqPackageRegex() for (const line of Array.from(lines)) { - var labelMatch - var clean, messy, packageMatch + let labelMatch + let clean, messy, packageMatch while ((labelMatch = label_re.exec(line))) { - var label + let label if ((label = labelMatch[1])) { docMeta.labels.push(label) } diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 6b0b607a27..7398bdab99 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -1065,7 +1065,7 @@ const ProjectController = { }, } -var defaultSettingsForAnonymousUser = userId => ({ +const defaultSettingsForAnonymousUser = userId => ({ id: userId, ace: { mode: 'none', @@ -1088,7 +1088,7 @@ var defaultSettingsForAnonymousUser = userId => ({ betaProgram: false, }) -var THEME_LIST = [] +const THEME_LIST = [] function generateThemeList() { const files = fs.readdirSync( Path.join(__dirname, '/../../../../node_modules/ace-builds/src-noconflict') diff --git a/services/web/app/src/Features/References/ReferencesHandler.js b/services/web/app/src/Features/References/ReferencesHandler.js index a81d144a63..87d8636c72 100644 --- a/services/web/app/src/Features/References/ReferencesHandler.js +++ b/services/web/app/src/Features/References/ReferencesHandler.js @@ -42,7 +42,7 @@ module.exports = ReferencesHandler = { _findBibFileIds(project) { const ids = [] - var _process = function (folder) { + function _process(folder) { _.each(folder.fileRefs || [], function (file) { if ( __guard__(file != null ? file.name : undefined, x1 => @@ -60,7 +60,7 @@ module.exports = ReferencesHandler = { _findBibDocIds(project) { const ids = [] - var _process = function (folder) { + function _process(folder) { _.each(folder.docs || [], function (doc) { if ( __guard__(doc != null ? doc.name : undefined, x1 => diff --git a/services/web/app/src/Features/ServerAdmin/AdminController.js b/services/web/app/src/Features/ServerAdmin/AdminController.js index 836a594344..9b5fa3a6eb 100644 --- a/services/web/app/src/Features/ServerAdmin/AdminController.js +++ b/services/web/app/src/Features/ServerAdmin/AdminController.js @@ -27,7 +27,7 @@ const SystemMessageManager = require('../SystemMessages/SystemMessageManager') const oneMinInMs = 60 * 1000 -var updateOpenConnetionsMetrics = function () { +function updateOpenConnetionsMetrics() { metrics.gauge( 'open_connections.socketio', __guard__( diff --git a/services/web/app/src/Features/Subscription/RecurlyWrapper.js b/services/web/app/src/Features/Subscription/RecurlyWrapper.js index 31c0f33e3e..e1f3060b99 100644 --- a/services/web/app/src/Features/Subscription/RecurlyWrapper.js +++ b/services/web/app/src/Features/Subscription/RecurlyWrapper.js @@ -556,7 +556,7 @@ const RecurlyWrapper = { getPaginatedEndpoint(resource, queryParams, callback) { queryParams.per_page = queryParams.per_page || 200 let allItems = [] - var getPage = (cursor = null) => { + const getPage = (cursor = null) => { const opts = { url: resource, qs: queryParams, @@ -950,7 +950,7 @@ const RecurlyWrapper = { }, _parseXml(xml, callback) { - var convertDataTypes = function (data) { + function convertDataTypes(data) { let key, value if (data != null && data.$ != null) { if (data.$.nil === 'nil') { diff --git a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js index 69743c2aea..25b920c918 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js +++ b/services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js @@ -106,7 +106,7 @@ const SubscriptionGroupHandler = { }, } -var replaceInArray = function (model, property, oldValue, newValue, callback) { +function replaceInArray(model, property, oldValue, newValue, callback) { // Mongo won't let us pull and addToSet in the same query, so do it in // two. Note we need to add first, since the query is based on the old user. const query = {} diff --git a/services/web/app/src/Features/Subscription/TeamInvitesHandler.js b/services/web/app/src/Features/Subscription/TeamInvitesHandler.js index 3646dccd2c..b2ca4ee03f 100644 --- a/services/web/app/src/Features/Subscription/TeamInvitesHandler.js +++ b/services/web/app/src/Features/Subscription/TeamInvitesHandler.js @@ -129,7 +129,7 @@ module.exports = TeamInvitesHandler = { }, } -var createInvite = function (subscription, email, inviter, callback) { +function createInvite(subscription, email, inviter, callback) { checkIfInviteIsPossible( subscription, email, @@ -205,7 +205,7 @@ var createInvite = function (subscription, email, inviter, callback) { ) } -var removeInviteFromTeam = function (subscriptionId, email, callback) { +function removeInviteFromTeam(subscriptionId, email, callback) { const searchConditions = { _id: new ObjectId(subscriptionId.toString()) } const removeInvite = { $pull: { teamInvites: { email } } } @@ -218,7 +218,7 @@ var removeInviteFromTeam = function (subscriptionId, email, callback) { ) } -var removeLegacyInvite = (subscriptionId, email, callback) => +const removeLegacyInvite = (subscriptionId, email, callback) => Subscription.updateOne( { _id: new ObjectId(subscriptionId.toString()), @@ -231,7 +231,7 @@ var removeLegacyInvite = (subscriptionId, email, callback) => callback ) -var checkIfInviteIsPossible = function (subscription, email, callback) { +function checkIfInviteIsPossible(subscription, email, callback) { if (!subscription.groupPlan) { logger.log( { subscriptionId: subscription.id }, @@ -272,7 +272,7 @@ var checkIfInviteIsPossible = function (subscription, email, callback) { }) } -var getInviterName = function (inviter) { +function getInviterName(inviter) { let inviterName if (inviter.first_name && inviter.last_name) { inviterName = `${inviter.first_name} ${inviter.last_name} (${inviter.email})` diff --git a/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js b/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js index 5ad9585a8a..6940d204db 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js @@ -59,7 +59,7 @@ module.exports = UpdateMerger = { if (err != null) { return callback(err) } - var existingFileType = null + let existingFileType = null if (_.some(files, f => f.path === path)) { existingFileType = 'file' } diff --git a/services/web/app/src/Features/User/UserGetter.js b/services/web/app/src/Features/User/UserGetter.js index 6649459b0b..54d4a73329 100644 --- a/services/web/app/src/Features/User/UserGetter.js +++ b/services/web/app/src/Features/User/UserGetter.js @@ -205,7 +205,7 @@ const UserGetter = { }, } -var decorateFullEmails = ( +const decorateFullEmails = ( defaultEmail, emailsData, affiliationsData, diff --git a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js index 80da3476ae..8f9f32d4de 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipHandler.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipHandler.js @@ -91,7 +91,7 @@ const UserMembershipHandler = { UserMembershipHandler.promises = promisifyAll(UserMembershipHandler) module.exports = UserMembershipHandler -var getPopulatedListOfMembers = function (entity, attributes, callback) { +function getPopulatedListOfMembers(entity, attributes, callback) { if (callback == null) { callback = function (error, users) {} } @@ -110,7 +110,7 @@ var getPopulatedListOfMembers = function (entity, attributes, callback) { return async.map(userObjects, UserMembershipViewModel.buildAsync, callback) } -var addUserToEntity = function (entity, attribute, user, callback) { +function addUserToEntity(entity, attribute, user, callback) { if (callback == null) { callback = function (error) {} } @@ -119,7 +119,7 @@ var addUserToEntity = function (entity, attribute, user, callback) { return entity.updateOne({ $addToSet: fieldUpdate }, callback) } -var removeUserFromEntity = function (entity, attribute, userId, callback) { +function removeUserFromEntity(entity, attribute, userId, callback) { if (callback == null) { callback = function (error) {} } @@ -128,7 +128,7 @@ var removeUserFromEntity = function (entity, attribute, userId, callback) { return entity.updateOne({ $pull: fieldUpdate }, callback) } -var buildEntityQuery = function (entityId, entityConfig, loggedInUser) { +function buildEntityQuery(entityId, entityConfig, loggedInUser) { if (ObjectId.isValid(entityId.toString())) { entityId = ObjectId(entityId) } diff --git a/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js b/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js index 1af1637777..99ba0fb71e 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipViewModel.js @@ -48,7 +48,7 @@ module.exports = UserMembershipViewModel = { }, } -var buildUserViewModel = function (user, isInvite) { +function buildUserViewModel(user, isInvite) { if (isInvite == null) { isInvite = false } @@ -62,6 +62,6 @@ var buildUserViewModel = function (user, isInvite) { } } -var buildUserViewModelWithEmail = email => buildUserViewModel({ email }, true) +const buildUserViewModelWithEmail = email => buildUserViewModel({ email }, true) -var buildUserViewModelWithId = id => buildUserViewModel({ _id: id }, false) +const buildUserViewModelWithId = id => buildUserViewModel({ _id: id }, false) diff --git a/services/web/app/src/infrastructure/Modules.js b/services/web/app/src/infrastructure/Modules.js index 0c3ad5a5a4..43a81a0590 100644 --- a/services/web/app/src/infrastructure/Modules.js +++ b/services/web/app/src/infrastructure/Modules.js @@ -106,7 +106,7 @@ function linkedFileAgentsIncludes() { } function attachHooks() { - for (var module of _modules) { + for (const module of _modules) { if (module.hooks != null) { for (const hook in module.hooks) { const method = module.hooks[hook] diff --git a/services/web/app/src/infrastructure/ProxyManager.js b/services/web/app/src/infrastructure/ProxyManager.js index 96edb415bb..bbeff7b1d0 100644 --- a/services/web/app/src/infrastructure/ProxyManager.js +++ b/services/web/app/src/infrastructure/ProxyManager.js @@ -20,7 +20,7 @@ module.exports = ProxyManager = { apply(publicApiRouter) { return (() => { const result = [] - for (var proxyUrl in settings.proxyUrls) { + for (const proxyUrl in settings.proxyUrls) { const target = settings.proxyUrls[proxyUrl] result.push( (function (target) { @@ -67,7 +67,7 @@ module.exports = ProxyManager = { // make a URL from a proxy target. // if the query is specified, set/replace the target's query with the given query -var makeTargetUrl = function (target, req) { +function makeTargetUrl(target, req) { const targetUrl = new URL(parseSettingUrl(target, req)) if (req.query != null && Object.keys(req.query).length > 0) { targetUrl.search = new URLSearchParams(req.query).toString() @@ -75,7 +75,7 @@ var makeTargetUrl = function (target, req) { return targetUrl.href } -var parseSettingUrl = function (target, { params }) { +function parseSettingUrl(target, { params }) { let path if (typeof target === 'string') { return target diff --git a/services/web/app/src/infrastructure/RedirectManager.js b/services/web/app/src/infrastructure/RedirectManager.js index 638aa3f9dd..2a11af8d6b 100644 --- a/services/web/app/src/infrastructure/RedirectManager.js +++ b/services/web/app/src/infrastructure/RedirectManager.js @@ -20,8 +20,8 @@ module.exports = RedirectManager = { apply(webRouter) { return (() => { const result = [] - for (var redirectUrl in settings.redirects) { - var target = settings.redirects[redirectUrl] + for (const redirectUrl in settings.redirects) { + const target = settings.redirects[redirectUrl] result.push( Array.from(target.methods || ['get']).map(method => webRouter[method]( @@ -73,7 +73,7 @@ module.exports = RedirectManager = { // Naively get the query params string. Stringifying the req.query object may // have differences between Express and Rails, so safer to just pass the raw // string -var getQueryString = function (req) { +function getQueryString(req) { const { search } = new URL(req.originalUrl, settings.siteUrl) if (search) { return search diff --git a/services/web/app/src/router.js b/services/web/app/src/router.js index 75f8ffac25..34144a55ed 100644 --- a/services/web/app/src/router.js +++ b/services/web/app/src/router.js @@ -1067,7 +1067,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) { ClsiCookieManager.clearServerId(projectId) }) // force every compile to a new server // set a timeout - var handler = setTimeout(function () { + let handler = setTimeout(function () { sendRes(500, 'Compiler timed out') handler = null }, 10000) diff --git a/services/web/frontend/js/features/preview/components/preview-log-entry-header.js b/services/web/frontend/js/features/preview/components/preview-log-entry-header.js index d5cf82d7f2..5047bf19fc 100644 --- a/services/web/frontend/js/features/preview/components/preview-log-entry-header.js +++ b/services/web/frontend/js/features/preview/components/preview-log-entry-header.js @@ -91,7 +91,7 @@ function PreviewLogEntryHeader({ ) : null - var headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle + const headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle return (
diff --git a/services/web/frontend/js/ide/directives/layout.js b/services/web/frontend/js/ide/directives/layout.js index 0007801dc4..9a66321de5 100644 --- a/services/web/frontend/js/ide/directives/layout.js +++ b/services/web/frontend/js/ide/directives/layout.js @@ -135,7 +135,7 @@ export default App.directive('layout', ($parse, $compile, ide) => ({ } // Someone moved the resizer - var onInternalResize = function () { + function onInternalResize() { state = element.layout().readState() scope.$broadcast(`layout:${name}:resize`, state) repositionControls() @@ -212,7 +212,7 @@ ng-click=\"handleClick()\">\ element.append(customTogglerEl) } - var onPaneOpen = function (pane) { + function onPaneOpen(pane) { if (!hasCustomToggler && pane !== customTogglerPane) { return } @@ -221,7 +221,7 @@ ng-click=\"handleClick()\">\ .$applyAsync(() => (customTogglerEl.scope().isOpen = true)) } - var onPaneClose = function (pane) { + function onPaneClose(pane) { if (!hasCustomToggler && pane !== customTogglerPane) { return } diff --git a/services/web/frontend/js/ide/editor/Document.js b/services/web/frontend/js/ide/editor/Document.js index 9bfbfac57b..c592b841df 100644 --- a/services/web/frontend/js/ide/editor/Document.js +++ b/services/web/frontend/js/ide/editor/Document.js @@ -302,7 +302,7 @@ export default Document = (function () { const orig = char let copy = null let pos = 0 - var timer = () => { + const timer = () => { if (copy == null || !copy.length) { copy = orig.slice() + ' ' + new Date() + '\n' line += Math.random() > 0.1 ? 1 : -2 @@ -751,11 +751,11 @@ export default Document = (function () { this.ranges.changes = changes this.ranges.comments = comments this.ranges.track_changes = this.doc.track_changes - for (var op of Array.from(this.doc.getInflightOp() || [])) { + for (const op of Array.from(this.doc.getInflightOp() || [])) { this.ranges.setIdSeed(this.doc.track_changes_id_seeds.inflight) this.ranges.applyOp(op, { user_id: this.track_changes_as }) } - for (op of Array.from(this.doc.getPendingOp() || [])) { + for (const op of Array.from(this.doc.getPendingOp() || [])) { this.ranges.setIdSeed(this.doc.track_changes_id_seeds.pending) this.ranges.applyOp(op, { user_id: this.track_changes_as }) } diff --git a/services/web/frontend/js/ide/editor/ShareJsDoc.js b/services/web/frontend/js/ide/editor/ShareJsDoc.js index 402f096fea..a3dfda46e5 100644 --- a/services/web/frontend/js/ide/editor/ShareJsDoc.js +++ b/services/web/frontend/js/ide/editor/ShareJsDoc.js @@ -214,7 +214,7 @@ export default ShareJsDoc = (function () { this._pushOntoQueue(message) return // defer processing this update for now } - var error = this.processUpdateFromServer(message) + const error = this.processUpdateFromServer(message) if ( error instanceof Error && error.message === 'Invalid version from server' @@ -383,7 +383,7 @@ export default ShareJsDoc = (function () { _startInflightOpTimeout(update) { this._startFatalTimeoutTimer(update) - var retryOp = () => { + const retryOp = () => { // Only send the update again if inflightOp is still populated // This can be cleared when hard reloading the document in which // case we don't want to keep trying to send it. diff --git a/services/web/frontend/js/ide/editor/controllers/SavingNotificationController.js b/services/web/frontend/js/ide/editor/controllers/SavingNotificationController.js index 9dea747dd2..4e5b9ee548 100644 --- a/services/web/frontend/js/ide/editor/controllers/SavingNotificationController.js +++ b/services/web/frontend/js/ide/editor/controllers/SavingNotificationController.js @@ -29,7 +29,7 @@ export default App.controller( const MAX_UNSAVED_SECONDS = 15 // lock the editor after this time if unsaved $scope.docSavingStatus = {} - var pollSavedStatus = function () { + function pollSavedStatus() { let t const oldStatus = $scope.docSavingStatus const oldUnsavedCount = $scope.docSavingStatusCount diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor.js b/services/web/frontend/js/ide/editor/directives/aceEditor.js index 89c1bf52b7..b0bb24d937 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor.js @@ -450,7 +450,7 @@ App.directive( return setScrollMargins(marginTop, marginBottom) }) - var setScrollMargins = function (marginTop, marginBottom) { + function setScrollMargins(marginTop, marginBottom) { let marginChanged = false if (editor.renderer.scrollMargin.top !== marginTop) { editor.renderer.scrollMargin.top = marginTop @@ -744,7 +744,7 @@ App.directive( scope.$broadcast('editorInit') ) - var attachToAce = function (sharejs_doc) { + function attachToAce(sharejs_doc) { let mode const lines = sharejs_doc.getSnapshot().split('\n') let session = editor.getSession() @@ -862,7 +862,7 @@ App.directive( return editor.focus() } - var detachFromAce = function (sharejs_doc) { + function detachFromAce(sharejs_doc) { tearDownSpellCheck() tearDownTrackChanges() tearDownUndo() diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js index 69cb23a396..cd13330d8b 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js @@ -146,7 +146,7 @@ export default CommandManager = class CommandManager { getCompletions(editor, session, pos, prefix, callback) { const commandNames = {} - for (var snippet of Array.from(topHundred)) { + for (const snippet of Array.from(topHundred)) { commandNames[snippet.caption.match(/\w+/)[0]] = true } @@ -154,7 +154,7 @@ export default CommandManager = class CommandManager { const packageCommands = [] for (const pkg in packages) { const snippets = packages[pkg] - for (snippet of Array.from(snippets)) { + for (const snippet of Array.from(snippets)) { packageCommands.push(snippet) commandNames[snippet.caption.match(/\w+/)[0]] = true } @@ -168,8 +168,8 @@ export default CommandManager = class CommandManager { if (!commandNames[command[0]]) { let caption = `\\${command[0]}` const score = caption === prefix ? 99 : 50 - snippet = caption - var i = 1 + let snippet = caption + let i = 1 _.times(command[1], function () { snippet += `[\${${i}}]` caption += '[]' diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/Helpers.js b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/Helpers.js index 572cc63af3..228b697432 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/Helpers.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/Helpers.js @@ -15,7 +15,7 @@ import 'ace/ace' import 'ace/ext-language_tools' const { Range } = ace.require('ace/range') -var Helpers = { +const Helpers = { getLastCommandFragment(lineUpToCursor) { let index if ((index = Helpers.getLastCommandFragmentIndex(lineUpToCursor)) > -1) { diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js index caaad3986d..837e61f4b5 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js @@ -362,7 +362,7 @@ class SpellCheckManager { let line = lines[row] const rowIdx = rowNumsToCheck[row] line = this.blankOutBlacklistedCommands(line) - var result + let result WORD_REGEX.lastIndex = 0 // reset global stateful regexp for this usage while ((result = WORD_REGEX.exec(line))) { let word = result[0] diff --git a/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js b/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js index f66f2433a8..b9333b716d 100644 --- a/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js +++ b/services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js @@ -203,7 +203,7 @@ class TrackChangesManager { let updateMarkers = false - for (var id in dirty.change.added) { + for (const id in dirty.change.added) { change = dirty.change.added[id] if (change.op.i != null) { this.adapter.onInsertAdded(change) @@ -211,7 +211,7 @@ class TrackChangesManager { this.adapter.onDeleteAdded(change) } } - for (id in dirty.change.removed) { + for (const id in dirty.change.removed) { change = dirty.change.removed[id] if (change.op.i != null) { this.adapter.onInsertRemoved(change) @@ -219,25 +219,25 @@ class TrackChangesManager { this.adapter.onDeleteRemoved(change) } } - for (id in dirty.change.moved) { + for (const id in dirty.change.moved) { change = dirty.change.moved[id] updateMarkers = true this.adapter.onChangeMoved(change) } - for (id in dirty.comment.added) { + for (const id in dirty.comment.added) { comment = dirty.comment.added[id] if (!this.isCommentResolved(comment)) { this.adapter.onCommentAdded(comment) } } - for (id in dirty.comment.removed) { + for (const id in dirty.comment.removed) { comment = dirty.comment.removed[id] if (!this.isCommentResolved(comment)) { this.adapter.onCommentRemoved(comment) } } - for (id in dirty.comment.moved) { + for (const id in dirty.comment.moved) { comment = dirty.comment.moved[id] if (this.adapter.onCommentMoved && !this.isCommentResolved(comment)) { updateMarkers = true @@ -487,13 +487,13 @@ class TrackChangesManager { // Make a copy of session.getMarkers() so we can modify it const markers = {} const object = session.getMarkers() - for (var marker_id in object) { + for (const marker_id in object) { marker = object[marker_id] markers[marker_id] = marker } const expected_markers = [] - for (var change of Array.from(this.rangesTracker.changes)) { + for (const change of Array.from(this.rangesTracker.changes)) { if (this.adapter.changeIdToMarkerIdMap[change.id] != null) { ;({ op } = change) ;({ @@ -542,7 +542,7 @@ class TrackChangesManager { } } - for ({ marker_id, start, end } of Array.from(expected_markers)) { + for (const { marker_id, start, end } of Array.from(expected_markers)) { marker = markers[marker_id] delete markers[marker_id] if ( @@ -552,7 +552,6 @@ class TrackChangesManager { marker.range.end.column !== end.column ) { console.error("Change doesn't match marker anymore", { - change, marker, start, end, @@ -562,7 +561,7 @@ class TrackChangesManager { return (() => { const result = [] - for (marker_id in markers) { + for (const marker_id in markers) { marker = markers[marker_id] if (/track-changes/.test(marker.clazz)) { result.push(console.error('Orphaned ace marker', marker)) diff --git a/services/web/frontend/js/ide/file-tree/FileTreeManager.js b/services/web/frontend/js/ide/file-tree/FileTreeManager.js index 7e4d96b1c1..9657a8ee68 100644 --- a/services/web/frontend/js/ide/file-tree/FileTreeManager.js +++ b/services/web/frontend/js/ide/file-tree/FileTreeManager.js @@ -180,12 +180,12 @@ export default FileTreeManager = class FileTreeManager { // problems with reserved Object properties const entities = this.getMultiSelectedEntities() const paths = {} - for (var entity of Array.from(entities)) { + for (const entity of Array.from(entities)) { paths['/' + this.getEntityPath(entity)] = entity } const prefixes = {} - for (var path in paths) { - entity = paths[path] + for (const path in paths) { + const entity = paths[path] const parts = path.split('/') if (parts.length <= 2) { continue @@ -201,10 +201,10 @@ export default FileTreeManager = class FileTreeManager { } } const child_entities = [] - for (path in paths) { + for (const path in paths) { // If the path is in the prefixes, then it's a parent folder and // should be ignore - entity = paths[path] + const entity = paths[path] if (prefixes[path] == null) { child_entities.push(entity) } @@ -337,7 +337,7 @@ export default FileTreeManager = class FileTreeManager { return (() => { const result = [] for (const entity of Array.from(folder.children || [])) { - var childPath + let childPath if (path != null) { childPath = path + '/' + entity.name } else { diff --git a/services/web/frontend/js/ide/history/HistoryManager.js b/services/web/frontend/js/ide/history/HistoryManager.js index 1ae712cd35..5924bd02be 100644 --- a/services/web/frontend/js/ide/history/HistoryManager.js +++ b/services/web/frontend/js/ide/history/HistoryManager.js @@ -208,7 +208,7 @@ export default HistoryManager = (function () { let text = '' const iterable = diff.diff || [] for (let i = 0; i < iterable.length; i++) { - var endColumn, endRow + let endColumn, endRow const entry = iterable[i] let content = entry.u || entry.i || entry.d if (!content) { diff --git a/services/web/frontend/js/ide/history/HistoryV2Manager.js b/services/web/frontend/js/ide/history/HistoryV2Manager.js index d4c803db0e..2aa84b5bb3 100644 --- a/services/web/frontend/js/ide/history/HistoryV2Manager.js +++ b/services/web/frontend/js/ide/history/HistoryV2Manager.js @@ -839,7 +839,7 @@ export default HistoryManager = (function () { let text = '' const iterable = diff || [] for (let i = 0; i < iterable.length; i++) { - var endColumn, endRow + let endColumn, endRow const entry = iterable[i] let content = entry.u || entry.i || entry.d if (!content) { diff --git a/services/web/frontend/js/ide/history/components/historyFileEntity.js b/services/web/frontend/js/ide/history/components/historyFileEntity.js index 912a49d30b..8ce52c1d87 100644 --- a/services/web/frontend/js/ide/history/components/historyFileEntity.js +++ b/services/web/frontend/js/ide/history/components/historyFileEntity.js @@ -40,8 +40,9 @@ const historyFileEntityController = function ($scope, $element, $attrs) { const path1Parts = path1.split('/') const path2Parts = path2.split('/') const maxIterations = Math.min(path1Parts.length, path2Parts.length) - 1 + let commonPartIndex for ( - var commonPartIndex = 0; + commonPartIndex = 0; commonPartIndex < maxIterations; commonPartIndex++ ) { @@ -61,7 +62,7 @@ const historyFileEntityController = function ($scope, $element, $attrs) { const _handleFileClick = () => ctrl.historyFileTreeController.handleEntityClick(ctrl.fileEntity) - var _getFolderIcon = function () { + function _getFolderIcon() { if (ctrl.isOpen) { return 'fa-folder-open' } else { diff --git a/services/web/frontend/js/ide/history/components/historyFileTree.js b/services/web/frontend/js/ide/history/components/historyFileTree.js index c33ed670ef..bcc1b38203 100644 --- a/services/web/frontend/js/ide/history/components/historyFileTree.js +++ b/services/web/frontend/js/ide/history/components/historyFileTree.js @@ -23,8 +23,8 @@ const historyFileTreeController = function ($scope, $element, $attrs) { const filePathParts = fileObject.pathname.split('/') let currentFileTreeLocation = currentFileTree for (let index = 0; index < filePathParts.length; index++) { - var fileTreeEntity - var pathPart = filePathParts[index] + let fileTreeEntity + const pathPart = filePathParts[index] const isFile = index === filePathParts.length - 1 if (isFile) { fileTreeEntity = _.clone(fileObject) diff --git a/services/web/frontend/js/ide/history/controllers/HistoryListController.js b/services/web/frontend/js/ide/history/controllers/HistoryListController.js index bc8c12fc99..e2c0d631cd 100644 --- a/services/web/frontend/js/ide/history/controllers/HistoryListController.js +++ b/services/web/frontend/js/ide/history/controllers/HistoryListController.js @@ -62,7 +62,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) { return (() => { const result = [] for (const update of Array.from($scope.history.updates)) { - var inSelection + let inSelection if (update.selectedTo) { inSelection = true beforeSelection = false @@ -91,7 +91,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) { let inHoverSelection let hoverSelectedFrom = false let hoverSelectedTo = false - for (var update of Array.from($scope.history.updates)) { + for (const update of Array.from($scope.history.updates)) { // Figure out whether the to or from selector is hovered over if (update.hoverSelectedFrom) { hoverSelectedFrom = true @@ -104,7 +104,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) { if (hoverSelectedFrom) { // We want to 'hover select' everything between hoverSelectedFrom and selectedTo inHoverSelection = false - for (update of Array.from($scope.history.updates)) { + for (const update of Array.from($scope.history.updates)) { if (update.selectedTo) { update.hoverSelectedTo = true inHoverSelection = true @@ -120,7 +120,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) { inHoverSelection = false return (() => { const result = [] - for (update of Array.from($scope.history.updates)) { + for (const update of Array.from($scope.history.updates)) { if (update.hoverSelectedTo) { inHoverSelection = true } diff --git a/services/web/frontend/js/ide/history/directives/infiniteScroll.js b/services/web/frontend/js/ide/history/directives/infiniteScroll.js index fa93cd925e..b559b28990 100644 --- a/services/web/frontend/js/ide/history/directives/infiniteScroll.js +++ b/services/web/frontend/js/ide/history/directives/infiniteScroll.js @@ -24,15 +24,15 @@ export default App.directive('infiniteScroll', () => ({ } } - var atTopOfListView = () => element.scrollTop() < 30 + const atTopOfListView = () => element.scrollTop() < 30 - var atBottomOfListView = () => + const atBottomOfListView = () => element.scrollTop() + element.height() >= innerElement.height() - 30 const listShorterThanContainer = () => element.height() > innerElement.height() - var loadUntilFull = function () { + function loadUntilFull() { if ( (listShorterThanContainer() || atEndOfListView()) && !scope.$eval(attrs.infiniteScrollDisabled) diff --git a/services/web/frontend/js/ide/human-readable-logs/HumanReadableLogs.js b/services/web/frontend/js/ide/human-readable-logs/HumanReadableLogs.js index df2523dbb8..4715db68de 100644 --- a/services/web/frontend/js/ide/human-readable-logs/HumanReadableLogs.js +++ b/services/web/frontend/js/ide/human-readable-logs/HumanReadableLogs.js @@ -25,7 +25,7 @@ export default { const ruleDetails = _getRule(entry.message) if (ruleDetails != null) { - var type + let type if (ruleDetails.ruleId != null) { entry.ruleId = ruleDetails.ruleId } else if (ruleDetails.regexToMatch != null) { diff --git a/services/web/frontend/js/ide/log-parser/bib-log-parser.js b/services/web/frontend/js/ide/log-parser/bib-log-parser.js index 38b0f6b58d..f132370b5d 100644 --- a/services/web/frontend/js/ide/log-parser/bib-log-parser.js +++ b/services/web/frontend/js/ide/log-parser/bib-log-parser.js @@ -28,9 +28,9 @@ const parserReducer = function (accumulator, parser) { // Too many log entries can cause browser crashes // Construct a too many files error from the last match - var maxErrors = 100 + const maxErrors = 100 if (iterationCount >= maxErrors) { - var level = newEntry.level + 's' + const level = newEntry.level + 's' newEntry.message = [ 'Over', maxErrors, diff --git a/services/web/frontend/js/ide/online-users/OnlineUsersManager.js b/services/web/frontend/js/ide/online-users/OnlineUsersManager.js index 8b3af10cac..7461c8330b 100644 --- a/services/web/frontend/js/ide/online-users/OnlineUsersManager.js +++ b/services/web/frontend/js/ide/online-users/OnlineUsersManager.js @@ -92,7 +92,7 @@ export default OnlineUsersManager = (function () { refreshOnlineUsers() { this.$scope.onlineUsersArray = [] - for (var client_id in this.$scope.onlineUsers) { + for (const client_id in this.$scope.onlineUsers) { const user = this.$scope.onlineUsers[client_id] if (user.doc_id != null) { user.doc = this.ide.fileTreeManager.findEntityById(user.doc_id) @@ -120,7 +120,7 @@ export default OnlineUsersManager = (function () { this.$scope.onlineUsersCount = this.$scope.onlineUsersArray.length this.$scope.onlineUserCursorHighlights = {} - for (client_id in this.$scope.onlineUsers) { + for (const client_id in this.$scope.onlineUsers) { const client = this.$scope.onlineUsers[client_id] const { doc_id } = client if (doc_id == null || client.row == null || client.column == null) { diff --git a/services/web/frontend/js/ide/pdf/controllers/PdfController.js b/services/web/frontend/js/ide/pdf/controllers/PdfController.js index b8804a4290..304df438bf 100644 --- a/services/web/frontend/js/ide/pdf/controllers/PdfController.js +++ b/services/web/frontend/js/ide/pdf/controllers/PdfController.js @@ -615,7 +615,7 @@ App.controller( const errors = [] const warnings = [] for (const line of log.split('\n')) { - var m + let m if ((m = line.match(/^(\S+):(\d+):(\d+): (Error|Warning): (.*)/))) { const result = { file: m[1], diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfJsLoader.js b/services/web/frontend/js/ide/pdfng/directives/pdfJsLoader.js index 4d6400ad2b..b655d4cb48 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfJsLoader.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfJsLoader.js @@ -18,8 +18,8 @@ * to customise the loader's options. However the rest of the file is identical * to the one provided by PDF.js. */ -var pdfjs = require('../../../vendor/libs/pdfjs-dist/build/pdf.js') -var PdfjsWorker = require('../../../vendor/libs/pdfjs-dist/build/pdf.worker.js') +const pdfjs = require('../../../vendor/libs/pdfjs-dist/build/pdf.js') +const PdfjsWorker = require('../../../vendor/libs/pdfjs-dist/build/pdf.worker.js') if (typeof window !== 'undefined' && 'Worker' in window) { pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker() diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfPage.js b/services/web/frontend/js/ide/pdfng/directives/pdfPage.js index fbef075c21..147383613d 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfPage.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfPage.js @@ -61,7 +61,7 @@ export default App.directive( } else { // shouldn't get here - the default page size should now // always be set before redraw is called - var handler = scope.$watch( + const handler = scope.$watch( 'defaultPageSize', function (defaultPageSize) { if (defaultPageSize == null) { diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js b/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js index e0d3ee987c..6347ce03c8 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js @@ -230,7 +230,7 @@ export default App.factory( startIndicators() { // make an array of the pages in the queue this.queuedPages = [] - for (var page of Array.from(this.renderQueue)) { + for (const page of Array.from(this.renderQueue)) { this.queuedPages[page.pagenum] = true } // clear any unfinished spinner timers on pages that aren't in the queue any more @@ -243,7 +243,7 @@ export default App.factory( // add indicators for any new pages in the current queue return (() => { const result = [] - for (page of Array.from(this.renderQueue)) { + for (const page of Array.from(this.renderQueue)) { if ( !this.spinTimer[page.pagenum] && !this.spinTimerDone[page.pagenum] @@ -348,7 +348,7 @@ export default App.factory( : undefined }, this.PAGE_LOAD_TIMEOUT) - var loadTask = this.getPage(pagenum) + const loadTask = this.getPage(pagenum) loadTask.cancel = function () { return (this.cancelled = true) diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js b/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js index 21ffa680bf..1ec5ed3a9c 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfViewer.js @@ -360,7 +360,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ return scope.document.renderPages(pages) } - var getVisiblePages = function () { + function getVisiblePages() { const top = element[0].scrollTop const bottom = top + element[0].clientHeight const visiblePages = _.filter(scope.pages, function (page) { @@ -376,7 +376,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ return visiblePages } - var getExtraPages = function (visiblePages) { + function getExtraPages(visiblePages) { const extra = [] if (visiblePages.length > 0) { const firstVisiblePage = visiblePages[0].pageNum @@ -417,7 +417,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ } let spinnerTimer = null - var doRescale = function (scale) { + function doRescale(scale) { // console.log 'doRescale', scale if (scale == null) { return @@ -455,8 +455,8 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ }) } - var elementTimer = null - var updateLayout = function () { + let elementTimer = null + function updateLayout() { // if element is zero-sized keep checking until it is ready // console.log 'checking element ready', element.height(), element.width() if (element.height() === 0 || element.width() === 0) { @@ -477,7 +477,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ } } - var layoutTimer = null + let layoutTimer = null const queueLayout = function () { // console.log 'call to queue layout' if (layoutTimer != null) { @@ -571,7 +571,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ let mouseUpHandler = null // keep track of the handler to avoid adding multiple times - var _setMouseUpHandler = function () { + function _setMouseUpHandler() { if (mouseUpHandler == null) { return (mouseUpHandler = $(document.body).one( 'mouseup', @@ -580,7 +580,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ } } - var _handleSelectionMouseUp = function () { + function _handleSelectionMouseUp() { mouseUpHandler = null // reset handler, has now fired window.setTimeout(function () { const removedClass = _removeClassIfNoSelection() @@ -592,7 +592,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ return true } - var _removeClassIfNoSelection = function () { + function _removeClassIfNoSelection() { if (_hasSelection()) { return false // didn't remove the text layer } else { @@ -601,7 +601,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ } } - var _hasSelection = function () { + function _hasSelection() { const selection = typeof window.getSelection === 'function' ? window.getSelection() @@ -616,7 +616,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ ) } - var _isSelectionWithinPDF = function (selection) { + function _isSelectionWithinPDF(selection) { if (selection.rangeCount === 0) { return false } @@ -642,7 +642,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({ return (scope.scrollHandlerTimeout = setTimeout(scrollHandler, 25)) }) - var scrollHandler = function () { + function scrollHandler() { renderVisiblePages() const newPosition = ctrl.getPdfPosition() if (newPosition != null) { diff --git a/services/web/frontend/js/ide/preamble/services/preamble.js b/services/web/frontend/js/ide/preamble/services/preamble.js index 54705d9dcb..6eeaf69c30 100644 --- a/services/web/frontend/js/ide/preamble/services/preamble.js +++ b/services/web/frontend/js/ide/preamble/services/preamble.js @@ -12,7 +12,7 @@ import App from '../../../base' export default App.factory('preamble', function (ide) { - var Preamble = { + const Preamble = { getPreambleText() { const text = ide.editorManager.getCurrentDocValue().slice(0, 5000) const preamble = diff --git a/services/web/frontend/js/ide/review-panel/RangesTracker.js b/services/web/frontend/js/ide/review-panel/RangesTracker.js index 6add6d35b7..9d8fed093d 100644 --- a/services/web/frontend/js/ide/review-panel/RangesTracker.js +++ b/services/web/frontend/js/ide/review-panel/RangesTracker.js @@ -324,7 +324,7 @@ export default RangesTracker = class RangesTracker { // delete is fully after comment, nothing to do } else { // delete and comment overlap - var remaining_after, remaining_before + let remaining_after, remaining_before if (op_start <= comment_start) { remaining_before = '' } else { @@ -402,7 +402,7 @@ export default RangesTracker = class RangesTracker { } } } else if (change.op.i != null) { - var offset + let offset const change_end = change_start + change.op.i.length const is_change_overlapping = op_start >= change_start && op_start <= change_end @@ -535,8 +535,8 @@ export default RangesTracker = class RangesTracker { // all the modifications after looping through the existing changes, so as not to mess up the // offset indexes as we go. const op_modifications = [] - for (var change of Array.from(this.changes)) { - var change_start + for (const change of Array.from(this.changes)) { + let change_start if (change.op.i != null) { change_start = change.op.p const change_end = change_start + change.op.i.length @@ -550,7 +550,7 @@ export default RangesTracker = class RangesTracker { // When the new delete overlaps an insert, we should remove the part of the insert that // is now deleted, and also remove the part of the new delete that overlapped. I.e. // the two cancel out where they overlap. - var delete_remaining_after, + let delete_remaining_after, delete_remaining_before, insert_remaining_after, insert_remaining_before @@ -645,7 +645,7 @@ export default RangesTracker = class RangesTracker { d: this._applyOpModifications(op.d, op_modifications), } - for (change of Array.from(remove_changes)) { + for (const change of Array.from(remove_changes)) { // This is a bit of hack to avoid removing one delete and replacing it with another. // If we don't do this, it causes the UI to flicker if ( @@ -675,7 +675,7 @@ export default RangesTracker = class RangesTracker { // We need to merge these together again const results = this._scanAndMergeAdjacentUpdates() moved_changes = moved_changes.concat(results.moved_changes) - for (change of Array.from(results.remove_changes)) { + for (const change of Array.from(results.remove_changes)) { this._removeChange(change) moved_changes = moved_changes.filter(c => c !== change) } @@ -683,7 +683,7 @@ export default RangesTracker = class RangesTracker { return (() => { const result = [] - for (change of Array.from(moved_changes)) { + for (const change of Array.from(moved_changes)) { result.push(this._markAsDirty(change, 'change', 'moved')) } return result diff --git a/services/web/frontend/js/ide/review-panel/controllers/ReviewPanelController.js b/services/web/frontend/js/ide/review-panel/controllers/ReviewPanelController.js index 2ec1ed5439..3d50f115f3 100644 --- a/services/web/frontend/js/ide/review-panel/controllers/ReviewPanelController.js +++ b/services/web/frontend/js/ide/review-panel/controllers/ReviewPanelController.js @@ -247,14 +247,14 @@ export default App.controller( return $scope.reviewPanel.resolvedComments[doc_id] } - var getThread = function (thread_id) { + function getThread(thread_id) { if ($scope.reviewPanel.commentThreads[thread_id] == null) { $scope.reviewPanel.commentThreads[thread_id] = { messages: [] } } return $scope.reviewPanel.commentThreads[thread_id] } - var getChangeTracker = function (doc_id) { + function getChangeTracker(doc_id) { if (rangesTrackers[doc_id] == null) { rangesTrackers[doc_id] = new RangesTracker() rangesTrackers[doc_id].resolvedThreadIds = @@ -272,7 +272,7 @@ export default App.controller( } ) - var updateScrollbar = function () { + function updateScrollbar() { if ( scrollbar.isVisible && $scope.reviewPanel.subView === $scope.SubViews.CUR_FILE && @@ -360,7 +360,7 @@ export default App.controller( nEntries > 0 && $scope.project.features.trackChangesVisible) ) - var regenerateTrackChangesId = function (doc) { + function regenerateTrackChangesId(doc) { const old_id = getChangeTracker(doc.doc_id).getIdSeed() const new_id = RangesTracker.generateIdSeed() getChangeTracker(doc.doc_id).setIdSeed(new_id) @@ -394,7 +394,7 @@ export default App.controller( })() }) - var refreshOverviewPanel = function () { + function refreshOverviewPanel() { $scope.reviewPanel.overview.loading = true return refreshRanges() .then(() => ($scope.reviewPanel.overview.loading = false)) @@ -409,8 +409,7 @@ export default App.controller( return q } - var updateEntries = function (doc_id) { - let change, entry_id, key, new_entry, value + function updateEntries(doc_id) { const rangesTracker = getChangeTracker(doc_id) const entries = getDocEntries(doc_id) const resolvedComments = getDocResolvedComments(doc_id) @@ -419,17 +418,17 @@ export default App.controller( // Assume we'll delete everything until we see it, then we'll remove it from this object const delete_changes = {} - for (var id in entries) { - change = entries[id] + for (const id in entries) { + const change = entries[id] if (!['add-comment', 'bulk-actions'].includes(id)) { - for (entry_id of Array.from(change.entry_ids)) { + for (const entry_id of Array.from(change.entry_ids)) { delete_changes[entry_id] = true } } } - for (id in resolvedComments) { - change = resolvedComments[id] - for (entry_id of Array.from(change.entry_ids)) { + for (const id in resolvedComments) { + const change = resolvedComments[id] + for (const entry_id of Array.from(change.entry_ids)) { delete_changes[entry_id] = true } } @@ -437,7 +436,7 @@ export default App.controller( let potential_aggregate = false let prev_insertion = null - for (change of Array.from(rangesTracker.changes)) { + for (const change of Array.from(rangesTracker.changes)) { changed = true if ( @@ -455,16 +454,15 @@ export default App.controller( entries[change.id] = {} } delete delete_changes[change.id] - new_entry = { + const new_entry = { type: change.op.i ? 'insert' : 'delete', entry_ids: [change.id], content: change.op.i || change.op.d, offset: change.op.p, metadata: change.metadata, } - for (key in new_entry) { - value = new_entry[key] - entries[change.id][key] = value + for (const key in new_entry) { + entries[change.id][key] = new_entry[key] } } @@ -486,7 +484,7 @@ export default App.controller( } for (const comment of Array.from(rangesTracker.comments)) { - var new_comment + let new_comment changed = true delete delete_changes[comment.id] if ($scope.reviewPanel.resolvedThreadIds[comment.op.t]) { @@ -502,16 +500,15 @@ export default App.controller( : (entries[comment.id] = {}) delete resolvedComments[comment.id] } - new_entry = { + const new_entry = { type: 'comment', thread_id: comment.op.t, entry_ids: [comment.id], content: comment.op.c, offset: comment.op.p, } - for (key in new_entry) { - value = new_entry[key] - new_comment[key] = value + for (const key in new_entry) { + new_comment[key] = new_entry[key] } } @@ -630,7 +627,7 @@ export default App.controller( }) } - var _doAcceptChanges = function (change_ids) { + function _doAcceptChanges(change_ids) { $http.post( `/project/${$scope.project_id}/doc/${$scope.editor.open_doc_id}/changes/accept`, { change_ids, _csrf: window.csrfToken } @@ -638,7 +635,7 @@ export default App.controller( return $scope.$broadcast('changes:accept', change_ids) } - var _doRejectChanges = change_ids => + const _doRejectChanges = change_ids => $scope.$broadcast('changes:reject', change_ids) const bulkAccept = function () { @@ -661,7 +658,7 @@ export default App.controller( $scope.showBulkRejectDialog = () => showBulkActionsDialog(false) - var showBulkActionsDialog = isAccept => + const showBulkActionsDialog = isAccept => $modal .open({ templateUrl: 'bulkActionsModalTemplate', @@ -806,7 +803,7 @@ export default App.controller( eventTracking.sendMB('rp-comment-reopen') } - var _onCommentResolved = function (thread_id, user) { + function _onCommentResolved(thread_id, user) { const thread = getThread(thread_id) if (thread == null) { return @@ -818,7 +815,7 @@ export default App.controller( return $scope.$broadcast('comment:resolve_threads', [thread_id]) } - var _onCommentReopened = function (thread_id) { + function _onCommentReopened(thread_id) { const thread = getThread(thread_id) if (thread == null) { return @@ -830,13 +827,13 @@ export default App.controller( return $scope.$broadcast('comment:unresolve_thread', thread_id) } - var _onThreadDeleted = function (thread_id) { + function _onThreadDeleted(thread_id) { delete $scope.reviewPanel.resolvedThreadIds[thread_id] delete $scope.reviewPanel.commentThreads[thread_id] return $scope.$broadcast('comment:remove', thread_id) } - var _onCommentEdited = function (thread_id, comment_id, content) { + function _onCommentEdited(thread_id, comment_id, content) { const thread = getThread(thread_id) if (thread == null) { return @@ -849,7 +846,7 @@ export default App.controller( return updateEntries() } - var _onCommentDeleted = function (thread_id, comment_id) { + function _onCommentDeleted(thread_id, comment_id) { const thread = getThread(thread_id) if (thread == null) { return @@ -965,7 +962,7 @@ export default App.controller( return _setUserTCState(project.owner._id, newValue, isLocal) } - var _setGuestsTCState = function (newValue, isLocal) { + function _setGuestsTCState(newValue, isLocal) { if (isLocal == null) { isLocal = false } @@ -1103,7 +1100,7 @@ export default App.controller( let _refreshingRangeUsers = false const _refreshedForUserIds = {} - var refreshChangeUsers = function (refresh_for_user_id) { + function refreshChangeUsers(refresh_for_user_id) { if (refresh_for_user_id != null) { if (_refreshedForUserIds[refresh_for_user_id] != null) { // We've already tried to refresh to get this user id, so stop it looping @@ -1147,7 +1144,7 @@ export default App.controller( } let _threadsLoaded = false - var ensureThreadsAreLoaded = function () { + function ensureThreadsAreLoaded() { if (_threadsLoaded) { // We get any updates in real time so only need to load them once. return @@ -1159,11 +1156,11 @@ export default App.controller( .then(function (response) { const threads = response.data $scope.reviewPanel.loadingThreads = false - for (var thread_id in $scope.reviewPanel.resolvedThreadIds) { + for (const thread_id in $scope.reviewPanel.resolvedThreadIds) { const _ = $scope.reviewPanel.resolvedThreadIds[thread_id] delete $scope.reviewPanel.resolvedThreadIds[thread_id] } - for (thread_id in threads) { + for (const thread_id in threads) { const thread = threads[thread_id] for (const comment of Array.from(thread.messages)) { formatComment(comment) @@ -1179,13 +1176,13 @@ export default App.controller( }) } - var formatComment = function (comment) { + function formatComment(comment) { comment.user = formatUser(comment.user) comment.timestamp = new Date(comment.timestamp) return comment } - var formatUser = function (user) { + function formatUser(user) { let isSelf, name const id = (user != null ? user._id : undefined) || diff --git a/services/web/frontend/js/ide/review-panel/directives/resolvedCommentsDropdown.js b/services/web/frontend/js/ide/review-panel/directives/resolvedCommentsDropdown.js index da37b51964..8ad9ff2e79 100644 --- a/services/web/frontend/js/ide/review-panel/directives/resolvedCommentsDropdown.js +++ b/services/web/frontend/js/ide/review-panel/directives/resolvedCommentsDropdown.js @@ -70,8 +70,8 @@ export default App.directive('resolvedCommentsDropdown', () => ({ return (() => { const result = [] - for (var docId in scope.entries) { - var docEntries = scope.entries[docId] + for (const docId in scope.entries) { + const docEntries = scope.entries[docId] result.push( (() => { const result1 = [] diff --git a/services/web/frontend/js/ide/review-panel/directives/reviewPanelSorted.js b/services/web/frontend/js/ide/review-panel/directives/reviewPanelSorted.js index 01861316c3..0be3c3847e 100644 --- a/services/web/frontend/js/ide/review-panel/directives/reviewPanelSorted.js +++ b/services/web/frontend/js/ide/review-panel/directives/reviewPanelSorted.js @@ -222,7 +222,7 @@ export default App.directive('reviewPanelSorted', $timeout => ({ } } - var scrollAce = scrollTop => + const scrollAce = scrollTop => scope.reviewPanelEventsBridge.emit('externalScroll', scrollTop) scope.reviewPanelEventsBridge.on('aceScroll', scrollPanel) diff --git a/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js b/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js index 6caecc5ffc..efb7b0b85b 100644 --- a/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js +++ b/services/web/frontend/js/main/affiliations/controllers/UserAffiliationsController.js @@ -217,7 +217,7 @@ export default App.controller( return _getUserEmails() } - var _resetAffiliationToChange = () => + const _resetAffiliationToChange = () => ($scope.affiliationToChange = { email: '', university: null, @@ -225,7 +225,7 @@ export default App.controller( department: null, }) - var _resetNewAffiliation = () => + const _resetNewAffiliation = () => ($scope.newAffiliation = { email: '', country: null, @@ -234,26 +234,26 @@ export default App.controller( department: null, }) - var _resetAddingEmail = function () { + function _resetAddingEmail() { $scope.ui.showAddEmailUI = false $scope.ui.isValidEmail = false $scope.ui.isBlacklistedEmail = false $scope.ui.showManualUniversitySelectionUI = false } - var _resetAffiliationSuggestion = () => { + const _resetAffiliationSuggestion = () => { $scope.newAffiliation = { email: $scope.newAffiliation.email, } } - var _resetMakingRequestType = function () { + function _resetMakingRequestType() { $scope.ui.isLoadingEmails = false $scope.ui.isProcessing = false $scope.ui.isResendingConfirmation = false } - var _reset = function () { + function _reset() { $scope.ui = { hasError: false, errorMessage: '', @@ -268,7 +268,7 @@ export default App.controller( } _reset() - var _monitorRequest = function (promise) { + function _monitorRequest(promise) { $scope.ui.hasError = false $scope.ui.isMakingRequest = true promise @@ -296,7 +296,7 @@ export default App.controller( } // Populates the emails table - var _getUserEmails = function () { + function _getUserEmails() { _resetMakingRequestType() $scope.ui.isLoadingEmails = true _monitorRequest( diff --git a/services/web/frontend/js/main/affiliations/factories/UserAffiliationsDataService.js b/services/web/frontend/js/main/affiliations/factories/UserAffiliationsDataService.js index 624a41bb12..02fda90a7d 100644 --- a/services/web/frontend/js/main/affiliations/factories/UserAffiliationsDataService.js +++ b/services/web/frontend/js/main/affiliations/factories/UserAffiliationsDataService.js @@ -528,7 +528,7 @@ App.factory('UserAffiliationsDataService', function ($http, $q) { _csrf: window.csrfToken, }) - var isDomainBlacklisted = domain => domain.toLowerCase() in domainsBlackList + const isDomainBlacklisted = domain => domain.toLowerCase() in domainsBlackList return { getCountries, diff --git a/services/web/frontend/js/main/learn.js b/services/web/frontend/js/main/learn.js index aed5296c18..b2c1c731ba 100644 --- a/services/web/frontend/js/main/learn.js +++ b/services/web/frontend/js/main/learn.js @@ -60,7 +60,7 @@ App.controller( return result } - var updateHits = (hits, hitsTotal = 0) => { + const updateHits = (hits, hitsTotal = 0) => { $scope.safeApply(() => { $scope.hits = hits $scope.hits_total = hitsTotal diff --git a/services/web/frontend/js/main/plans.js b/services/web/frontend/js/main/plans.js index 6409ca74b5..461892f24c 100644 --- a/services/web/frontend/js/main/plans.js +++ b/services/web/frontend/js/main/plans.js @@ -323,7 +323,7 @@ App.controller( $scope.openGroupPlanModal() } - var eventLabel = (label, location) => label + const eventLabel = (label, location) => label function switchEvent(e, label, location) { e.preventDefault() diff --git a/services/web/frontend/js/main/project-list/project-list.js b/services/web/frontend/js/main/project-list/project-list.js index 83a23c07e2..031a7bce01 100644 --- a/services/web/frontend/js/main/project-list/project-list.js +++ b/services/web/frontend/js/main/project-list/project-list.js @@ -40,7 +40,7 @@ App.controller('ProjectPageController', function ( newVal => ($scope.nUntagged = newVal) ) - var recalculateProjectListHeight = function () { + function recalculateProjectListHeight() { const $projListCard = $('.project-list-card') if (!$projListCard || !$projListCard.offset()) return @@ -52,17 +52,17 @@ App.controller('ProjectPageController', function ( } function defaultComparator(v1, v2) { - var result = 0 - var type1 = v1.type - var type2 = v2.type + let result = 0 + const type1 = v1.type + const type2 = v2.type if ($scope.predicate === 'ownerName') { return } if (type1 === type2) { - var value1 = v1.value - var value2 = v2.value + let value1 = v1.value + let value2 = v2.value if (type1 === 'string') { // Compare strings case-insensitively diff --git a/services/web/frontend/js/main/subscription-dashboard.js b/services/web/frontend/js/main/subscription-dashboard.js index 1735d4fa45..95588d6aaf 100644 --- a/services/web/frontend/js/main/subscription-dashboard.js +++ b/services/web/frontend/js/main/subscription-dashboard.js @@ -31,7 +31,7 @@ const ensureRecurlyIsSetup = _.once(() => { App.controller('MetricsEmailController', function ($scope, $http) { $scope.institutionEmailSubscription = function (institutionId) { - var inst = _.find(window.managedInstitutions, function (institution) { + const inst = _.find(window.managedInstitutions, function (institution) { return institution.v1Id === parseInt(institutionId) }) if (inst.metricsEmail.optedOutUserIds.includes(window.user_id)) { diff --git a/services/web/frontend/js/main/system-messages.js b/services/web/frontend/js/main/system-messages.js index 1c7d9be1d7..3284b66210 100644 --- a/services/web/frontend/js/main/system-messages.js +++ b/services/web/frontend/js/main/system-messages.js @@ -14,7 +14,7 @@ const MESSAGE_POLL_INTERVAL = 15 * 60 * 1000 // Controller for messages (array) App.controller('SystemMessagesController', ($http, $scope) => { $scope.messages = [] - var pollSystemMessages = function () { + function pollSystemMessages() { // Ignore polling if tab is hidden or browser is offline if (document.hidden || !navigator.onLine) { return diff --git a/services/web/frontend/js/services/queued-http.js b/services/web/frontend/js/services/queued-http.js index fe6597abf3..6d5c41bbfe 100644 --- a/services/web/frontend/js/services/queued-http.js +++ b/services/web/frontend/js/services/queued-http.js @@ -16,7 +16,7 @@ export default App.factory('queuedHttp', function ($http, $q) { const pendingRequests = [] let inflight = false - var processPendingRequests = function () { + function processPendingRequests() { if (inflight) { return } diff --git a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js index 0a0655a808..c52a60f8da 100644 --- a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js +++ b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js @@ -89,7 +89,7 @@ describe('ProjectStructureMongoLock', function () { 'renameEntity', 'addFolder', ] - for (var methodName of Array.from(LOCKING_UPDATE_METHODS)) { + for (const methodName of Array.from(LOCKING_UPDATE_METHODS)) { it(`cannot call ProjectEntityMongoUpdateHandler.${methodName}`, function (done) { const method = ProjectEntityMongoUpdateHandler[methodName] const args = _.times(method.length - 2, _.constant(null)) diff --git a/services/web/test/frontend/features/file-tree/flows/create-folder.test.js b/services/web/test/frontend/features/file-tree/flows/create-folder.test.js index 02dd3a9b2a..be0a97da82 100644 --- a/services/web/test/frontend/features/file-tree/flows/create-folder.test.js +++ b/services/web/test/frontend/features/file-tree/flows/create-folder.test.js @@ -245,7 +245,7 @@ describe('FileTree Create Folder Flow', function () { { socket: new MockedSocket() } ) - var newFolderName = 'existingFile' + let newFolderName = 'existingFile' await fireCreateFolder(newFolderName) diff --git a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js index 40516a5bc4..96a06b5427 100644 --- a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js +++ b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js @@ -157,7 +157,7 @@ const scope = { } describe('', function () { - var clock + let clock beforeEach(function () { window.showNewPdfPreview = true diff --git a/services/web/test/frontend/ide/log-parser/logParserTests.js b/services/web/test/frontend/ide/log-parser/logParserTests.js index 1e827bbf12..9b69bb9d77 100644 --- a/services/web/test/frontend/ide/log-parser/logParserTests.js +++ b/services/web/test/frontend/ide/log-parser/logParserTests.js @@ -99,7 +99,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect( expectedErrors.indexOf([errors[i].line, errors[i].message] + '') ).to.equal(i) @@ -124,7 +124,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect( expectedErrors.indexOf([errors[i].line, errors[i].message] + '') ).to.equal(i) @@ -217,7 +217,7 @@ describe('logParser', function (done) { const offsetErrorLen = errors.length - 1 expect(offsetErrorLen).to.equal(expectedErrors.length) - for (var i = 0; i < offsetErrorLen; i++) { + for (let i = 0; i < offsetErrorLen; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -252,7 +252,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -263,7 +263,7 @@ describe('logParser', function (done) { const latexParser = new LatexLogParser(this.natbibWarningsLog) const errors = latexParser.parse().warnings - var expectedErrors = [ + const expectedErrors = [ [ 6, "Package natbib Warning: Citation `blah' on page 1 undefined on input line 6.", @@ -277,7 +277,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -288,7 +288,7 @@ describe('logParser', function (done) { const latexParser = new LatexLogParser(this.geometryWarningsLog) const errors = latexParser.parse().warnings - var expectedErrors = [ + const expectedErrors = [ [ null, "Package geometry Warning: Over-specification in `h'-direction. `width' (597.50787pt) is ignored.", @@ -302,7 +302,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -313,7 +313,7 @@ describe('logParser', function (done) { const latexParser = new LatexLogParser(this.captionWarningsLog) const errors = latexParser.parse().warnings - var expectedErrors = [ + const expectedErrors = [ [ null, 'Package caption Warning: Unsupported document class (or package) detected, usage of the caption package is not recommended. See the caption package documentation for explanation.', @@ -327,7 +327,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -338,13 +338,13 @@ describe('logParser', function (done) { const latexParser = new LatexLogParser(this.runawayArgumentsLog) const errors = latexParser.parse().errors - var expectedErrors = [ + const expectedErrors = [ [null, 'Runaway argument?', '/compile/runaway_argument.tex'] + '', [null, 'Emergency stop.', '/compile/runaway_argument.tex'] + '', ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -353,9 +353,9 @@ describe('logParser', function (done) { it('should parse filenames', function () { const latexParser = new LatexLogParser(this.filenamesLog) - var { errors, warnings, typesetting } = latexParser.parse() + const { errors, warnings, typesetting } = latexParser.parse() - var expectedErrors = [ + const expectedErrors = [ [ 1, 'Undefined control sequence.', @@ -363,7 +363,7 @@ describe('logParser', function (done) { ] + '', ] - var expectedWarnings = [ + const expectedWarnings = [ [ 9, "Citation `Peeters:2001np' on page 13 undefined on input line 9.", @@ -371,7 +371,7 @@ describe('logParser', function (done) { ] + '', ] - var expectedTypesetting = [ + const expectedTypesetting = [ [ 123, 'Overfull \\hbox (4.56pt too wide) in paragraph at lines 123--456', @@ -383,17 +383,17 @@ describe('logParser', function (done) { expect(warnings.length).to.equal(warnings.length) expect(typesetting.length).to.equal(typesetting.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) } - for (var j = 0; i < warnings.length; i++) { + for (let j = 0; j < warnings.length; j++) { expect(expectedWarnings[j]).to.equal( [warnings[j].line, warnings[j].message, warnings[j].file] + '' ) } - for (var k = 0; i < typesetting.length; i++) { + for (let k = 0; k < typesetting.length; k++) { expect(expectedTypesetting[k]).to.equal( [typesetting[k].line, typesetting[k].message, typesetting[k].file] + '' ) @@ -404,7 +404,7 @@ describe('logParser', function (done) { const latexParser = new LatexLogParser(this.fileLineErrorLog) const errors = latexParser.parse().errors - var expectedErrors = [ + const expectedErrors = [ [ 1, 'Undefined control sequence.', @@ -413,7 +413,7 @@ describe('logParser', function (done) { ] expect(errors.length).to.equal(expectedErrors.length) - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(expectedErrors[i]).to.equal( [errors[i].line, errors[i].message, errors[i].file] + '' ) @@ -421,8 +421,8 @@ describe('logParser', function (done) { }) it('should ignore duplicates', function () { - var latexParser = new LatexLogParser(this.errorLog) - var errors = latexParser.parse().errors + let latexParser = new LatexLogParser(this.errorLog) + let errors = latexParser.parse().errors // duplicates included expect(errors.length).to.equal(10) @@ -435,10 +435,10 @@ describe('logParser', function (done) { }) it('should get file paths', function () { - var latexParser = new LatexLogParser(this.errorLog) - var errors = latexParser.parse().errors + let latexParser = new LatexLogParser(this.errorLog) + let errors = latexParser.parse().errors - for (var i = 0; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { expect(errors[i].file).to.equal( 'compiles/dff0c37d892f346e58fc14975a16bf69/sections/appendices.tex' ) @@ -446,7 +446,7 @@ describe('logParser', function (done) { latexParser = new LatexLogParser(this.badBoxesLog) errors = latexParser.parse().all - for (var j = 0; j < errors.length; j++) { + for (let j = 0; j < errors.length; j++) { expect(errors[j].file).to.equal( 'compiles/b6cf470376785e64ad84c57e3296c912/logs/bad-boxes.tex' ) diff --git a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js index 15b88bc127..b39233011a 100644 --- a/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js +++ b/services/web/test/unit/src/TokenAccess/TokenAccessHandlerTests.js @@ -58,7 +58,7 @@ describe('TokenAccessHandler', function () { '': null, abc123def: null, } - for (var token of Object.keys(specs)) { + for (const token of Object.keys(specs)) { expect(this.TokenAccessHandler.getTokenType(token)).to.equal( specs[token] )