Przeglądaj źródła

Merge pull request #5352 from overleaf/jpa-no-var

[misc] fix eslint violations for `no-var`

GitOrigin-RevId: c52e82f3a8a993b8662cc5aa56e7b95ca3c55832
Jakob Ackermann 4 lat temu
rodzic
commit
a6f05109a3
100 zmienionych plików z 245 dodań i 260 usunięć
  1. 0 1
      services/chat/.eslintrc
  2. 0 1
      services/clsi/.eslintrc
  3. 3 3
      services/clsi/app/js/Errors.js
  4. 1 1
      services/clsi/app/js/UrlFetcher.js
  5. 1 1
      services/clsi/test/acceptance/js/ExampleDocumentTests.js
  6. 1 1
      services/clsi/test/acceptance/js/helpers/Client.js
  7. 0 1
      services/contacts/.eslintrc
  8. 1 1
      services/contacts/app/js/Errors.js
  9. 0 1
      services/docstore/.eslintrc
  10. 0 1
      services/document-updater/.eslintrc
  11. 2 2
      services/document-updater/app/js/DeleteQueueManager.js
  12. 1 1
      services/document-updater/app/js/DispatchManager.js
  13. 4 4
      services/document-updater/app/js/Errors.js
  14. 2 2
      services/document-updater/app/js/ProjectFlusher.js
  15. 4 4
      services/document-updater/app/js/RangesTracker.js
  16. 1 1
      services/document-updater/app/js/RealTimeRedisManager.js
  17. 1 1
      services/document-updater/app/js/UpdateManager.js
  18. 1 1
      services/document-updater/app/js/sharejs/helpers.js
  19. 5 5
      services/document-updater/app/js/sharejs/json-api.js
  20. 1 1
      services/document-updater/app/js/sharejs/json.js
  21. 3 3
      services/document-updater/app/js/sharejs/model.js
  22. 3 3
      services/document-updater/app/js/sharejs/server/model.js
  23. 1 1
      services/document-updater/app/js/sharejs/server/syncqueue.js
  24. 1 1
      services/document-updater/app/js/sharejs/syncqueue.js
  25. 2 2
      services/document-updater/app/js/sharejs/text-composable.js
  26. 1 1
      services/document-updater/app/js/sharejs/text-tp2-api.js
  27. 4 4
      services/document-updater/app/js/sharejs/text-tp2.js
  28. 1 1
      services/document-updater/app/js/sharejs/types/helpers.js
  29. 5 5
      services/document-updater/app/js/sharejs/types/json-api.js
  30. 1 1
      services/document-updater/app/js/sharejs/types/json.js
  31. 3 3
      services/document-updater/app/js/sharejs/types/model.js
  32. 1 1
      services/document-updater/app/js/sharejs/types/syncqueue.js
  33. 2 2
      services/document-updater/app/js/sharejs/types/text-composable.js
  34. 1 1
      services/document-updater/app/js/sharejs/types/text-tp2-api.js
  35. 4 4
      services/document-updater/app/js/sharejs/types/text-tp2.js
  36. 1 1
      services/document-updater/test/unit/js/DispatchManager/DispatchManagerTests.js
  37. 3 3
      services/document-updater/test/unit/js/ShareJS/TextTransformTests.js
  38. 0 1
      services/filestore/.eslintrc
  39. 0 1
      services/notifications/.eslintrc
  40. 0 1
      services/real-time/.eslintrc
  41. 1 1
      services/real-time/app/js/Router.js
  42. 1 1
      services/real-time/test/acceptance/libs/XMLHttpRequest.js
  43. 0 1
      services/spelling/.eslintrc
  44. 2 2
      services/spelling/app/js/ASpell.js
  45. 2 2
      services/spelling/app/js/ASpellWorker.js
  46. 0 1
      services/track-changes/.eslintrc
  47. 1 1
      services/track-changes/app/js/DiffGenerator.js
  48. 1 1
      services/track-changes/app/js/RedisManager.js
  49. 2 2
      services/track-changes/app/js/UpdatesManager.js
  50. 0 4
      services/web/.eslintrc
  51. 2 2
      services/web/app/src/Features/Analytics/AnalyticsRegistrationSourceHelper.js
  52. 1 1
      services/web/app/src/Features/Documents/DocumentHelper.js
  53. 1 1
      services/web/app/src/Features/Editor/EditorRealTimeController.js
  54. 1 1
      services/web/app/src/Features/Email/EmailBuilder.js
  55. 1 1
      services/web/app/src/Features/Institutions/InstitutionsAPI.js
  56. 2 6
      services/web/app/src/Features/Institutions/InstitutionsController.js
  57. 11 5
      services/web/app/src/Features/Institutions/InstitutionsManager.js
  58. 3 3
      services/web/app/src/Features/Metadata/MetaHandler.js
  59. 2 2
      services/web/app/src/Features/Project/ProjectController.js
  60. 2 2
      services/web/app/src/Features/References/ReferencesHandler.js
  61. 1 1
      services/web/app/src/Features/ServerAdmin/AdminController.js
  62. 2 2
      services/web/app/src/Features/Subscription/RecurlyWrapper.js
  63. 1 1
      services/web/app/src/Features/Subscription/SubscriptionGroupHandler.js
  64. 5 5
      services/web/app/src/Features/Subscription/TeamInvitesHandler.js
  65. 1 1
      services/web/app/src/Features/ThirdPartyDataStore/UpdateMerger.js
  66. 1 1
      services/web/app/src/Features/User/UserGetter.js
  67. 4 4
      services/web/app/src/Features/UserMembership/UserMembershipHandler.js
  68. 3 3
      services/web/app/src/Features/UserMembership/UserMembershipViewModel.js
  69. 1 1
      services/web/app/src/infrastructure/Modules.js
  70. 3 3
      services/web/app/src/infrastructure/ProxyManager.js
  71. 3 3
      services/web/app/src/infrastructure/RedirectManager.js
  72. 1 1
      services/web/app/src/router.js
  73. 1 1
      services/web/frontend/js/features/preview/components/preview-log-entry-header.js
  74. 3 3
      services/web/frontend/js/ide/directives/layout.js
  75. 3 3
      services/web/frontend/js/ide/editor/Document.js
  76. 2 2
      services/web/frontend/js/ide/editor/ShareJsDoc.js
  77. 1 1
      services/web/frontend/js/ide/editor/controllers/SavingNotificationController.js
  78. 3 3
      services/web/frontend/js/ide/editor/directives/aceEditor.js
  79. 4 4
      services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/CommandManager.js
  80. 1 1
      services/web/frontend/js/ide/editor/directives/aceEditor/auto-complete/Helpers.js
  81. 1 1
      services/web/frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.js
  82. 10 11
      services/web/frontend/js/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.js
  83. 6 6
      services/web/frontend/js/ide/file-tree/FileTreeManager.js
  84. 1 1
      services/web/frontend/js/ide/history/HistoryManager.js
  85. 1 1
      services/web/frontend/js/ide/history/HistoryV2Manager.js
  86. 3 2
      services/web/frontend/js/ide/history/components/historyFileEntity.js
  87. 2 2
      services/web/frontend/js/ide/history/components/historyFileTree.js
  88. 4 4
      services/web/frontend/js/ide/history/controllers/HistoryListController.js
  89. 3 3
      services/web/frontend/js/ide/history/directives/infiniteScroll.js
  90. 1 1
      services/web/frontend/js/ide/human-readable-logs/HumanReadableLogs.js
  91. 2 2
      services/web/frontend/js/ide/log-parser/bib-log-parser.js
  92. 2 2
      services/web/frontend/js/ide/online-users/OnlineUsersManager.js
  93. 1 1
      services/web/frontend/js/ide/pdf/controllers/PdfController.js
  94. 2 2
      services/web/frontend/js/ide/pdfng/directives/pdfJsLoader.js
  95. 1 1
      services/web/frontend/js/ide/pdfng/directives/pdfPage.js
  96. 3 3
      services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js
  97. 12 12
      services/web/frontend/js/ide/pdfng/directives/pdfViewer.js
  98. 1 1
      services/web/frontend/js/ide/preamble/services/preamble.js
  99. 8 8
      services/web/frontend/js/ide/review-panel/RangesTracker.js
  100. 35 38
      services/web/frontend/js/ide/review-panel/controllers/ReviewPanelController.js

+ 0 - 1
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",

+ 0 - 1
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",

+ 3 - 3
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

+ 1 - 1
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')

+ 1 - 1
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) {

+ 1 - 1
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(

+ 0 - 1
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",

+ 1 - 1
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

+ 0 - 1
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",

+ 0 - 1
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",

+ 2 - 2
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

+ 1 - 1
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) {

+ 4 - 4
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

+ 2 - 2
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(

+ 4 - 4
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

+ 1 - 1
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) {

+ 1 - 1
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(

+ 1 - 1
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++

+ 5 - 5
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':

+ 1 - 1
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()

+ 3 - 3
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.

+ 3 - 3
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.

+ 1 - 1
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
     }

+ 1 - 1
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
     }

+ 2 - 2
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

+ 1 - 1
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

+ 4 - 4
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.

+ 1 - 1
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++

+ 5 - 5
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':

+ 1 - 1
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()

+ 3 - 3
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.

+ 1 - 1
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
     }

+ 2 - 2
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

+ 1 - 1
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

+ 4 - 4
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.

+ 1 - 1
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)

+ 3 - 3
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 = []

+ 0 - 1
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",

+ 0 - 1
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",

+ 0 - 1
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",

+ 1 - 1
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) {

+ 1 - 1
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
 

+ 0 - 1
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",

+ 2 - 2
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

+ 2 - 2
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)
     })

+ 0 - 1
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",

+ 1 - 1
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

+ 1 - 1
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',

+ 2 - 2
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
 

+ 0 - 4
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"
   },

+ 2 - 2
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]

+ 1 - 1
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) ||

+ 1 - 1
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 {

+ 1 - 1
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('<br/> Project:')

+ 1 - 1
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

+ 2 - 6
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
   )

+ 11 - 5
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) {

+ 3 - 3
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)
         }

+ 2 - 2
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')

+ 2 - 2
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 =>

+ 1 - 1
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__(

+ 2 - 2
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') {

+ 1 - 1
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 = {}

+ 5 - 5
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})`

+ 1 - 1
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'
         }

+ 1 - 1
services/web/app/src/Features/User/UserGetter.js

@@ -205,7 +205,7 @@ const UserGetter = {
   },
 }
 
-var decorateFullEmails = (
+const decorateFullEmails = (
   defaultEmail,
   emailsData,
   affiliationsData,

+ 4 - 4
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)
   }

+ 3 - 3
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)

+ 1 - 1
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]

+ 3 - 3
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

+ 3 - 3
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

+ 1 - 1
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)

+ 1 - 1
services/web/frontend/js/features/preview/components/preview-log-entry-header.js

@@ -91,7 +91,7 @@ function PreviewLogEntryHeader({
       </Tooltip>
     ) : null
 
-  var headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle
+  const headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle
 
   return (
     <header className={logEntryHeaderClasses}>

+ 3 - 3
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
           }

+ 3 - 3
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 })
       }

+ 2 - 2
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.

+ 1 - 1
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

+ 3 - 3
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()

+ 4 - 4
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 += '[]'

+ 1 - 1
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) {

+ 1 - 1
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]

+ 10 - 11
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))

+ 6 - 6
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 {

+ 1 - 1
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) {

+ 1 - 1
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) {

+ 3 - 2
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 {

+ 2 - 2
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)

+ 4 - 4
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
           }

+ 3 - 3
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)

+ 1 - 1
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) {

+ 2 - 2
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,

+ 2 - 2
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) {

+ 1 - 1
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],

+ 2 - 2
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()

+ 1 - 1
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) {

+ 3 - 3
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)

+ 12 - 12
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) {

+ 1 - 1
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 =

+ 8 - 8
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

+ 35 - 38
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) ||

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików