如何修复意外的令牌解析错误?

how to fix unexpected token parsing error?

箭头一直对我有效,但我现在收到错误消息 Parsing error: Unexpected token => 我尝试检查语法和括号,是的,我确实错过了任何括号。

代码:

const functions = require("firebase-functions");

const Filter = require("bad-words");

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

const db = admin.firestore();

exports.detectEvilUsers = functions.firestore
  .document("messages/{msgId}")
  .onCreate(async (doc, ctx) => {
    const filter = new Filter();
    const { text, uid } = doc.data();

    if (filter.isProfane(text)) {
      const cleaned = filter.clean(text);
      await doc.ref.update({
        text: "I got banned for lifetime for using voilated words",
      });

      await db.collection("banned").doc(uid).set({});
    }
  });

错误:

Parsing error: Unexpected token =>

并且如果尝试将其更改为正常的 function(){} 调用,就像这样

exports.detectEvilUsers = functions.firestore
  .document("messages/{msgId}")
  .onCreate(async function(doc, ctx)  {
        const filter = new Filter();
        const { text, uid } = doc.data();
    ....
    ....
    ....
    }

它给了我 Parsing error:unexpected token function

Eslin.json 文件: { "parser": "babel-eslint", "plugins": [ "babel" ], "extends": [ "plugin:prettier/recommended", "plugin:react/recommended" ], "env": { "browser": true, "es6": true, "jest": true }, "parserOptions": { "ecmaVersion": 2018, "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "rules": { "curly": "error", "eqeqeq": "error", "guard-for-in": "error", "no-extend-native": "error", "complexity": [ "error", 200 ], "max-depth": [ "error", 5 ], "max-params": [ "error", 12 ], "max-statements": [ "error", 200 ], "no-caller": "error", "no-irregular-whitespace": "error", "no-new": "error", "no-undef": "error", "no-unused-vars": "error", "no-global-assign": "error", "react/prop-types": "off", "babel/semi": 1 } }