Skip to content

Commit

Permalink
fix: skip collection hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
renanccastro committed Feb 20, 2024
1 parent 4772df3 commit b716798
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/rules/no-sync-mongo-methods-on-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ module.exports = {
return;
}
}
if(node.object.type === 'MemberExpression'){
// we can ignore longer than 1 call chain
debug(
`Skipping ${invalidFunction} to be considered error because it was used in a longer than 1 call chain`,
{ object: node.object }
);
return;
}
createError({
context,
node,
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/no-sync-mongo-methods-on-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ruleTester.run('no-sync-mongo-methods-on-server', rule, {
only: true,
valid: [
{ code: 'TestCollection.findOneAsync()' },
{ code: 'UserAccess.after.insert((userId, doc) => {})' },
{
code: `
var modulesCursor = ModulesCollection.find();
Expand Down

0 comments on commit b716798

Please sign in to comment.