Моя функция облака:
exports.onCommentarie = functions.firestore
.document('posts/{postId}/{commentaries}/{commentarieId}')
.onCreate((context) => {
let postId = context.params.postId
let commentarieId = context.params.commentarieId
let commentarie = context.data.data().comment
let ownerCommentarieName = context.data.data().creatorName
let ownerCommentarieId = context.data.data().creatorId
let postCreatorId = context.data.data().postCreatorId
console.log(postCreatorId)
const store = admin.firestore()
store.collection('users').doc(postCreatorId).get()
.then(doc => {
let userToken = doc.data().tokenId
return userToken
})
.then(userToken => {
console.log(userToken)
console.log('O token destino é:', userToken)
console.log('O id de quem criou o post é:', postCreatorId)
console.log('O comentário foi:', commentarie)
console.log('O nome de quem comentou é:', ownerCommentarieName)
console.log('o Id do post foi:', postId)
console.log('o Id do comentário foi:', commentarieId)
let message = {
notification: {
title: 'Comentário no seu post de:',
body: ownerCommentarieName
},
token: userToken
}
admin.messaging().send(message)
.then((response) => {
return console.log('Successfully sent message:', response)
})
.catch(err => {
return console.log(err)
})
})
})
Это приводит к большому количеству ненужных ошибок, а именно:
38:3 error Expected catch() or return promise/catch-or-return
43:9 error Each then() should return a value or throw promise/always-return
58:3 warning Avoid nesting promises promise/no-nesting
58:3 warning Avoid nesting promises promise/no-nesting
Почему Линт говорит это?