Firebase Deploy 导致多个错误且未部署

Firebase Deploy causing multiple errors and not deploying

您好,我正在关注这个 tutorial in order to do push notifications to multiple devices at once in Expo React Native using Firebase's cloud functions. The push tokens are stored in my RealTime-Database, but when I attempt to integrate this step after running firebase login and firebase init, I updated my index.js file to contain this code。保存此文件后,我尝试进行 firebase 部署,但出现 70 错误。我尝试从我的 app 目录部署它,但没有成功,我尝试从我的 functions 目录部署它,但没有成功。我删除了 node_modules 和 package-lock,并尝试再次重新 运行 expo 并清除我的 npm 缓存。没有任何效果。我已经在其他地方初始化了我的 firebase 应用程序,这可能是原因吗?但是我的应用程序本身仍然有效,所以我没有收到错误消息说 Firebase 应用程序被初始化了两次。我真的不知道还能做什么。 ESLint 是否导致了所有这些错误?我应该在不添加 ESLint 的情况下再次 运行 firebase init 吗?请告诉我。我的错误如下。

部署代码时,默认情况下,您的代码会使用名为 ESLint 的工具进行检查。

您看到的“错误”是 eslint 抱怨一些琐碎的事情,例如行尾缺少分号,使用 ' 而不是 ",代码缩进不当,等等其他事情。如果您不了解规则的作用,可以访问 https://eslint.org/docs/rules/{rule-name}(例如 https://eslint.org/docs/rules/semi)。

如错误消息所示,您可以使用 eslint . --fix 自动修复其中的大部分问题。只需进入您的 functions 目录并执行 eslint . --fix.

大多数 IDE 都有一个键盘快捷键,可以根据您的规则自动格式化代码。例如在VSCode中,这个快捷方式是Alt+Shift+F.