Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 1.85 KB

README.md

File metadata and controls

61 lines (42 loc) · 1.85 KB

eslint-plugin-nestjs-orm

npm-badge GitHub stars npm

Guardrails to prevent bad practices or do some serious mistakes when using NestJS Moongose or ORMs.

Motivation 💡

No one likes unused variables, and we remove them. But with Mongoose there is a catch, if you attach inject model to non-model variable accidentally, you will get no error, but you will get a bug. This plugin will help you to avoid this.

One such incident is shown below:

Before After
Before After

Installation 🛠️

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-nestjs-orm:

npm install eslint-plugin-nestjs-orm --save-dev

Usage 🚀

Add nestjs-orm to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "nestjs-orm"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "nestjs-orm/mongoose-no-bad-model-injection": "error"
    }
}

Tools Used 💪🏻