Skip to content

Commit 8bab265

Browse files
authored
Merge pull request #15 from felipinas/fix/ignore-chain-in-update-collection-method
Fix: ignore chain in update collection method
2 parents 41fb151 + dd9799b commit 8bab265

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rules/no-sync-mongo-methods-on-server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ module.exports = {
134134
return;
135135
}
136136
}
137-
if(node.object.type === 'MemberExpression'){
137+
// this means it's a call chain like crypto.createHmac().update()
138+
if(['MemberExpression', 'CallExpression'].includes(node.object.type) && node.type === 'MemberExpression'){
138139
// we can ignore longer than 1 call chain
139140
debug(
140141
`Skipping ${invalidFunction} to be considered error because it was used in a longer than 1 call chain`,

tests/lib/rules/no-sync-mongo-methods-on-server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ ruleTester.run('no-sync-mongo-methods-on-server', rule, {
4848
modules.fetch();
4949
`,
5050
},
51+
{
52+
code: `
53+
crypto
54+
.createHmac('sha256', secretIntercomKey)
55+
.update(userId);
56+
`,
57+
},
5158
],
5259

5360
invalid: [

0 commit comments

Comments
 (0)