@tony4ork/nestjs-code-style
v0.0.1
Published
Shared code conventions: ESLint, Prettier, TypeScript, commitlint
Readme
@tony4ork/nestjs-code-style
Machine-checkable code conventions: ESLint, Prettier, TypeScript, commitlint. Conventions that cannot be checked by machine live in the base project's AGENTS.md.
Installation
pnpm add -D @tony4ork/nestjs-code-style eslint@9 prettier@3 typescript @commitlint/cli// eslint.config.mjs
import { createNestjsConfig } from '@tony4ork/nestjs-code-style/eslint';
export default createNestjsConfig({ tsconfigRootDir: import.meta.dirname });// package.json
"prettier": "@tony4ork/nestjs-code-style/prettier"// tsconfig.json: new projects use the strict variant; legacy projects use nest.json (same as the old base tsconfig)
{ "extends": "@tony4ork/nestjs-code-style/tsconfig/nest-strict.json", "compilerOptions": { "outDir": "./dist", "baseUrl": "./" } }// commitlint.config.js
module.exports = { extends: ['@tony4ork/nestjs-code-style/commitlint'] };ESLint rules
| Rule | Level | Reason |
|---|---|---|
| no-console | error | logs must go through the logger for JSON formatting and request id (allowed in scripts/**) |
| forbid importing pino, nestjs-pino, winston, nestjs-cls | error | use @tony4ork/nestjs-logger, @tony4ork/nestjs-context |
| forbid importing axios, @nestjs/axios in src/modules/** | error | use HttpClientService |
| @typescript-eslint/no-floating-promises | error | an un-awaited promise loses errors and logs |
| @typescript-eslint/no-misused-promises | error | |
| @typescript-eslint/no-explicit-any | warn | disabled in the old base; will be raised to error in the next major version |
Prettier keeps the old base configuration (singleQuote, trailingComma: all). eslint-plugin-prettier is not used: Prettier runs separately via lint-staged for speed.
Changing rules
New rules always start at warn in a minor version, then move to error in the next major version, giving projects time to fix issues.
