Przeglądaj źródła

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

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

GitOrigin-RevId: af5aace52e1476b1b0ee48cc8be2aabbe04efac6
Jakob Ackermann 5 lat temu
rodzic
commit
669606f797

+ 0 - 1
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

+ 0 - 1
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

+ 3 - 1
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

+ 4 - 4
services/clsi/test/load/js/loadTest.js

@@ -55,13 +55,13 @@ ${bodyContent}
       },
     },
     (err, response, body) => {
-      if (response.statusCode !== 200) {
+      if (err != null) {
         failedCount++
-        return callback(`compile ${compileNumber} failed`)
+        return callback(new Error(`compile ${compileNumber} failed`))
       }
-      if (err != null) {
+      if (response.statusCode !== 200) {
         failedCount++
-        return callback('failed')
+        return callback(new Error(`compile ${compileNumber} failed`))
       }
       const totalTime = new Date() - startTime
       console.log(totalTime + 'ms')

+ 8 - 6
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'
+      )
     })
   })
 

+ 0 - 1
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

+ 0 - 1
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

+ 1 - 1
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(

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

+ 0 - 1
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

+ 1 - 0
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.

+ 1 - 0
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.

+ 1 - 0
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.

+ 0 - 1
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

+ 0 - 1
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

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

+ 0 - 1
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

+ 0 - 1
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

+ 0 - 1
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

+ 9 - 3
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()
             }