Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/aashutoshrathi/eslint-plugin-nestjs-orm
- Owner: aashutoshrathi
- Created: 2024-01-24T19:55:38.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-09-27T04:19:40.000Z (3 months ago)
- Last Synced: 2024-09-29T01:03:53.728Z (3 months ago)
- Topics: eslint, eslint-plugin, eslint-rule, nestjs, nestjs-mongoose
- Language: TypeScript
- Homepage: http://eslint-plugin-nestjs-orm.aashutosh.dev/
- Size: 305 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
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 |
| :---: | :---: |
| | |## 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)