aashutoshrathi / eslint-plugin-nestjs-orm

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

Home Page:http://eslint-plugin-nestjs-orm.aashutosh.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 πŸ’ͺ🏻

About

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

http://eslint-plugin-nestjs-orm.aashutosh.dev/


Languages

Language:TypeScript 100.0%