eslint-plugin-mongo
raw JSON → 1.0.5 verified Sat Apr 25 auth: no javascript maintenance
ESLint plugin providing environments for MongoDB server-side scripts (mapReduce, eval, $where) and MongoDB shell scripts. Version 1.0.5 is the latest and only release. It defines global variables specific to MongoDB contexts to prevent false positives in ESLint. Limited to environment definitions; does not include custom rules. Requires ESLint as a peer dependency. Last updated in 2018; no active development.
Common errors
error Error: Failed to load plugin 'mongo' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-mongo' ↓
cause Plugin not installed or ESLint cannot resolve it.
fix
Run 'npm install eslint-plugin-mongo --save-dev' and ensure node_modules is accessible.
error Parsing error: The keyword 'db' is not defined. ↓
cause MongoDB shell globals like 'db' are not recognized by ESLint.
fix
Enable the 'mongo/shell' environment in your ESLint config.
error Definition for rule 'mongo/rule-name' was not found. ↓
cause Plugin does not provide custom rules.
fix
Check plugin documentation; only environments are provided.
Warnings
deprecated Package is unmaintained since 2018. ↓
fix Consider using eslint-plugin-mongodb or writing custom globals.
gotcha Plugin only defines environments, no rules. May not meet all linting needs. ↓
fix Combine with other plugins or define custom rules.
gotcha Environments may not include all MongoDB globals (e.g., ObjectId, ISODate). ↓
fix Manually add globals in ESLint config.
Install
npm install eslint-plugin-mongo yarn add eslint-plugin-mongo pnpm add eslint-plugin-mongo Imports
- eslint-plugin-mongo wrong
{ "plugins": ["eslint-plugin-mongo"] }correct// In .eslintrc: { "plugins": ["mongo"] } - mongo/server-side wrong
{ "env": { "mongo-server-side": true } }correct// In .eslintrc: { "env": { "mongo/server-side": true } } - mongo/shell wrong
{ "env": { "mongo-shell": true } }correct// In .eslintrc: { "env": { "mongo/shell": true } }
Quickstart
// Install: npm install eslint eslint-plugin-mongo --save-dev
// .eslintrc.json
{
"plugins": ["mongo"],
"env": {
"mongo/shell": true
}
}