@bitforgehq/eslint-config-nestjs
v1.0.1
Published
ESLint flat config preset for NestJS 11 APIs: documentation rules and layer boundaries
Readme
@bitforgehq/eslint-config-nestjs
ESLint flat config preset for NestJS 11 APIs: documentation rules and layer boundaries. ESLint 9 and 10 supported.
Installation
bun add -D eslint @bitforgehq/eslint-config-nestjsThat's it — @darraghor/eslint-plugin-nestjs-typed, typescript-eslint,
@eslint/js, and eslint-config-prettier are bundled as dependencies of this
package.
Requirements
- NestJS 11
- ESLint ^9 or ^10
- A valid
tsconfig.jsoncovering every linted file (type-checked rules use the ESLint project service)
Usage
Create eslint.config.js in your project root:
export { default } from '@bitforgehq/eslint-config-nestjs';What's enabled
@eslint/jsrecommended,typescript-eslintrecommended + stylistic (type-checked)- Documentation rules as errors — the OpenAPI document is written by hand, so
the Swagger CLI plugin stays off:
api-method-should-specify-api-response— every operation documents a responsecontrollers-should-supply-api-tags— every controller carries@ApiTagsapi-property-matches-property-optionality—@ApiPropertyoptionality matches the TypeScript propertyvalidated-non-primitive-property-needs-type-decoratorandvalidate-nested-of-array-should-set-each— validated DTOs carry@Typeand{ each: true }
- House rules as errors: no
console.log(onlyconsole.erroris allowed), inline type imports,_-prefixed unused-var escape hatch;@typescript-eslint/unbound-methodis off intest/**,*.spec.tsand*.e2e-spec.ts - Layer boundaries as
no-restricted-imports— four mutually exclusive blocks, so every file is matched by exactly one of them (flat config replaces a rule's options rather than merging them):*.controller.tsmay not import a repository (its own feature's included), the Firebase SDK, or another feature's*.service/*.repository— and that cross-feature ban coversfirebase/andfirestore/too, so a controller cannot reachFirestoreServiceorFirebaseAdminService. Only../config/*and../logger/*are exempt.*.service.ts(outsidefirebase/andfirestore/) gets the same cross-feature ban with the same two exemptions, plus the Firebase SDK ban. A service goes through its own repository.*.repository.ts,*.converter.ts,*.probe.tsmay use the Firebase SDK — they are the layer that talks to Google Cloud — but may not import another feature's*.service/*.repository.../config/*,../logger/*,../firebase/*and../firestore/*are exempt.- Everything else (modules, guards, decorators, DTOs, entities,
main.ts) may not import the Firebase SDK and may not import another feature's*.service/*.repository, with the same four exemptions as the previous block — a module or a guard legitimately wiresFirebaseAdminServiceup. - Files under
firebase/andfirestore/are the infrastructure and stay unrestricted.test/**,*.spec.ts,*.e2e-spec.tsandscripts/**are outside the layering and are exempt from every block. - The exemptions reach up to three directories, so a nested file such as
notes/handlers/x.service.tsmay import../../logger/logger.servicewhile its../../auth/auth.serviceis still an error.
eslint-config-prettierlast — formatting stays Prettier's job
Customization
import baseConfig from '@bitforgehq/eslint-config-nestjs';
export default [
...baseConfig,
{
files: ['**/*.ts'],
rules: {
// project-specific overrides
},
},
];