mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #17816 from overleaf/bg-eslint-rule-for-find-with-await
add eslint rule for find with await GitOrigin-RevId: 7e78104e610073ff3c151d7314753c8301a8c787
This commit is contained in:
parent
9f86f90a08
commit
598eaf08fd
2 changed files with 6 additions and 1 deletions
|
@ -133,6 +133,11 @@
|
|||
{
|
||||
"selector": "CallExpression[callee.property.name='map'] Identifier[name='ObjectId']:first-child, CallExpression[callee.property.name='map'] MemberExpression[property.name='ObjectId']:first-child",
|
||||
"message": "Don't map ObjectId directly. Use `id => new ObjectId(id)` instead"
|
||||
},
|
||||
// Catch incorrect usage of `await db.collection.find()`
|
||||
{
|
||||
"selector": "AwaitExpression > CallExpression > MemberExpression[property.name='find'][object.object.name='db']",
|
||||
"message": "Mongo find returns a cursor not a promise, use `for await (const result of cursor)` or `.toArray()` instead."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ const { db, waitForDb } = require('../app/src/infrastructure/mongodb')
|
|||
|
||||
async function updateStringDates() {
|
||||
await waitForDb()
|
||||
const users = await db.users.find({
|
||||
const users = db.users.find({
|
||||
splitTests: { $exists: true },
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue