From b7167981fe3ba552a75ece1b63b73a194cc474c1 Mon Sep 17 00:00:00 2001 From: Renan Castro Date: Mon, 19 Feb 2024 21:29:37 -0300 Subject: [PATCH 1/2] fix: skip collection hooks --- lib/rules/no-sync-mongo-methods-on-server.js | 8 ++++++++ tests/lib/rules/no-sync-mongo-methods-on-server.js | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/rules/no-sync-mongo-methods-on-server.js b/lib/rules/no-sync-mongo-methods-on-server.js index 7bdac7e..e46f81c 100644 --- a/lib/rules/no-sync-mongo-methods-on-server.js +++ b/lib/rules/no-sync-mongo-methods-on-server.js @@ -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, diff --git a/tests/lib/rules/no-sync-mongo-methods-on-server.js b/tests/lib/rules/no-sync-mongo-methods-on-server.js index 44cd4dd..a42e811 100644 --- a/tests/lib/rules/no-sync-mongo-methods-on-server.js +++ b/tests/lib/rules/no-sync-mongo-methods-on-server.js @@ -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(); From ec288e6358b1f06601dd140c4162d4aafeda8fdc Mon Sep 17 00:00:00 2001 From: Renan Castro Date: Mon, 19 Feb 2024 21:29:53 -0300 Subject: [PATCH 2/2] fix: bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 113d2ac..6c5b18a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quave/eslint-plugin-meteor-quave", - "version": "1.4.0", + "version": "1.4.1", "description": "Quave linting rules for ESLint", "main": "lib/index.js", "scripts": {