diff --git a/services/chat/.eslintrc b/services/chat/.eslintrc index c852478384..b3d597e163 100644 --- a/services/chat/.eslintrc +++ b/services/chat/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/clsi/.eslintrc b/services/clsi/.eslintrc index c852478384..b3d597e163 100644 --- a/services/clsi/.eslintrc +++ b/services/clsi/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/clsi/app/js/RequestParser.js b/services/clsi/app/js/RequestParser.js index e916f2a20a..daa1e91ad6 100644 --- a/services/clsi/app/js/RequestParser.js +++ b/services/clsi/app/js/RequestParser.js @@ -30,7 +30,9 @@ module.exports = RequestParser = { const response = {} if (body.compile == null) { - return callback('top level object should have a compile attribute') + return callback( + new Error('top level object should have a compile attribute') + ) } const { compile } = body diff --git a/services/clsi/test/load/js/loadTest.js b/services/clsi/test/load/js/loadTest.js index f5e1fce063..196d8579ca 100644 --- a/services/clsi/test/load/js/loadTest.js +++ b/services/clsi/test/load/js/loadTest.js @@ -55,13 +55,13 @@ ${bodyContent} }, }, (err, response, body) => { - if (response.statusCode !== 200) { - failedCount++ - return callback(`compile ${compileNumber} failed`) - } if (err != null) { failedCount++ - return callback('failed') + return callback(new Error(`compile ${compileNumber} failed`)) + } + if (response.statusCode !== 200) { + failedCount++ + return callback(new Error(`compile ${compileNumber} failed`)) } const totalTime = new Date() - startTime console.log(totalTime + 'ms') diff --git a/services/clsi/test/unit/js/RequestParserTests.js b/services/clsi/test/unit/js/RequestParserTests.js index 8128b58e5a..3e24d94d5d 100644 --- a/services/clsi/test/unit/js/RequestParserTests.js +++ b/services/clsi/test/unit/js/RequestParserTests.js @@ -54,9 +54,10 @@ describe('RequestParser', function () { }) return it('should return an error', function () { - return this.callback - .calledWith('top level object should have a compile attribute') - .should.equal(true) + expect(this.callback).to.have.been.called + expect(this.callback.args[0][0].message).to.equal( + 'top level object should have a compile attribute' + ) }) }) @@ -66,9 +67,10 @@ describe('RequestParser', function () { }) return it('should return an error', function () { - return this.callback - .calledWith('top level object should have a compile attribute') - .should.equal(true) + expect(this.callback).to.have.been.called + expect(this.callback.args[0][0].message).to.equal( + 'top level object should have a compile attribute' + ) }) }) diff --git a/services/contacts/.eslintrc b/services/contacts/.eslintrc index c852478384..b3d597e163 100644 --- a/services/contacts/.eslintrc +++ b/services/contacts/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/docstore/.eslintrc b/services/docstore/.eslintrc index c852478384..b3d597e163 100644 --- a/services/docstore/.eslintrc +++ b/services/docstore/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/docstore/app/js/DocManager.js b/services/docstore/app/js/DocManager.js index 360840886c..91d45dd3e5 100644 --- a/services/docstore/app/js/DocManager.js +++ b/services/docstore/app/js/DocManager.js @@ -33,7 +33,7 @@ module.exports = DocManager = { callback = function () {} } if (filter.inS3 !== true) { - return callback('must include inS3 when getting doc') + return callback(new Error('must include inS3 when getting doc')) } return MongoManager.findDoc( diff --git a/services/docstore/app/js/HealthChecker.js b/services/docstore/app/js/HealthChecker.js index 5578afff75..08f193da6c 100644 --- a/services/docstore/app/js/HealthChecker.js +++ b/services/docstore/app/js/HealthChecker.js @@ -46,16 +46,20 @@ module.exports = { logger.err({ err }, 'docstore returned a error in health check get') return cb(err) } else if (res == null) { - return cb('no response from docstore with get check') + return cb(new Error('no response from docstore with get check')) } else if ((res != null ? res.statusCode : undefined) !== 200) { - return cb(`status code not 200, its ${res.statusCode}`) + return cb(new Error(`status code not 200, its ${res.statusCode}`)) } else if ( _.isEqual(body != null ? body.lines : undefined, lines) && (body != null ? body._id : undefined) === doc_id.toString() ) { return cb() } else { - return cb(`health check lines not equal ${body.lines} != ${lines}`) + return cb( + new Error( + `health check lines not equal ${body.lines} != ${lines}` + ) + ) } }) }, diff --git a/services/document-updater/.eslintrc b/services/document-updater/.eslintrc index c852478384..b3d597e163 100644 --- a/services/document-updater/.eslintrc +++ b/services/document-updater/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/document-updater/app/js/sharejs/model.js b/services/document-updater/app/js/sharejs/model.js index a14f806d72..a4ad89ab38 100644 --- a/services/document-updater/app/js/sharejs/model.js +++ b/services/document-updater/app/js/sharejs/model.js @@ -1,6 +1,7 @@ /* eslint-disable no-console, no-return-assign, + node/no-callback-literal, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. diff --git a/services/document-updater/app/js/sharejs/server/model.js b/services/document-updater/app/js/sharejs/server/model.js index 8d029c7ac7..a5a36ad34b 100644 --- a/services/document-updater/app/js/sharejs/server/model.js +++ b/services/document-updater/app/js/sharejs/server/model.js @@ -1,6 +1,7 @@ /* eslint-disable no-console, no-return-assign, + node/no-callback-literal, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. diff --git a/services/document-updater/app/js/sharejs/types/model.js b/services/document-updater/app/js/sharejs/types/model.js index a14f806d72..a4ad89ab38 100644 --- a/services/document-updater/app/js/sharejs/types/model.js +++ b/services/document-updater/app/js/sharejs/types/model.js @@ -1,6 +1,7 @@ /* eslint-disable no-console, no-return-assign, + node/no-callback-literal, */ // TODO: This file was created by bulk-decaffeinate. // Fix any style issues and re-enable lint. diff --git a/services/filestore/.eslintrc b/services/filestore/.eslintrc index c852478384..b3d597e163 100644 --- a/services/filestore/.eslintrc +++ b/services/filestore/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/notifications/.eslintrc b/services/notifications/.eslintrc index c852478384..b3d597e163 100644 --- a/services/notifications/.eslintrc +++ b/services/notifications/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/notifications/app/js/HealthCheckController.js b/services/notifications/app/js/HealthCheckController.js index b2a60048fc..46ec01aef3 100644 --- a/services/notifications/app/js/HealthCheckController.js +++ b/services/notifications/app/js/HealthCheckController.js @@ -69,7 +69,7 @@ module.exports = { { body, notification_key }, 'Health Check: notification not in response' ) - return cb('notification not found in response') + return cb(new Error('notification not found in response')) } }) }, diff --git a/services/real-time/.eslintrc b/services/real-time/.eslintrc index c852478384..b3d597e163 100644 --- a/services/real-time/.eslintrc +++ b/services/real-time/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/spelling/.eslintrc b/services/spelling/.eslintrc index c852478384..b3d597e163 100644 --- a/services/spelling/.eslintrc +++ b/services/spelling/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/track-changes/.eslintrc b/services/track-changes/.eslintrc index c852478384..b3d597e163 100644 --- a/services/track-changes/.eslintrc +++ b/services/track-changes/.eslintrc @@ -22,7 +22,6 @@ "rules": { // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671) // START of temporary overrides - "node/no-callback-literal": "off", "node/no-path-concat": "off", "prefer-regex-literals": "off", // END of temporary overrides diff --git a/services/track-changes/app/js/HealthChecker.js b/services/track-changes/app/js/HealthChecker.js index 978f586f6e..7497e56977 100644 --- a/services/track-changes/app/js/HealthChecker.js +++ b/services/track-changes/app/js/HealthChecker.js @@ -34,7 +34,9 @@ module.exports = { ) return cb(err) } else if ((res != null ? res.statusCode : undefined) !== 200) { - return cb(`status code not 200, it's ${res.statusCode}`) + return cb( + new Error(`status code not 200, it's ${res.statusCode}`) + ) } else { return cb() } @@ -48,7 +50,9 @@ module.exports = { logger.err({ err, project_id }, 'error flushing for health check') return cb(err) } else if ((res != null ? res.statusCode : undefined) !== 204) { - return cb(`status code not 204, it's ${res.statusCode}`) + return cb( + new Error(`status code not 204, it's ${res.statusCode}`) + ) } else { return cb() } @@ -65,7 +69,9 @@ module.exports = { ) return cb(err) } else if ((res != null ? res.statusCode : undefined) !== 200) { - return cb(`status code not 200, it's ${res.statusCode}`) + return cb( + new Error(`status code not 200, it's ${res.statusCode}`) + ) } else { return cb() }