Skip to content

Fix: ignore chain in update collection method #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

felipinas
Copy link
Contributor

Fix ESLint rule to properly handle method chains

Problem

The ESLint rule no-sync-mongo-methods-on-server was incorrectly flagging method chains as errors when they weren't MongoDB-related sync operations. Specifically, it wasn't properly handling cases where the chain included CallExpression types, such as in crypto.createHmac().update().

Solution

Enhanced the method chain detection to consider both MemberExpression and CallExpression types in the object chain. This allows the rule to properly skip validation for non-MongoDB method chains while still catching actual sync MongoDB operations.

Changes

  • Added support for CallExpression in the chain detection logic
  • Added test case for crypto.createHmac().update() to verify the fix
  • Added clarifying comment explaining the purpose of the chain detection

@renanccastro renanccastro merged commit 8bab265 into quavedev:main Dec 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants