Merge pull request #5568 from overleaf/jpa-node-no-callback-literal

[misc] fix eslint violations for node/no-callback-literal

GitOrigin-RevId: af5aace52e1476b1b0ee48cc8be2aabbe04efac6
This commit is contained in:
Jakob Ackermann 2021-10-27 11:49:42 +02:00 committed by Copybot
parent 489df8360e
commit 669606f797
20 changed files with 37 additions and 30 deletions

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

View file

@ -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

View file

@ -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')

View file

@ -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'
)
})
})

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

View file

@ -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(

View file

@ -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}`
)
)
}
})
},

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

View file

@ -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.

View file

@ -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.

View file

@ -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.

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

View file

@ -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'))
}
})
},

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

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/no-callback-literal": "off",
"node/no-path-concat": "off",
"prefer-regex-literals": "off",
// END of temporary overrides

View file

@ -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()
}