From 16fee6d7d27578a10c0720e7a122eaaab2b84c83 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Wed, 22 Mar 2023 07:52:39 -0400 Subject: [PATCH] Merge pull request #12203 from overleaf/em-camel-case-clsi Camel case variables in clsi GitOrigin-RevId: 1542a6b7f8886e5fef496ce31acd2bba537befa9 --- services/clsi/app/js/CompileManager.js | 4 +- services/clsi/app/js/DockerRunner.js | 4 +- services/clsi/app/js/LocalCommandRunner.js | 9 ++- services/clsi/app/js/OutputCacheManager.js | 2 +- .../clsi/app/js/ProjectPersistenceManager.js | 45 ++++++------ services/clsi/app/js/ResourceWriter.js | 41 ++++++----- .../clsi/app/js/StaticServerForbidSymlinks.js | 11 ++- services/clsi/app/js/UrlCache.js | 1 - .../acceptance/js/ExampleDocumentTests.js | 72 +++++++++---------- .../clsi/test/acceptance/js/helpers/Client.js | 37 +++++----- .../test/unit/js/ContentTypeMapperTests.js | 41 ++++++----- .../unit/js/ProjectPersistenceManagerTests.js | 5 +- 12 files changed, 128 insertions(+), 144 deletions(-) diff --git a/services/clsi/app/js/CompileManager.js b/services/clsi/app/js/CompileManager.js index 3be3c3c93d..784d191583 100644 --- a/services/clsi/app/js/CompileManager.js +++ b/services/clsi/app/js/CompileManager.js @@ -106,7 +106,7 @@ async function doCompile(request) { { projectId: request.project_id, userId: request.user_id, - time_taken: Date.now() - writeToDiskTimer.start, + timeTaken: Date.now() - writeToDiskTimer.start, }, 'written files to disk' ) @@ -248,7 +248,7 @@ async function doCompile(request) { { projectId: request.project_id, userId: request.user_id, - time_taken: ts, + timeTaken: ts, stats, timings, loadavg, diff --git a/services/clsi/app/js/DockerRunner.js b/services/clsi/app/js/DockerRunner.js index 198b9a7b82..2ebb1035a9 100644 --- a/services/clsi/app/js/DockerRunner.js +++ b/services/clsi/app/js/DockerRunner.js @@ -353,7 +353,7 @@ const DockerRunner = { callback = _.once(callback) const { name } = options - logger.debug({ container_name: name }, 'starting container') + logger.debug({ containerName: name }, 'starting container') const container = dockerode.getContainer(name) function createAndStartContainer() { @@ -390,7 +390,7 @@ const DockerRunner = { createAndStartContainer() } else if (error != null) { logger.err( - { container_name: name, error }, + { containerName: name, error }, 'unable to inspect container to start' ) callback(error) diff --git a/services/clsi/app/js/LocalCommandRunner.js b/services/clsi/app/js/LocalCommandRunner.js index 9f86b26e9d..d909ec601c 100644 --- a/services/clsi/app/js/LocalCommandRunner.js +++ b/services/clsi/app/js/LocalCommandRunner.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, no-unused-vars, */ @@ -22,7 +21,7 @@ logger.debug('using standard command runner') module.exports = CommandRunner = { run( - project_id, + projectId, command, directory, image, @@ -36,7 +35,7 @@ module.exports = CommandRunner = { command = Array.from(command).map(arg => 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') // merge environment settings @@ -62,7 +61,7 @@ module.exports = CommandRunner = { proc.on('error', function (err) { logger.err( - { err, project_id, command, directory }, + { err, projectId, command, directory }, 'error running command' ) return callback(err) @@ -70,7 +69,7 @@ module.exports = CommandRunner = { proc.on('close', function (code, signal) { let err - logger.debug({ code, signal, project_id }, 'command exited') + logger.debug({ code, signal, projectId }, 'command exited') if (signal === 'SIGTERM') { // signal from kill method below err = new Error('terminated') diff --git a/services/clsi/app/js/OutputCacheManager.js b/services/clsi/app/js/OutputCacheManager.js index c309b9fdef..ebde64c871 100644 --- a/services/clsi/app/js/OutputCacheManager.js +++ b/services/clsi/app/js/OutputCacheManager.js @@ -584,7 +584,7 @@ module.exports = OutputCacheManager = { // cache directory is empty return cleanupAll(callback) } - logger.error({ err, project_id: cacheRoot }, 'error clearing cache') + logger.error({ err, projectId: cacheRoot }, 'error clearing cache') return callback(err) } diff --git a/services/clsi/app/js/ProjectPersistenceManager.js b/services/clsi/app/js/ProjectPersistenceManager.js index 48982314a8..21348e1d7e 100644 --- a/services/clsi/app/js/ProjectPersistenceManager.js +++ b/services/clsi/app/js/ProjectPersistenceManager.js @@ -1,6 +1,3 @@ -/* eslint-disable - camelcase, -*/ // TODO: This file was created by bulk-decaffeinate. // 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() }, @@ -116,25 +113,25 @@ module.exports = ProjectPersistenceManager = { } return ProjectPersistenceManager._findExpiredProjectIds(function ( error, - project_ids + projectIds ) { if (error != null) { 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( - project_id, + projectId, function (err) { if (err != null) { - logger.error({ err, project_id }, 'error clearing project') + logger.error({ err, projectId }, 'error clearing project') } return callback() } ) - )(project_id) + )(projectId) ) return async.series(jobs, function (error) { if (error != null) { @@ -148,17 +145,17 @@ module.exports = ProjectPersistenceManager = { }) }, // ignore any errors from deleting directories - clearProject(project_id, user_id, callback) { + clearProject(projectId, userId, callback) { if (callback == null) { 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) { return callback(error) } return ProjectPersistenceManager.clearProjectFromCache( - project_id, + projectId, function (error) { if (error != null) { return callback(error) @@ -169,22 +166,22 @@ module.exports = ProjectPersistenceManager = { }) }, - clearProjectFromCache(project_id, callback) { + clearProjectFromCache(projectId, callback) { if (callback == null) { 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) { - logger.err({ error, project_id }, 'error clearing project from cache') + logger.err({ error, projectId }, 'error clearing project from cache') return callback(error) } return ProjectPersistenceManager._clearProjectFromDatabase( - project_id, + projectId, function (error) { if (error != null) { logger.err( - { error, project_id }, + { error, projectId }, '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() }, diff --git a/services/clsi/app/js/ResourceWriter.js b/services/clsi/app/js/ResourceWriter.js index da610508b8..11fb4500f4 100644 --- a/services/clsi/app/js/ResourceWriter.js +++ b/services/clsi/app/js/ResourceWriter.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, no-unused-vars, no-useless-escape, @@ -34,7 +33,7 @@ module.exports = ResourceWriter = { } if (request.syncType === 'incremental') { logger.debug( - { project_id: request.project_id, user_id: request.user_id }, + { projectId: request.project_id, userId: request.user_id }, 'incremental sync' ) return ResourceStateManager.checkProjectStateMatches( @@ -79,7 +78,7 @@ module.exports = ResourceWriter = { ) } logger.debug( - { project_id: request.project_id, user_id: request.user_id }, + { projectId: request.project_id, userId: request.user_id }, 'full sync' ) 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) { callback = function () {} } @@ -121,7 +120,7 @@ module.exports = ResourceWriter = { (resource => { return callback => ResourceWriter._writeResourceToDisk( - project_id, + projectId, resource, basePath, callback @@ -140,7 +139,7 @@ module.exports = ResourceWriter = { if (error != null) { return callback(error) } - const { project_id, resources } = request + const { project_id: projectId, resources } = request ResourceWriter._removeExtraneousFiles( request, resources, @@ -153,7 +152,7 @@ module.exports = ResourceWriter = { (resource => { return callback => ResourceWriter._writeResourceToDisk( - project_id, + projectId, resource, basePath, callback @@ -210,40 +209,40 @@ module.exports = ResourceWriter = { for (const file of Array.from(outputFiles || [])) { ;(function (file) { const { path } = file - let should_delete = true + let shouldDelete = true if ( path.match(/^output\./) || path.match(/\.aux$/) || path.match(/^cache\//) ) { // knitr cache - should_delete = false + shouldDelete = false } if (path.match(/^output-.*/)) { // Tikz cached figures (default case) - should_delete = false + shouldDelete = false } if (path.match(/\.(pdf|dpth|md5)$/)) { // Tikz cached figures (by extension) - should_delete = false + shouldDelete = false } if ( path.match(/\.(pygtex|pygstyle)$/) || path.match(/(^|\/)_minted-[^\/]+\//) ) { // minted files/directory - should_delete = false + shouldDelete = false } if ( path.match(/\.md\.tex$/) || path.match(/(^|\/)_markdown_[^\/]+\//) ) { // markdown files/directory - should_delete = false + shouldDelete = false } if (path.match(/-eps-converted-to\.pdf$/)) { // Epstopdf generated files - should_delete = false + shouldDelete = false } if ( path === 'output.pdf' || @@ -253,13 +252,13 @@ module.exports = ResourceWriter = { path === 'output.stdout' || path === 'output.stderr' ) { - should_delete = true + shouldDelete = true } if (path === 'output.tex') { // created by TikzManager if present in output files - should_delete = true + shouldDelete = true } - if (should_delete) { + if (shouldDelete) { return jobs.push(callback => ResourceWriter._deleteFileIfNotDirectory( 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) { callback = function () {} } @@ -332,7 +331,7 @@ module.exports = ResourceWriter = { // TODO: Don't overwrite file if it hasn't been modified if (resource.url != null) { return UrlCache.downloadUrlToFile( - project_id, + projectId, resource.url, path, resource.modified, @@ -341,9 +340,9 @@ module.exports = ResourceWriter = { logger.err( { err, - project_id, + projectId, path, - resource_url: resource.url, + resourceUrl: resource.url, modified: resource.modified, }, 'error downloading file for resources' diff --git a/services/clsi/app/js/StaticServerForbidSymlinks.js b/services/clsi/app/js/StaticServerForbidSymlinks.js index 8468b771d1..645053dc51 100644 --- a/services/clsi/app/js/StaticServerForbidSymlinks.js +++ b/services/clsi/app/js/StaticServerForbidSymlinks.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-cond-assign, no-unused-vars, n/no-deprecated-api, @@ -23,11 +22,11 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) { const expressStatic = staticFn(root, options) const basePath = Path.resolve(root) return function (req, res, next) { - let file, project_id, result + let file, projectId, result const path = req.url // check that the path is of the form /project_id_or_name/path/to/file.log if ((result = path.match(/^\/?([a-zA-Z0-9_-]+)\/(.*)/))) { - project_id = result[1] + projectId = result[1] file = result[2] } else { logger.warn({ path }, 'unrecognized file request') @@ -41,7 +40,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) { } } // check that the requested path is normalized - const requestedFsPath = `${basePath}/${project_id}/${file}` + const requestedFsPath = `${basePath}/${projectId}/${file}` if (requestedFsPath !== Path.normalize(requestedFsPath)) { logger.error( { path: requestedFsPath }, @@ -61,7 +60,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) { requestedFsPath, realFsPath, path: req.params[0], - project_id: req.params.project_id, + projectId: req.params.project_id, }, 'error checking file access' ) @@ -73,7 +72,7 @@ module.exports = ForbidSymlinks = function (staticFn, root, options) { requestedFsPath, realFsPath, path: req.params[0], - project_id: req.params.project_id, + projectId: req.params.project_id, }, 'trying to access a different file (symlink), aborting' ) diff --git a/services/clsi/app/js/UrlCache.js b/services/clsi/app/js/UrlCache.js index bc7d4a99b2..9fbd168436 100644 --- a/services/clsi/app/js/UrlCache.js +++ b/services/clsi/app/js/UrlCache.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, */ // TODO: This file was created by bulk-decaffeinate. diff --git a/services/clsi/test/acceptance/js/ExampleDocumentTests.js b/services/clsi/test/acceptance/js/ExampleDocumentTests.js index 5407f9a0d7..a7ca8d1416 100644 --- a/services/clsi/test/acceptance/js/ExampleDocumentTests.js +++ b/services/clsi/test/acceptance/js/ExampleDocumentTests.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, no-unused-vars, */ @@ -56,18 +55,18 @@ const compare = function (originalPath, generatedPath, callback) { if (callback == null) { callback = function () {} } - const diff_file = `${fixturePath(generatedPath)}-diff.png` + const diffFile = `${fixturePath(generatedPath)}-diff.png` const proc = ChildProcess.exec( `compare -metric mae ${fixturePath(originalPath)} ${fixturePath( generatedPath - )} ${diff_file}` + )} ${diffFile}` ) let stderr = '' proc.stderr.on('data', chunk => (stderr += chunk)) return proc.on('exit', () => { if (stderr.trim() === '0 (0)') { // remove output diff if test matches expected image - fs.unlink(diff_file, err => { + fs.unlink(diffFile, err => { if (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) { 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) => { if (error != null) { return callback() } else { 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) => { if (error != null) { throw error } 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) } -const comparePdf = function (project_id, example_dir, callback) { +const comparePdf = function (projectId, exampleDir, callback) { if (callback == null) { callback = function () {} } 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( - `tmp/${project_id}.pdf`, - `tmp/${project_id}-generated.png`, + `tmp/${projectId}.pdf`, + `tmp/${projectId}-generated.png`, error => { if (error != null) { throw error } return convertToPng( - `examples/${example_dir}/output.pdf`, - `tmp/${project_id}-source.png`, + `examples/${exampleDir}/output.pdf`, + `tmp/${projectId}-source.png`, error => { if (error != null) { throw error } return fs.stat( - fixturePath(`tmp/${project_id}-source-0.png`), + fixturePath(`tmp/${projectId}-source-0.png`), (error, stat) => { if (error != null) { return compare( - `tmp/${project_id}-source.png`, - `tmp/${project_id}-generated.png`, + `tmp/${projectId}-source.png`, + `tmp/${projectId}-generated.png`, (error, same) => { if (error != null) { throw error @@ -160,7 +159,7 @@ const comparePdf = function (project_id, example_dir, callback) { } ) } else { - return compareMultiplePages(project_id, error => { + return compareMultiplePages(projectId, error => { if (error != null) { 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) { callback = function () {} } - const writeStream = fs.createWriteStream(fixturePath(`tmp/${project_id}.pdf`)) + const writeStream = fs.createWriteStream(fixturePath(`tmp/${projectId}.pdf`)) 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 checkPdfInfo(`tmp/${project_id}.pdf`, (error, optimised) => { + return checkPdfInfo(`tmp/${projectId}.pdf`, (error, optimised) => { if (error != null) { throw error } 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) }) - 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 () { - return (this.project_id = Client.randomId() + '_' + example_dir) + return (this.project_id = Client.randomId() + '_' + exampleDir) }) it('should generate the correct pdf', function (done) { @@ -226,7 +220,7 @@ describe('Example Documents', function () { return Client.compileDirectory( this.project_id, fixturePath('examples'), - example_dir, + exampleDir, 4242, (error, res, body) => { if ( @@ -242,7 +236,7 @@ describe('Example Documents', function () { const pdf = Client.getOutputFile(body, 'pdf') return downloadAndComparePdf( this.project_id, - example_dir, + exampleDir, pdf.url, done ) @@ -255,7 +249,7 @@ describe('Example Documents', function () { return Client.compileDirectory( this.project_id, fixturePath('examples'), - example_dir, + exampleDir, 4242, (error, res, body) => { if ( @@ -271,14 +265,14 @@ describe('Example Documents', function () { const pdf = Client.getOutputFile(body, 'pdf') return downloadAndComparePdf( this.project_id, - example_dir, + exampleDir, pdf.url, done ) } ) }) - }))(example_dir) + }))(exampleDir) ) }) diff --git a/services/clsi/test/acceptance/js/helpers/Client.js b/services/clsi/test/acceptance/js/helpers/Client.js index 0bc8b46210..ff3db7cd28 100644 --- a/services/clsi/test/acceptance/js/helpers/Client.js +++ b/services/clsi/test/acceptance/js/helpers/Client.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-unused-vars, */ // TODO: This file was created by bulk-decaffeinate. @@ -25,7 +24,7 @@ module.exports = Client = { return Math.random().toString(16).slice(2) }, - compile(project_id, data, callback) { + compile(projectId, data, callback) { if (callback == null) { callback = function () {} } @@ -35,7 +34,7 @@ module.exports = Client = { } return request.post( { - url: `${this.host}/project/${project_id}/compile`, + url: `${this.host}/project/${projectId}/compile`, json: { compile: data, }, @@ -44,11 +43,11 @@ module.exports = Client = { ) }, - clearCache(project_id, callback) { + clearCache(projectId, callback) { if (callback == null) { callback = function () {} } - return request.del(`${this.host}/project/${project_id}`, callback) + return request.del(`${this.host}/project/${projectId}`, callback) }, 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) { callback = function () {} } return request.get( { - url: `${this.host}/project/${project_id}/sync/code`, + url: `${this.host}/project/${projectId}/sync/code`, qs: { imageName, 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) { callback = function () {} } return request.get( { - url: `${this.host}/project/${project_id}/sync/pdf`, + url: `${this.host}/project/${projectId}/sync/pdf`, qs: { imageName, page, @@ -133,7 +132,7 @@ module.exports = Client = { ) }, - compileDirectory(project_id, baseDirectory, directory, serverPort, callback) { + compileDirectory(projectId, baseDirectory, directory, serverPort, callback) { if (callback == null) { callback = function () {} } @@ -200,23 +199,23 @@ module.exports = Client = { 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 - 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) { callback = function () {} } return request.get( { - url: `${this.host}/project/${project_id}/wordcount`, + url: `${this.host}/project/${projectId}/wordcount`, qs: { image, file, diff --git a/services/clsi/test/unit/js/ContentTypeMapperTests.js b/services/clsi/test/unit/js/ContentTypeMapperTests.js index b6363623d2..a80ef991ca 100644 --- a/services/clsi/test/unit/js/ContentTypeMapperTests.js +++ b/services/clsi/test/unit/js/ContentTypeMapperTests.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, no-unused-vars, */ @@ -24,56 +23,56 @@ describe('ContentTypeMapper', function () { return describe('map', 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 () { - 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 () { - 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 () { - 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 () { 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 () { - 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 () { - 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 () { 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 () { - 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 () { - 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') }) }) }) diff --git a/services/clsi/test/unit/js/ProjectPersistenceManagerTests.js b/services/clsi/test/unit/js/ProjectPersistenceManagerTests.js index a7ca9e48ba..10fe389dbf 100644 --- a/services/clsi/test/unit/js/ProjectPersistenceManagerTests.js +++ b/services/clsi/test/unit/js/ProjectPersistenceManagerTests.js @@ -1,5 +1,4 @@ /* eslint-disable - camelcase, no-return-assign, no-unused-vars, */ @@ -104,9 +103,9 @@ describe('ProjectPersistenceManager', 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 - .calledWith(project_id) + .calledWith(projectId) .should.equal(true) ) })