我在Google上搜索并尝试了不同的方法,但似乎async函数导致了一个错误,称=>
是意外的。我尝试将ecmaVersion添加到. eslintrc.js中,但没有结果。
我的代码:
exports.badgeUpdated = functions.firestore
.document("badges/{docId}")
.onUpdate(async (change, _) => {
//get the document that has changed and the new fieldvalue
const newObjectId = change.after.id;
const newObject = change.after.data();
const newBadgeName = newObject.badgeName;
console.log(`New BadgeName ${newBadgeName}`);
//Search badge doc with changed ID and set new name
const badgedRef = admin
.firestore()
.collectionGroup("badgeCollection")
.where("id", "==", newObjectId).get();
console.log(`Queryresult ${(await badgedRef).docs}`);
return null;
});
linter在抱怨第三行my. eslintrc. js:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
parserOptions: {
"ecmaFeatures": {
"ecmaVersion": 2022,
},
"sourceType": "module",
},
rules: {
"quotes": ["error", "double"],
"linebreak-style": ["error", "windows"],
},
};
1条答案
按热度按时间omqzjyyz1#
ecmaVersion
不应在ecmaFeatures
中。https://eslint.org/docs/latest/use/configure/language-options
此外,请确保您使用的是最新版本的ESLint。