Skip to main content

What it flags

A Mongoose find, findOne or findById result is only null-checked and converted with .toObject() or .toJSON().

How to review or fix

Append .lean() to skip hydration. Skipped when a schema customizes toObject or toJSON. A lean result also skips schema defaults, getters and virtuals, so a stored document that lacks a defaulted field comes back without it; check that callers do not rely on those before applying the change. For that reason the inline fix requires review, and --yes does not apply it.

Configuration

Set the rule to "off" in loadwise.config.json to drop its findings: