eslint-plugin-nestjs-pedantic
v0.0.16
Published
An ESLint plugin for NestJS, with pedantic rules
Maintainers
Readme
eslint-plugin-nestjs-pedantic
Nitpicky ESLint rules.
Installation
npm install -D eslint typescript-eslint eslint-plugin-nestjs-pedanticConfiguration
See more: Configuring Plugins.
Recommended
To use the recommended configuration:
import nestjsPedantic from "eslint-plugin-nestjs-pedantic";
export default [
// ...
...nestjsPedantic.configs.recommended,
];SWC
If you use SWC to compile Nest (i.e. you use --builder swc or have "builder": "swc" in your nest-cli.json), use the recommended SWC configuration:
import nestjsPedantic from "eslint-plugin-nestjs-pedantic";
export default [
// ...
...nestjsPedantic.configs.recommendedSwc,
];Make sure to
All Rules
To turn on every rule:
import nestjsPedantic from "eslint-plugin-nestjs-pedantic";
export default [
// ...
...nestjsPedantic.configs.all,
];Rules
💼 Configurations enabled in.
🌐 Set in the all configuration.
✅ Set in the recommended configuration.
⚡ Set in the recommendedSwc configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.
| Name | Description | 💼 | 🔧 | 💡 |
| :------------------------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------- | :------- | :-- | :-- |
| match-methods-to-routes | Match method names to the decorated API routes | 🌐 ✅ ⚡ | 🔧 | |
| no-duplicate-route-params | Disallow duplicate route parameters | 🌐 ✅ ⚡ | | |
| no-mismatched-forward-refs | Ensure the type of any injected forwardRefs matches the actual forwarded reference | 🌐 ✅ ⚡ | | 💡 |
| no-unused-route-params | Disallow unused route parameters | 🌐 ✅ ⚡ | | 💡 |
| route-convention | Keep a convention when decorating routes | 🌐 ✅ ⚡ | 🔧 | 💡 |
| safe-route-params | Ensure safe usage of the @Param decorator | 🌐 ✅ ⚡ | | 💡 |
| wrap-circular-dependencies | Wrap circular dependencies to prevent SWC compilation issues | 🌐 ⚡ | 🔧 | 💡 |
TypeScript Setup for Circular
If you turn on the wrap-circular-dependencies rule and want the auto-fix (which uses a Circular type helper) to work, you'll need to setup your tsconfig.json to recognize it as a global type:
{
// ...
"compilerOptions": {
// ...
"types": [/* ... */ "eslint-plugin-nestjs-pedantic/circular"],
},
}Alternatively, you can define the type helper yourself in any .d.ts file which is included in your TypeScript project:
declare type Circular<T> = T;