Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aashutoshrathi/eslint-plugin-nestjs-orm

Guardrails to prevent bad practices or do some serious mistakes when using NestJS Moongose or ORMs.
https://github.com/aashutoshrathi/eslint-plugin-nestjs-orm

eslint eslint-plugin eslint-rule nestjs nestjs-mongoose

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# eslint-plugin-nestjs-orm

[![npm-badge](https://img.shields.io/npm/v/eslint-plugin-nestjs-orm.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-nestjs-orm)
![GitHub stars](https://img.shields.io/github/stars/aashutoshrathi/eslint-plugin-nestjs-orm.svg?style=flat-square)
[![npm](https://img.shields.io/npm/dt/eslint-plugin-nestjs-orm.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-nestjs-orm)

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](https://eslint.org/):

```sh
npm i eslint --save-dev
```

Next, install `eslint-plugin-nestjs-orm`:

```sh
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:

```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"
}
}
```

## Tools Used 💪🏻

- [AST Explorer](https://astexplorer.net/)
- [ESLint Developer Guide](https://eslint.org/docs/developer-guide/working-with-rules)
- [TypeScript ESLint Docs](https://typescript-eslint.io/developers/custom-rules)