Преглед изворни кода

Merge pull request #12203 from overleaf/em-camel-case-clsi

Camel case variables in clsi

GitOrigin-RevId: 1542a6b7f8886e5fef496ce31acd2bba537befa9
Eric Mc Sween пре 3 година
родитељ
комит
16fee6d7d2

+ 2 - 2
services/clsi/app/js/CompileManager.js

@@ -106,7 +106,7 @@ async function doCompile(request) {
     {
     {
       projectId: request.project_id,
       projectId: request.project_id,
       userId: request.user_id,
       userId: request.user_id,
-      time_taken: Date.now() - writeToDiskTimer.start,
+      timeTaken: Date.now() - writeToDiskTimer.start,
     },
     },
     'written files to disk'
     'written files to disk'
   )
   )
@@ -248,7 +248,7 @@ async function doCompile(request) {
     {
     {
       projectId: request.project_id,
       projectId: request.project_id,
       userId: request.user_id,
       userId: request.user_id,
-      time_taken: ts,
+      timeTaken: ts,
       stats,
       stats,
       timings,
       timings,
       loadavg,
       loadavg,

+ 2 - 2
services/clsi/app/js/DockerRunner.js

@@ -353,7 +353,7 @@ const DockerRunner = {
     callback = _.once(callback)
     callback = _.once(callback)
     const { name } = options
     const { name } = options
 
 
-    logger.debug({ container_name: name }, 'starting container')
+    logger.debug({ containerName: name }, 'starting container')
     const container = dockerode.getContainer(name)
     const container = dockerode.getContainer(name)
 
 
     function createAndStartContainer() {
     function createAndStartContainer() {
@@ -390,7 +390,7 @@ const DockerRunner = {
         createAndStartContainer()
         createAndStartContainer()
       } else if (error != null) {
       } else if (error != null) {
         logger.err(
         logger.err(
-          { container_name: name, error },
+          { containerName: name, error },
           'unable to inspect container to start'
           'unable to inspect container to start'
         )
         )
         callback(error)
         callback(error)

+ 4 - 5
services/clsi/app/js/LocalCommandRunner.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
     no-unused-vars,
     no-unused-vars,
 */
 */
@@ -22,7 +21,7 @@ logger.debug('using standard command runner')
 
 
 module.exports = CommandRunner = {
 module.exports = CommandRunner = {
   run(
   run(
-    project_id,
+    projectId,
     command,
     command,
     directory,
     directory,
     image,
     image,
@@ -36,7 +35,7 @@ module.exports = CommandRunner = {
     command = Array.from(command).map(arg =>
     command = Array.from(command).map(arg =>
       arg.toString().replace('$COMPILE_DIR', directory)
       arg.toString().replace('$COMPILE_DIR', directory)
     )
     )
-    logger.debug({ project_id, command, directory }, 'running command')
+    logger.debug({ projectId, command, directory }, 'running command')
     logger.warn('timeouts and sandboxing are not enabled with CommandRunner')
     logger.warn('timeouts and sandboxing are not enabled with CommandRunner')
 
 
     // merge environment settings
     // merge environment settings
@@ -62,7 +61,7 @@ module.exports = CommandRunner = {
 
 
     proc.on('error', function (err) {
     proc.on('error', function (err) {
       logger.err(
       logger.err(
-        { err, project_id, command, directory },
+        { err, projectId, command, directory },
         'error running command'
         'error running command'
       )
       )
       return callback(err)
       return callback(err)
@@ -70,7 +69,7 @@ module.exports = CommandRunner = {
 
 
     proc.on('close', function (code, signal) {
     proc.on('close', function (code, signal) {
       let err
       let err
-      logger.debug({ code, signal, project_id }, 'command exited')
+      logger.debug({ code, signal, projectId }, 'command exited')
       if (signal === 'SIGTERM') {
       if (signal === 'SIGTERM') {
         // signal from kill method below
         // signal from kill method below
         err = new Error('terminated')
         err = new Error('terminated')

+ 1 - 1
services/clsi/app/js/OutputCacheManager.js

@@ -584,7 +584,7 @@ module.exports = OutputCacheManager = {
           // cache directory is empty
           // cache directory is empty
           return cleanupAll(callback)
           return cleanupAll(callback)
         }
         }
-        logger.error({ err, project_id: cacheRoot }, 'error clearing cache')
+        logger.error({ err, projectId: cacheRoot }, 'error clearing cache')
         return callback(err)
         return callback(err)
       }
       }
 
 

+ 21 - 24
services/clsi/app/js/ProjectPersistenceManager.js

@@ -1,6 +1,3 @@
-/* eslint-disable
-    camelcase,
-*/
 // TODO: This file was created by bulk-decaffeinate.
 // TODO: This file was created by bulk-decaffeinate.
 // Fix any style issues and re-enable lint.
 // Fix any style issues and re-enable lint.
 /*
 /*
@@ -105,8 +102,8 @@ module.exports = ProjectPersistenceManager = {
     })
     })
   },
   },
 
 
-  markProjectAsJustAccessed(project_id, callback) {
-    LAST_ACCESS.set(project_id, Date.now())
+  markProjectAsJustAccessed(projectId, callback) {
+    LAST_ACCESS.set(projectId, Date.now())
     callback()
     callback()
   },
   },
 
 
@@ -116,25 +113,25 @@ module.exports = ProjectPersistenceManager = {
     }
     }
     return ProjectPersistenceManager._findExpiredProjectIds(function (
     return ProjectPersistenceManager._findExpiredProjectIds(function (
       error,
       error,
-      project_ids
+      projectIds
     ) {
     ) {
       if (error != null) {
       if (error != null) {
         return callback(error)
         return callback(error)
       }
       }
-      logger.debug({ project_ids }, 'clearing expired projects')
-      const jobs = Array.from(project_ids || []).map(project_id =>
+      logger.debug({ projectIds }, 'clearing expired projects')
+      const jobs = Array.from(projectIds || []).map(projectId =>
         (
         (
-          project_id => callback =>
+          projectId => callback =>
             ProjectPersistenceManager.clearProjectFromCache(
             ProjectPersistenceManager.clearProjectFromCache(
-              project_id,
+              projectId,
               function (err) {
               function (err) {
                 if (err != null) {
                 if (err != null) {
-                  logger.error({ err, project_id }, 'error clearing project')
+                  logger.error({ err, projectId }, 'error clearing project')
                 }
                 }
                 return callback()
                 return callback()
               }
               }
             )
             )
-        )(project_id)
+        )(projectId)
       )
       )
       return async.series(jobs, function (error) {
       return async.series(jobs, function (error) {
         if (error != null) {
         if (error != null) {
@@ -148,17 +145,17 @@ module.exports = ProjectPersistenceManager = {
     })
     })
   }, // ignore any errors from deleting directories
   }, // ignore any errors from deleting directories
 
 
-  clearProject(project_id, user_id, callback) {
+  clearProject(projectId, userId, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
-    logger.debug({ project_id, user_id }, 'clearing project for user')
-    return CompileManager.clearProject(project_id, user_id, function (error) {
+    logger.debug({ projectId, userId }, 'clearing project for user')
+    return CompileManager.clearProject(projectId, userId, function (error) {
       if (error != null) {
       if (error != null) {
         return callback(error)
         return callback(error)
       }
       }
       return ProjectPersistenceManager.clearProjectFromCache(
       return ProjectPersistenceManager.clearProjectFromCache(
-        project_id,
+        projectId,
         function (error) {
         function (error) {
           if (error != null) {
           if (error != null) {
             return callback(error)
             return callback(error)
@@ -169,22 +166,22 @@ module.exports = ProjectPersistenceManager = {
     })
     })
   },
   },
 
 
-  clearProjectFromCache(project_id, callback) {
+  clearProjectFromCache(projectId, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
-    logger.debug({ project_id }, 'clearing project from cache')
-    return UrlCache.clearProject(project_id, function (error) {
+    logger.debug({ projectId }, 'clearing project from cache')
+    return UrlCache.clearProject(projectId, function (error) {
       if (error != null) {
       if (error != null) {
-        logger.err({ error, project_id }, 'error clearing project from cache')
+        logger.err({ error, projectId }, 'error clearing project from cache')
         return callback(error)
         return callback(error)
       }
       }
       return ProjectPersistenceManager._clearProjectFromDatabase(
       return ProjectPersistenceManager._clearProjectFromDatabase(
-        project_id,
+        projectId,
         function (error) {
         function (error) {
           if (error != null) {
           if (error != null) {
             logger.err(
             logger.err(
-              { error, project_id },
+              { error, projectId },
               'error clearing project from database'
               'error clearing project from database'
             )
             )
           }
           }
@@ -194,8 +191,8 @@ module.exports = ProjectPersistenceManager = {
     })
     })
   },
   },
 
 
-  _clearProjectFromDatabase(project_id, callback) {
-    LAST_ACCESS.delete(project_id)
+  _clearProjectFromDatabase(projectId, callback) {
+    LAST_ACCESS.delete(projectId)
     callback()
     callback()
   },
   },
 
 

+ 20 - 21
services/clsi/app/js/ResourceWriter.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
     no-unused-vars,
     no-unused-vars,
     no-useless-escape,
     no-useless-escape,
@@ -34,7 +33,7 @@ module.exports = ResourceWriter = {
     }
     }
     if (request.syncType === 'incremental') {
     if (request.syncType === 'incremental') {
       logger.debug(
       logger.debug(
-        { project_id: request.project_id, user_id: request.user_id },
+        { projectId: request.project_id, userId: request.user_id },
         'incremental sync'
         'incremental sync'
       )
       )
       return ResourceStateManager.checkProjectStateMatches(
       return ResourceStateManager.checkProjectStateMatches(
@@ -79,7 +78,7 @@ module.exports = ResourceWriter = {
       )
       )
     }
     }
     logger.debug(
     logger.debug(
-      { project_id: request.project_id, user_id: request.user_id },
+      { projectId: request.project_id, userId: request.user_id },
       'full sync'
       'full sync'
     )
     )
     UrlCache.createProjectDir(request.project_id, error => {
     UrlCache.createProjectDir(request.project_id, error => {
@@ -109,7 +108,7 @@ module.exports = ResourceWriter = {
     })
     })
   },
   },
 
 
-  saveIncrementalResourcesToDisk(project_id, resources, basePath, callback) {
+  saveIncrementalResourcesToDisk(projectId, resources, basePath, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
@@ -121,7 +120,7 @@ module.exports = ResourceWriter = {
         (resource => {
         (resource => {
           return callback =>
           return callback =>
             ResourceWriter._writeResourceToDisk(
             ResourceWriter._writeResourceToDisk(
-              project_id,
+              projectId,
               resource,
               resource,
               basePath,
               basePath,
               callback
               callback
@@ -140,7 +139,7 @@ module.exports = ResourceWriter = {
       if (error != null) {
       if (error != null) {
         return callback(error)
         return callback(error)
       }
       }
-      const { project_id, resources } = request
+      const { project_id: projectId, resources } = request
       ResourceWriter._removeExtraneousFiles(
       ResourceWriter._removeExtraneousFiles(
         request,
         request,
         resources,
         resources,
@@ -153,7 +152,7 @@ module.exports = ResourceWriter = {
             (resource => {
             (resource => {
               return callback =>
               return callback =>
                 ResourceWriter._writeResourceToDisk(
                 ResourceWriter._writeResourceToDisk(
-                  project_id,
+                  projectId,
                   resource,
                   resource,
                   basePath,
                   basePath,
                   callback
                   callback
@@ -210,40 +209,40 @@ module.exports = ResourceWriter = {
         for (const file of Array.from(outputFiles || [])) {
         for (const file of Array.from(outputFiles || [])) {
           ;(function (file) {
           ;(function (file) {
             const { path } = file
             const { path } = file
-            let should_delete = true
+            let shouldDelete = true
             if (
             if (
               path.match(/^output\./) ||
               path.match(/^output\./) ||
               path.match(/\.aux$/) ||
               path.match(/\.aux$/) ||
               path.match(/^cache\//)
               path.match(/^cache\//)
             ) {
             ) {
               // knitr cache
               // knitr cache
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (path.match(/^output-.*/)) {
             if (path.match(/^output-.*/)) {
               // Tikz cached figures (default case)
               // Tikz cached figures (default case)
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (path.match(/\.(pdf|dpth|md5)$/)) {
             if (path.match(/\.(pdf|dpth|md5)$/)) {
               // Tikz cached figures (by extension)
               // Tikz cached figures (by extension)
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (
             if (
               path.match(/\.(pygtex|pygstyle)$/) ||
               path.match(/\.(pygtex|pygstyle)$/) ||
               path.match(/(^|\/)_minted-[^\/]+\//)
               path.match(/(^|\/)_minted-[^\/]+\//)
             ) {
             ) {
               // minted files/directory
               // minted files/directory
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (
             if (
               path.match(/\.md\.tex$/) ||
               path.match(/\.md\.tex$/) ||
               path.match(/(^|\/)_markdown_[^\/]+\//)
               path.match(/(^|\/)_markdown_[^\/]+\//)
             ) {
             ) {
               // markdown files/directory
               // markdown files/directory
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (path.match(/-eps-converted-to\.pdf$/)) {
             if (path.match(/-eps-converted-to\.pdf$/)) {
               // Epstopdf generated files
               // Epstopdf generated files
-              should_delete = false
+              shouldDelete = false
             }
             }
             if (
             if (
               path === 'output.pdf' ||
               path === 'output.pdf' ||
@@ -253,13 +252,13 @@ module.exports = ResourceWriter = {
               path === 'output.stdout' ||
               path === 'output.stdout' ||
               path === 'output.stderr'
               path === 'output.stderr'
             ) {
             ) {
-              should_delete = true
+              shouldDelete = true
             }
             }
             if (path === 'output.tex') {
             if (path === 'output.tex') {
               // created by TikzManager if present in output files
               // created by TikzManager if present in output files
-              should_delete = true
+              shouldDelete = true
             }
             }
-            if (should_delete) {
+            if (shouldDelete) {
               return jobs.push(callback =>
               return jobs.push(callback =>
                 ResourceWriter._deleteFileIfNotDirectory(
                 ResourceWriter._deleteFileIfNotDirectory(
                   Path.join(basePath, path),
                   Path.join(basePath, path),
@@ -311,7 +310,7 @@ module.exports = ResourceWriter = {
     })
     })
   },
   },
 
 
-  _writeResourceToDisk(project_id, resource, basePath, callback) {
+  _writeResourceToDisk(projectId, resource, basePath, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
@@ -332,7 +331,7 @@ module.exports = ResourceWriter = {
             // TODO: Don't overwrite file if it hasn't been modified
             // TODO: Don't overwrite file if it hasn't been modified
             if (resource.url != null) {
             if (resource.url != null) {
               return UrlCache.downloadUrlToFile(
               return UrlCache.downloadUrlToFile(
-                project_id,
+                projectId,
                 resource.url,
                 resource.url,
                 path,
                 path,
                 resource.modified,
                 resource.modified,
@@ -341,9 +340,9 @@ module.exports = ResourceWriter = {
                     logger.err(
                     logger.err(
                       {
                       {
                         err,
                         err,
-                        project_id,
+                        projectId,
                         path,
                         path,
-                        resource_url: resource.url,
+                        resourceUrl: resource.url,
                         modified: resource.modified,
                         modified: resource.modified,
                       },
                       },
                       'error downloading file for resources'
                       'error downloading file for resources'

+ 5 - 6
services/clsi/app/js/StaticServerForbidSymlinks.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-cond-assign,
     no-cond-assign,
     no-unused-vars,
     no-unused-vars,
     n/no-deprecated-api,
     n/no-deprecated-api,
@@ -23,11 +22,11 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) {
   const expressStatic = staticFn(root, options)
   const expressStatic = staticFn(root, options)
   const basePath = Path.resolve(root)
   const basePath = Path.resolve(root)
   return function (req, res, next) {
   return function (req, res, next) {
-    let file, project_id, result
+    let file, projectId, result
     const path = req.url
     const path = req.url
     // check that the path is of the form /project_id_or_name/path/to/file.log
     // check that the path is of the form /project_id_or_name/path/to/file.log
     if ((result = path.match(/^\/?([a-zA-Z0-9_-]+)\/(.*)/))) {
     if ((result = path.match(/^\/?([a-zA-Z0-9_-]+)\/(.*)/))) {
-      project_id = result[1]
+      projectId = result[1]
       file = result[2]
       file = result[2]
     } else {
     } else {
       logger.warn({ path }, 'unrecognized file request')
       logger.warn({ path }, 'unrecognized file request')
@@ -41,7 +40,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) {
       }
       }
     }
     }
     // check that the requested path is normalized
     // check that the requested path is normalized
-    const requestedFsPath = `${basePath}/${project_id}/${file}`
+    const requestedFsPath = `${basePath}/${projectId}/${file}`
     if (requestedFsPath !== Path.normalize(requestedFsPath)) {
     if (requestedFsPath !== Path.normalize(requestedFsPath)) {
       logger.error(
       logger.error(
         { path: requestedFsPath },
         { path: requestedFsPath },
@@ -61,7 +60,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) {
               requestedFsPath,
               requestedFsPath,
               realFsPath,
               realFsPath,
               path: req.params[0],
               path: req.params[0],
-              project_id: req.params.project_id,
+              projectId: req.params.project_id,
             },
             },
             'error checking file access'
             'error checking file access'
           )
           )
@@ -73,7 +72,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) {
             requestedFsPath,
             requestedFsPath,
             realFsPath,
             realFsPath,
             path: req.params[0],
             path: req.params[0],
-            project_id: req.params.project_id,
+            projectId: req.params.project_id,
           },
           },
           'trying to access a different file (symlink), aborting'
           'trying to access a different file (symlink), aborting'
         )
         )

+ 0 - 1
services/clsi/app/js/UrlCache.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
 */
 */
 // TODO: This file was created by bulk-decaffeinate.
 // TODO: This file was created by bulk-decaffeinate.

+ 33 - 39
services/clsi/test/acceptance/js/ExampleDocumentTests.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
     no-unused-vars,
     no-unused-vars,
 */
 */
@@ -56,18 +55,18 @@ const compare = function (originalPath, generatedPath, callback) {
   if (callback == null) {
   if (callback == null) {
     callback = function () {}
     callback = function () {}
   }
   }
-  const diff_file = `${fixturePath(generatedPath)}-diff.png`
+  const diffFile = `${fixturePath(generatedPath)}-diff.png`
   const proc = ChildProcess.exec(
   const proc = ChildProcess.exec(
     `compare -metric mae ${fixturePath(originalPath)} ${fixturePath(
     `compare -metric mae ${fixturePath(originalPath)} ${fixturePath(
       generatedPath
       generatedPath
-    )} ${diff_file}`
+    )} ${diffFile}`
   )
   )
   let stderr = ''
   let stderr = ''
   proc.stderr.on('data', chunk => (stderr += chunk))
   proc.stderr.on('data', chunk => (stderr += chunk))
   return proc.on('exit', () => {
   return proc.on('exit', () => {
     if (stderr.trim() === '0 (0)') {
     if (stderr.trim() === '0 (0)') {
       // remove output diff if test matches expected image
       // remove output diff if test matches expected image
-      fs.unlink(diff_file, err => {
+      fs.unlink(diffFile, err => {
         if (err) {
         if (err) {
           throw err
           throw err
         }
         }
@@ -97,25 +96,25 @@ const checkPdfInfo = function (pdfPath, callback) {
   })
   })
 }
 }
 
 
-const compareMultiplePages = function (project_id, callback) {
+const compareMultiplePages = function (projectId, callback) {
   if (callback == null) {
   if (callback == null) {
     callback = function () {}
     callback = function () {}
   }
   }
-  function compareNext(page_no, callback) {
-    const path = `tmp/${project_id}-source-${page_no}.png`
+  function compareNext(pageNo, callback) {
+    const path = `tmp/${projectId}-source-${pageNo}.png`
     return fs.stat(fixturePath(path), (error, stat) => {
     return fs.stat(fixturePath(path), (error, stat) => {
       if (error != null) {
       if (error != null) {
         return callback()
         return callback()
       } else {
       } else {
         return compare(
         return compare(
-          `tmp/${project_id}-source-${page_no}.png`,
-          `tmp/${project_id}-generated-${page_no}.png`,
+          `tmp/${projectId}-source-${pageNo}.png`,
+          `tmp/${projectId}-generated-${pageNo}.png`,
           (error, same) => {
           (error, same) => {
             if (error != null) {
             if (error != null) {
               throw error
               throw error
             }
             }
             same.should.equal(true)
             same.should.equal(true)
-            return compareNext(page_no + 1, callback)
+            return compareNext(pageNo + 1, callback)
           }
           }
         )
         )
       }
       }
@@ -124,33 +123,33 @@ const compareMultiplePages = function (project_id, callback) {
   return compareNext(0, callback)
   return compareNext(0, callback)
 }
 }
 
 
-const comparePdf = function (project_id, example_dir, callback) {
+const comparePdf = function (projectId, exampleDir, callback) {
   if (callback == null) {
   if (callback == null) {
     callback = function () {}
     callback = function () {}
   }
   }
   console.log('CONVERT')
   console.log('CONVERT')
-  console.log(`tmp/${project_id}.pdf`, `tmp/${project_id}-generated.png`)
+  console.log(`tmp/${projectId}.pdf`, `tmp/${projectId}-generated.png`)
   return convertToPng(
   return convertToPng(
-    `tmp/${project_id}.pdf`,
-    `tmp/${project_id}-generated.png`,
+    `tmp/${projectId}.pdf`,
+    `tmp/${projectId}-generated.png`,
     error => {
     error => {
       if (error != null) {
       if (error != null) {
         throw error
         throw error
       }
       }
       return convertToPng(
       return convertToPng(
-        `examples/${example_dir}/output.pdf`,
-        `tmp/${project_id}-source.png`,
+        `examples/${exampleDir}/output.pdf`,
+        `tmp/${projectId}-source.png`,
         error => {
         error => {
           if (error != null) {
           if (error != null) {
             throw error
             throw error
           }
           }
           return fs.stat(
           return fs.stat(
-            fixturePath(`tmp/${project_id}-source-0.png`),
+            fixturePath(`tmp/${projectId}-source-0.png`),
             (error, stat) => {
             (error, stat) => {
               if (error != null) {
               if (error != null) {
                 return compare(
                 return compare(
-                  `tmp/${project_id}-source.png`,
-                  `tmp/${project_id}-generated.png`,
+                  `tmp/${projectId}-source.png`,
+                  `tmp/${projectId}-generated.png`,
                   (error, same) => {
                   (error, same) => {
                     if (error != null) {
                     if (error != null) {
                       throw error
                       throw error
@@ -160,7 +159,7 @@ const comparePdf = function (project_id, example_dir, callback) {
                   }
                   }
                 )
                 )
               } else {
               } else {
-                return compareMultiplePages(project_id, error => {
+                return compareMultiplePages(projectId, error => {
                   if (error != null) {
                   if (error != null) {
                     throw error
                     throw error
                   }
                   }
@@ -175,25 +174,20 @@ const comparePdf = function (project_id, example_dir, callback) {
   )
   )
 }
 }
 
 
-const downloadAndComparePdf = function (
-  project_id,
-  example_dir,
-  url,
-  callback
-) {
+const downloadAndComparePdf = function (projectId, exampleDir, url, callback) {
   if (callback == null) {
   if (callback == null) {
     callback = function () {}
     callback = function () {}
   }
   }
-  const writeStream = fs.createWriteStream(fixturePath(`tmp/${project_id}.pdf`))
+  const writeStream = fs.createWriteStream(fixturePath(`tmp/${projectId}.pdf`))
   request.get(url).pipe(writeStream)
   request.get(url).pipe(writeStream)
-  console.log('writing file out', fixturePath(`tmp/${project_id}.pdf`))
+  console.log('writing file out', fixturePath(`tmp/${projectId}.pdf`))
   return writeStream.on('close', () => {
   return writeStream.on('close', () => {
-    return checkPdfInfo(`tmp/${project_id}.pdf`, (error, optimised) => {
+    return checkPdfInfo(`tmp/${projectId}.pdf`, (error, optimised) => {
       if (error != null) {
       if (error != null) {
         throw error
         throw error
       }
       }
       optimised.should.equal(true)
       optimised.should.equal(true)
-      return comparePdf(project_id, example_dir, callback)
+      return comparePdf(projectId, exampleDir, callback)
     })
     })
   })
   })
 }
 }
@@ -214,11 +208,11 @@ describe('Example Documents', function () {
     fsExtra.remove(fixturePath('tmp'), done)
     fsExtra.remove(fixturePath('tmp'), done)
   })
   })
 
 
-  return Array.from(fs.readdirSync(fixturePath('examples'))).map(example_dir =>
-    (example_dir =>
-      describe(example_dir, function () {
+  return Array.from(fs.readdirSync(fixturePath('examples'))).map(exampleDir =>
+    (exampleDir =>
+      describe(exampleDir, function () {
         before(function () {
         before(function () {
-          return (this.project_id = Client.randomId() + '_' + example_dir)
+          return (this.project_id = Client.randomId() + '_' + exampleDir)
         })
         })
 
 
         it('should generate the correct pdf', function (done) {
         it('should generate the correct pdf', function (done) {
@@ -226,7 +220,7 @@ describe('Example Documents', function () {
           return Client.compileDirectory(
           return Client.compileDirectory(
             this.project_id,
             this.project_id,
             fixturePath('examples'),
             fixturePath('examples'),
-            example_dir,
+            exampleDir,
             4242,
             4242,
             (error, res, body) => {
             (error, res, body) => {
               if (
               if (
@@ -242,7 +236,7 @@ describe('Example Documents', function () {
               const pdf = Client.getOutputFile(body, 'pdf')
               const pdf = Client.getOutputFile(body, 'pdf')
               return downloadAndComparePdf(
               return downloadAndComparePdf(
                 this.project_id,
                 this.project_id,
-                example_dir,
+                exampleDir,
                 pdf.url,
                 pdf.url,
                 done
                 done
               )
               )
@@ -255,7 +249,7 @@ describe('Example Documents', function () {
           return Client.compileDirectory(
           return Client.compileDirectory(
             this.project_id,
             this.project_id,
             fixturePath('examples'),
             fixturePath('examples'),
-            example_dir,
+            exampleDir,
             4242,
             4242,
             (error, res, body) => {
             (error, res, body) => {
               if (
               if (
@@ -271,14 +265,14 @@ describe('Example Documents', function () {
               const pdf = Client.getOutputFile(body, 'pdf')
               const pdf = Client.getOutputFile(body, 'pdf')
               return downloadAndComparePdf(
               return downloadAndComparePdf(
                 this.project_id,
                 this.project_id,
-                example_dir,
+                exampleDir,
                 pdf.url,
                 pdf.url,
                 done
                 done
               )
               )
             }
             }
           )
           )
         })
         })
-      }))(example_dir)
+      }))(exampleDir)
   )
   )
 })
 })
 
 

+ 18 - 19
services/clsi/test/acceptance/js/helpers/Client.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-unused-vars,
     no-unused-vars,
 */
 */
 // TODO: This file was created by bulk-decaffeinate.
 // TODO: This file was created by bulk-decaffeinate.
@@ -25,7 +24,7 @@ module.exports = Client = {
     return Math.random().toString(16).slice(2)
     return Math.random().toString(16).slice(2)
   },
   },
 
 
-  compile(project_id, data, callback) {
+  compile(projectId, data, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
@@ -35,7 +34,7 @@ module.exports = Client = {
     }
     }
     return request.post(
     return request.post(
       {
       {
-        url: `${this.host}/project/${project_id}/compile`,
+        url: `${this.host}/project/${projectId}/compile`,
         json: {
         json: {
           compile: data,
           compile: data,
         },
         },
@@ -44,11 +43,11 @@ module.exports = Client = {
     )
     )
   },
   },
 
 
-  clearCache(project_id, callback) {
+  clearCache(projectId, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
-    return request.del(`${this.host}/project/${project_id}`, callback)
+    return request.del(`${this.host}/project/${projectId}`, callback)
   },
   },
 
 
   getOutputFile(response, type) {
   getOutputFile(response, type) {
@@ -71,17 +70,17 @@ module.exports = Client = {
     })
     })
   },
   },
 
 
-  syncFromCode(project_id, file, line, column, callback) {
-    Client.syncFromCodeWithImage(project_id, file, line, column, '', callback)
+  syncFromCode(projectId, file, line, column, callback) {
+    Client.syncFromCodeWithImage(projectId, file, line, column, '', callback)
   },
   },
 
 
-  syncFromCodeWithImage(project_id, file, line, column, imageName, callback) {
+  syncFromCodeWithImage(projectId, file, line, column, imageName, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
     return request.get(
     return request.get(
       {
       {
-        url: `${this.host}/project/${project_id}/sync/code`,
+        url: `${this.host}/project/${projectId}/sync/code`,
         qs: {
         qs: {
           imageName,
           imageName,
           file,
           file,
@@ -102,17 +101,17 @@ module.exports = Client = {
     )
     )
   },
   },
 
 
-  syncFromPdf(project_id, page, h, v, callback) {
-    Client.syncFromPdfWithImage(project_id, page, h, v, '', callback)
+  syncFromPdf(projectId, page, h, v, callback) {
+    Client.syncFromPdfWithImage(projectId, page, h, v, '', callback)
   },
   },
 
 
-  syncFromPdfWithImage(project_id, page, h, v, imageName, callback) {
+  syncFromPdfWithImage(projectId, page, h, v, imageName, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
     return request.get(
     return request.get(
       {
       {
-        url: `${this.host}/project/${project_id}/sync/pdf`,
+        url: `${this.host}/project/${projectId}/sync/pdf`,
         qs: {
         qs: {
           imageName,
           imageName,
           page,
           page,
@@ -133,7 +132,7 @@ module.exports = Client = {
     )
     )
   },
   },
 
 
-  compileDirectory(project_id, baseDirectory, directory, serverPort, callback) {
+  compileDirectory(projectId, baseDirectory, directory, serverPort, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
@@ -200,23 +199,23 @@ module.exports = Client = {
           req.options = body
           req.options = body
         }
         }
 
 
-        return this.compile(project_id, req, callback)
+        return this.compile(projectId, req, callback)
       }
       }
     )
     )
   },
   },
 
 
-  wordcount(project_id, file, callback) {
+  wordcount(projectId, file, callback) {
     const image = undefined
     const image = undefined
-    Client.wordcountWithImage(project_id, file, image, callback)
+    Client.wordcountWithImage(projectId, file, image, callback)
   },
   },
 
 
-  wordcountWithImage(project_id, file, image, callback) {
+  wordcountWithImage(projectId, file, image, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function () {}
       callback = function () {}
     }
     }
     return request.get(
     return request.get(
       {
       {
-        url: `${this.host}/project/${project_id}/wordcount`,
+        url: `${this.host}/project/${projectId}/wordcount`,
         qs: {
         qs: {
           image,
           image,
           file,
           file,

+ 20 - 21
services/clsi/test/unit/js/ContentTypeMapperTests.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
     no-unused-vars,
     no-unused-vars,
 */
 */
@@ -24,56 +23,56 @@ describe('ContentTypeMapper', function () {
 
 
   return describe('map', function () {
   return describe('map', function () {
     it('should map .txt to text/plain', function () {
     it('should map .txt to text/plain', function () {
-      const content_type = this.ContentTypeMapper.map('example.txt')
-      return content_type.should.equal('text/plain')
+      const contentType = this.ContentTypeMapper.map('example.txt')
+      return contentType.should.equal('text/plain')
     })
     })
 
 
     it('should map .csv to text/csv', function () {
     it('should map .csv to text/csv', function () {
-      const content_type = this.ContentTypeMapper.map('example.csv')
-      return content_type.should.equal('text/csv')
+      const contentType = this.ContentTypeMapper.map('example.csv')
+      return contentType.should.equal('text/csv')
     })
     })
 
 
     it('should map .pdf to application/pdf', function () {
     it('should map .pdf to application/pdf', function () {
-      const content_type = this.ContentTypeMapper.map('example.pdf')
-      return content_type.should.equal('application/pdf')
+      const contentType = this.ContentTypeMapper.map('example.pdf')
+      return contentType.should.equal('application/pdf')
     })
     })
 
 
     it('should fall back to octet-stream', function () {
     it('should fall back to octet-stream', function () {
-      const content_type = this.ContentTypeMapper.map('example.unknown')
-      return content_type.should.equal('application/octet-stream')
+      const contentType = this.ContentTypeMapper.map('example.unknown')
+      return contentType.should.equal('application/octet-stream')
     })
     })
 
 
     describe('coercing web files to plain text', function () {
     describe('coercing web files to plain text', function () {
       it('should map .js to plain text', function () {
       it('should map .js to plain text', function () {
-        const content_type = this.ContentTypeMapper.map('example.js')
-        return content_type.should.equal('text/plain')
+        const contentType = this.ContentTypeMapper.map('example.js')
+        return contentType.should.equal('text/plain')
       })
       })
 
 
       it('should map .html to plain text', function () {
       it('should map .html to plain text', function () {
-        const content_type = this.ContentTypeMapper.map('example.html')
-        return content_type.should.equal('text/plain')
+        const contentType = this.ContentTypeMapper.map('example.html')
+        return contentType.should.equal('text/plain')
       })
       })
 
 
       return it('should map .css to plain text', function () {
       return it('should map .css to plain text', function () {
-        const content_type = this.ContentTypeMapper.map('example.css')
-        return content_type.should.equal('text/plain')
+        const contentType = this.ContentTypeMapper.map('example.css')
+        return contentType.should.equal('text/plain')
       })
       })
     })
     })
 
 
     return describe('image files', function () {
     return describe('image files', function () {
       it('should map .png to image/png', function () {
       it('should map .png to image/png', function () {
-        const content_type = this.ContentTypeMapper.map('example.png')
-        return content_type.should.equal('image/png')
+        const contentType = this.ContentTypeMapper.map('example.png')
+        return contentType.should.equal('image/png')
       })
       })
 
 
       it('should map .jpeg to image/jpeg', function () {
       it('should map .jpeg to image/jpeg', function () {
-        const content_type = this.ContentTypeMapper.map('example.jpeg')
-        return content_type.should.equal('image/jpeg')
+        const contentType = this.ContentTypeMapper.map('example.jpeg')
+        return contentType.should.equal('image/jpeg')
       })
       })
 
 
       return it('should map .svg to text/plain to protect against XSS (SVG can execute JS)', function () {
       return it('should map .svg to text/plain to protect against XSS (SVG can execute JS)', function () {
-        const content_type = this.ContentTypeMapper.map('example.svg')
-        return content_type.should.equal('text/plain')
+        const contentType = this.ContentTypeMapper.map('example.svg')
+        return contentType.should.equal('text/plain')
       })
       })
     })
     })
   })
   })

+ 2 - 3
services/clsi/test/unit/js/ProjectPersistenceManagerTests.js

@@ -1,5 +1,4 @@
 /* eslint-disable
 /* eslint-disable
-    camelcase,
     no-return-assign,
     no-return-assign,
     no-unused-vars,
     no-unused-vars,
 */
 */
@@ -104,9 +103,9 @@ describe('ProjectPersistenceManager', function () {
     })
     })
 
 
     it('should clear each expired project', function () {
     it('should clear each expired project', function () {
-      return Array.from(this.project_ids).map(project_id =>
+      return Array.from(this.project_ids).map(projectId =>
         this.ProjectPersistenceManager.clearProjectFromCache
         this.ProjectPersistenceManager.clearProjectFromCache
-          .calledWith(project_id)
+          .calledWith(projectId)
           .should.equal(true)
           .should.equal(true)
       )
       )
     })
     })