Explorar el Código

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

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

GitOrigin-RevId: 8d6bb1398b3db2794bf1b2f97cd6d2886f2b4b0a
Jakob Ackermann hace 4 años
padre
commit
12890edd14

+ 0 - 1
services/web/.eslintrc

@@ -22,7 +22,6 @@
     // do not allow importing of implicit dependencies.
     "import/no-extraneous-dependencies": "error",
 
-    "node/no-callback-literal": "off",
     "node/no-deprecated-api": "off"
   },
   "overrides": [

+ 2 - 1
services/web/app/src/Features/Exports/ExportsHandler.js

@@ -190,7 +190,8 @@ module.exports = ExportsHandler = self = {
             `v1 export returned failure; forwarding: ${body}`
           )
           // pass the v1 error along for the publish modal to handle
-          return callback({ forwardResponse: body })
+          const err = { forwardResponse: body }
+          return callback(err)
         }
       }
     )

+ 6 - 3
services/web/app/src/Features/UserMembership/UserMembershipHandler.js

@@ -61,10 +61,12 @@ const UserMembershipHandler = {
         return callback(error)
       }
       if (!user) {
-        return callback({ userNotFound: true })
+        const err = { userNotFound: true }
+        return callback(err)
       }
       if (entity[attribute].some(managerId => managerId.equals(user._id))) {
-        return callback({ alreadyAdded: true })
+        error = { alreadyAdded: true }
+        return callback(error)
       }
 
       return addUserToEntity(entity, attribute, user, error =>
@@ -79,7 +81,8 @@ const UserMembershipHandler = {
     }
     const attribute = entityConfig.fields.write
     if (entity.admin_id != null ? entity.admin_id.equals(userId) : undefined) {
-      return callback({ isAdmin: true })
+      const error = { isAdmin: true }
+      return callback(error)
     }
     return removeUserFromEntity(entity, attribute, userId, callback)
   },

+ 2 - 2
services/web/frontend/js/services/queued-http.js

@@ -59,10 +59,10 @@ export default App.factory('queuedHttp', function ($http, $q) {
     const doRequest = () =>
       $http(...Array.from(args || []))
         .then((...args) =>
-          Array.from(successCallbacks).map(cb => cb(...Array.from(args || [])))
+          Array.from(successCallbacks).map(fn => fn(...Array.from(args || [])))
         )
         .catch((...args) =>
-          Array.from(errorCallbacks).map(cb => cb(...Array.from(args || [])))
+          Array.from(errorCallbacks).map(fn => fn(...Array.from(args || [])))
         )
 
     pendingRequests.push(doRequest)

+ 4 - 4
services/web/test/unit/src/FileStore/FileStoreHandlerTests.js

@@ -21,9 +21,9 @@ describe('FileStoreHandler', function () {
     }
     this.writeStream = {
       my: 'writeStream',
-      on(type, cb) {
+      on(type, fn) {
         if (type === 'response') {
-          cb({ statusCode: 200 })
+          fn({ statusCode: 200 })
         }
       },
     }
@@ -200,9 +200,9 @@ describe('FileStoreHandler', function () {
 
     describe('when upload fails', function () {
       beforeEach(function () {
-        this.writeStream.on = function (type, cb) {
+        this.writeStream.on = function (type, fn) {
           if (type === 'response') {
-            cb({ statusCode: 500 })
+            fn({ statusCode: 500 })
           }
         }
       })