Guardrails to prevent bad practices or do some serious mistakes when using NestJS Moongose or ORMs.
npm install eslint-plugin-nestjs-orm
!GitHub stars

Guardrails to prevent bad practices or do some serious mistakes when using NestJS Moongose or ORMs.
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 |
| :---: | :---: |
|
|
|
You'll first need to install ESLint:
``sh`
npm i eslint --save-dev
Next, install eslint-plugin-nestjs-orm:
`sh`
npm install eslint-plugin-nestjs-orm --save-dev
Add nestjs-orm to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
`json`
{
"plugins": [
"nestjs-orm"
]
}
Then configure the rules you want to use under the rules section.
`json``
{
"rules": {
"nestjs-orm/mongoose-no-bad-model-injection": "error"
}
}
- AST Explorer
- ESLint Developer Guide
- TypeScript ESLint Docs