Merge pull request #5367 from overleaf/jpa-node-handle-callback-err

[misc] fix eslint violations for node/handle-callback-err

GitOrigin-RevId: 83a4900e8861010df1917bff49382bd9c93375bd
This commit is contained in:
Jakob Ackermann
2021-10-28 08:03:26 +00:00
committed by Copybot
parent acd821089a
commit 18e89dd367
181 changed files with 746 additions and 658 deletions
-1
View File
@@ -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/handle-callback-err": "off",
"no-loss-of-precision": "off",
"node/no-callback-literal": "off",
"node/no-path-concat": "off",
@@ -1,6 +1,5 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
@@ -19,7 +18,7 @@ const metrics = require('@overleaf/metrics')
module.exports = Notifications = {
getUserNotifications(user_id, callback) {
if (callback == null) {
callback = function (err, notifications) {}
callback = function () {}
}
const query = {
user_id: ObjectId(user_id),
@@ -30,7 +29,7 @@ module.exports = Notifications = {
_countExistingNotifications(user_id, notification, callback) {
if (callback == null) {
callback = function (err, count) {}
callback = function () {}
}
const query = {
user_id: ObjectId(user_id),
@@ -1,6 +1,5 @@
/* eslint-disable
camelcase,
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
@@ -15,7 +14,7 @@ const logger = require('logger-sharelatex')
const metrics = require('@overleaf/metrics')
module.exports = {
getUserNotifications(req, res) {
getUserNotifications(req, res, next) {
logger.log(
{ user_id: req.params.user_id },
'getting user unread notifications'
@@ -23,7 +22,10 @@ module.exports = {
metrics.inc('getUserNotifications')
return Notifications.getUserNotifications(
req.params.user_id,
(err, notifications) => res.json(notifications)
(err, notifications) => {
if (err) return next(err)
res.json(notifications)
}
)
},
@@ -46,7 +48,7 @@ module.exports = {
)
},
removeNotificationId(req, res) {
removeNotificationId(req, res, next) {
logger.log(
{
user_id: req.params.user_id,
@@ -58,11 +60,14 @@ module.exports = {
return Notifications.removeNotificationId(
req.params.user_id,
req.params.notification_id,
(err, notifications) => res.sendStatus(200)
err => {
if (err) return next(err)
res.sendStatus(200)
}
)
},
removeNotificationKey(req, res) {
removeNotificationKey(req, res, next) {
logger.log(
{ user_id: req.params.user_id, notification_key: req.body.key },
'mark key notification as read'
@@ -71,18 +76,21 @@ module.exports = {
return Notifications.removeNotificationKey(
req.params.user_id,
req.body.key,
(err, notifications) => res.sendStatus(200)
(err, notifications) => {
if (err) return next(err)
res.sendStatus(200)
}
)
},
removeNotificationByKeyOnly(req, res) {
removeNotificationByKeyOnly(req, res, next) {
const notification_key = req.params.key
logger.log({ notification_key }, 'mark notification as read by key only')
metrics.inc('removeNotificationKey')
return Notifications.removeNotificationByKeyOnly(
notification_key,
(err, notifications) => res.sendStatus(200)
)
return Notifications.removeNotificationByKeyOnly(notification_key, err => {
if (err) return next(err)
res.sendStatus(200)
})
},
countNotificationsByKeyOnly(req, res) {
@@ -1,6 +1,5 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-dupe-keys,
no-return-assign,
no-unused-vars,
@@ -62,6 +61,7 @@ describe('Notifications Tests', function () {
return this.notifications.getUserNotifications(
user_id,
(err, notifications) => {
if (err) return done(err)
notifications.should.equal(this.stubbedNotificationArray)
assert.deepEqual(this.findStub.args[0][0], {
user_id: ObjectId(user_id),
@@ -228,6 +228,7 @@ describe('Notifications Tests', function () {
user_id,
notification_id,
err => {
if (err) return done(err)
const searchOps = {
user_id: ObjectId(user_id),
_id: ObjectId(notification_id),
@@ -251,6 +252,7 @@ describe('Notifications Tests', function () {
user_id,
notification_key,
err => {
if (err) return done(err)
const searchOps = {
user_id: ObjectId(user_id),
key: notification_key,
@@ -273,6 +275,7 @@ describe('Notifications Tests', function () {
return this.notifications.removeNotificationByKeyOnly(
notification_key,
err => {
if (err) return done(err)
const searchOps = { key: notification_key }
const updateOperation = { $unset: { templateKey: true } }
assert.deepEqual(this.updateOneStub.args[0][0], searchOps)
@@ -290,6 +293,7 @@ describe('Notifications Tests', function () {
return this.notifications.deleteNotificationByKeyOnly(
notification_key,
err => {
if (err) return done(err)
const searchOps = { key: notification_key }
assert.deepEqual(this.deleteOneStub.args[0][0], searchOps)
return done()