Javascript 节点Js错误:";错误预期catch()或return,promise/catch或return“;火基

Javascript 节点Js错误:";错误预期catch()或return,promise/catch或return“;火基,javascript,node.js,firebase,google-cloud-firestore,google-cloud-functions,Javascript,Node.js,Firebase,Google Cloud Firestore,Google Cloud Functions,我正在尝试为我的社交媒体应用程序部署Firebase功能。我正在为用户帖子等创建CRUD函数,但下面有一个错误。代码附在下面 错误 === Deploying to 'AppName-780db'... i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint > functions@ lint F:\_dev\AppName\functions > eslint

我正在尝试为我的社交媒体应用程序部署Firebase功能。我正在为用户帖子等创建CRUD函数,但下面有一个错误。代码附在下面

错误

=== Deploying to 'AppName-780db'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint F:\_dev\AppName\functions
> eslint .


F:\_dev\AppName\functions\index.js
  118:7   error  Expected catch() or return                  promise/catch-or-return
 A 126:11  error  Each then() should return a value or throw  promise/always-return
  151:7   error  Expected catch() or return                  promise/catch-or-return
  159:11  error  Each then() should return a value or throw  promise/always-return

✖ 4 problems (4 errors, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USERPC\AppData\Roaming\npm-cache\_logs\2020-11-13T23_04_10_358Z-debug.log
events.js:287
      throw er; // Unhandled 'error' event
      ^
我已经修剪并粘贴了有问题的错误片段,因为Stack说我发布了大部分代码

代码

const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();

admin
        .firestore()
        .collection("timeline")
        .doc(followerId)
        .collection("timelinePosts")
        .doc(postId)
        .get()
        .then(doc => {
          if (doc.exists) {
            doc.ref.update(postUpdated);
          }
        });
===============

admin
        .firestore()
        .collection("timeline")
        .doc(followerId)
        .collection("timelinePosts")
        .doc(postId)
        .get()
        .then(doc => {
          if (doc.exists) {
            doc.ref.delete();
          }

我在这里删除了对颤振的提及,因为您所展示的内容与颤振没有任何直接关系。这是在云函数中运行的JavaScript后端代码,与您调用它的前端类型无关。这里的问题是JavaScript eslint警告。@DougStevenson我看到过这些帖子,它们在我的代码中不起作用。我添加了
return
error
它们只是添加了更多的错误。我正在学习我的课程,对于作者来说,代码的工作原理是,在我的情况下,它会返回这些错误。既然我读到这些只是警告,有没有办法在过渡期间忽略它们呢?作者给出的编码建议不符合eslint确定的JavaScript最佳实践。如果按照副本中所述重新构造代码,错误将消失。我删除了“函数”文件夹“重新安装”节点,更新了软件包,并在安装Eslint时选择了“否”。一切正常,并已成功部署。您建议我启用Eslint并尝试解决警告?依我看,如果您希望获得最高质量的代码,请启用所有警告并解决所有警告。