All Projects â†’ SebastienElet â†’ eslint-plugin-mongodb

SebastienElet / eslint-plugin-mongodb

Licence: MIT license
🔎 MongoDB best practices rules for ESLint

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to eslint-plugin-mongodb

eslint-plugin-license-header
Rules to validate the presence of license headers in source files.
Stars: ✭ 21 (+23.53%)
Mutual labels:  eslint-plugin
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+1135.29%)
Mutual labels:  mongodb-database
eslint-plugin-googleappsscript
ESLint plugin for Google Apps Script environment
Stars: ✭ 37 (+117.65%)
Mutual labels:  eslint-plugin
eslint-plugin-gridsome
ESLint plugin for Gridsome
Stars: ✭ 45 (+164.71%)
Mutual labels:  eslint-plugin
eslint-plugin-strict-dependencies
ESlint plugin to define custom module dependency rules.
Stars: ✭ 142 (+735.29%)
Mutual labels:  eslint-plugin
mern-ecommerce
MERN Stack ecommerce site
Stars: ✭ 122 (+617.65%)
Mutual labels:  mongodb-database
MongoDB-University
Repo for All MongoDB University Courses
Stars: ✭ 102 (+500%)
Mutual labels:  mongodb-database
eslint-plugin-vue-scoped-css
ESLint plugin for Scoped CSS in Vue.js
Stars: ✭ 58 (+241.18%)
Mutual labels:  eslint-plugin
eslint-plugin-header
ESLint plugin to ensure that files begin with given comment
Stars: ✭ 65 (+282.35%)
Mutual labels:  eslint-plugin
eslint-plugin-roku
ESLint plugin to parse and lint BrightScript files
Stars: ✭ 44 (+158.82%)
Mutual labels:  eslint-plugin
eslint-plugin-aura
Salesforce Lightning (Aura) specific linting rules for ESLint
Stars: ✭ 24 (+41.18%)
Mutual labels:  eslint-plugin
eslint-plugin-array-func
Rules for Array functions and methods.
Stars: ✭ 77 (+352.94%)
Mutual labels:  eslint-plugin
eslint-plugin-diff
Run ESLint on your changes only
Stars: ✭ 80 (+370.59%)
Mutual labels:  eslint-plugin
eslint-plugin-no-only-tests
ESLint rule for catching focused/only test blocks
Stars: ✭ 67 (+294.12%)
Mutual labels:  eslint-plugin
Discord-Study-Bot
Discord-Study-Bot is a Study-Time-based leaderboard system in discord servers. This features an Overall leaderboard and leaderboards based on a Daily, Weekly, and Monthly basis.
Stars: ✭ 20 (+17.65%)
Mutual labels:  mongodb-database
ultimate-hot-boilerplate
🚀 node-react universal app boilerplate with everything on hot reload, SSR, GraphQL, Flow included
Stars: ✭ 35 (+105.88%)
Mutual labels:  eslint-plugin
eslint-plugin-import-access
www.npmjs.com/package/eslint-plugin-import-access
Stars: ✭ 204 (+1100%)
Mutual labels:  eslint-plugin
eslint-plugin-import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 4,290 (+25135.29%)
Mutual labels:  eslint-plugin
eslint-plugin-chai-friendly
Makes eslint friendly towards Chai.js 'expect' and 'should' statements.
Stars: ✭ 49 (+188.24%)
Mutual labels:  eslint-plugin
eslint-plugin-yml
This ESLint plugin provides linting rules for YAML.
Stars: ✭ 40 (+135.29%)
Mutual labels:  eslint-plugin

eslint-plugin-mongodb

Eslint rules for the NodeJS MongoDB native driver 2.0 syntax and best practices.

NPM version Build status Dependency Status devDependency Status Coverage Status Code Climate

Disclaimer: This is a work in progress. Use it only if you wish to be involved in this project evolution by reporting bugs or even sending PRs.

The first stable release will be 1.0.0.

Usage

  1. Install eslint as a dev-dependency:
npm install --save-dev eslint
  1. Install eslint-plugin-mongodb as a dev-dependency:
npm install --save-dev eslint-plugin-mongodb
  1. Enable the plugin by adding it to your .eslintrc:
plugins:
  - mongodb
  1. You can also configure these rules in your .eslintrc. All rules defined in this plugin have to be prefixed by 'mongodb/'

    plugins:
      - mongodb
    rules:
      - mongodb/no-replace: 0

Settings

In order to recognize MongoDB native driver queries, this plugin check for function calls. By using shared settings you can specify your own patterns, here are the defaults:

{
    "settings": {
        "mongodb": {
          "callPatterns": {
            "query": [
              "(\\.|^)db\\.collection\\([^\\)]+\\)\\.(find|findOne|)$",
            ],
            "update": [
              "(\\.|^)db\\.collection\\([^\\)]+\\)\\.(findOneAndUpdate|updateOne|updateMany)$",
            ],
            "insert": [
              "(\\.|^)db\\.collection\\([^\\)]+\\)\\.(insertOne|insertMany)$",
            ],
            "remove": [
              "(\\.|^)db\\.collection\\([^\\)]+\\)\\.(findOneAndDelete|deleteOne|deleteMany)$",
            ],
            "deprecated": [
              "(\\.|^)db\\.collection\\([^\\)]+\\)\\.(remove|update|findAndModify|ensureIndex|findAndRemove|insert|dropAllIndexes)$",
            ]
          }
        }
    }
})

Note that the above are strings representing regular expressions. It will be cast with the RegExp constructor so you have to escape your escapes ;).

Rules

check-insert-calls

Default: 'check-insert-calls': 2

Check insertOne/insertMany calls to ensure their arguments are well formed.

check-query-calls

Default: 'check-query-calls': 2

Check find/findOne calls to ensure their arguments are well formed.

check-update-calls

Default: 'check-update-calls': 2

Check update calls to ensure their arguments are well formed.

check-remove-calls

Default: 'check-remove-calls': 2

Check remove calls to ensure their arguments are well formed.

check-deprecated-calls

Default: 'check-deprecated-calls': 2

Check collection calls and warn in case of deprecated methods usage.

no-replace

Default: 'no_replace': 1

Check update queries to ensure no raw replace is done.

check-rename-updates

Default: 'check-rename-updates': 2

Check $rename update operator usage.

check-unset-updates

Default: 'check-unset-updates': 2

Check $unset update operator usage.

check-current-date-updates

Default: 'check-current-date-updates': 2

Check $currentDate update operator usage.

check-numeric-updates

Default: 'check-numeric-updates': 2

Check update queries to ensure numeric operators like $mul and $inc contain numeric values.

check-minmax-updates

Default: 'check-minmax-updates': 2

Check $min and $max update operators usage.

check-set-updates

Default: 'check-set-updates': 2

Check $set and $setOnInsert update operators usage.

check-push-updates

Default: 'check-push-updates': 2

Check $push update operator usage and its modifiers.

check-pull-updates

Default: 'check-pull-updates': 2

Check $pull update operator usage.

check-pop-updates

Default: 'check-pop-updates': 2

Check $pop update operator usage.

check-addtoset-updates

Default: 'check-addtoset-updates': 2

Check $addToSet update operator usage and common misuses.

check-deprecated-updates

Default: 'check-deprecated-updates': 2

Check deprecated update operator usage.

Contributing

Feel free to push your code if you agree with publishing under the MIT license.

How to create a new rule

Avoid wasting your time and follow those steps to suggest a new rule:

  • create and issue prefixed by [rule] and followed by it's name
  • OR create the rule tests file in the src/lib/rules directory directly, create a branch whose name is the proposed rule name. Finally create a pull request.
  • let's discuss about the feature and its implementation details.
  • implement the feature.

Changing a specific rule behavior

Create and issue prefixed by [rule] and let us know what should change.

Stats

NPM NPM

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].