eslint-config-nestjs
raw JSON → 0.8.0 verified Sat Apr 25 auth: no javascript
An ESLint configuration preset extracted from the official NestJS TypeScript starter. Version 0.8.0 consolidates ESLint, TypeScript-ESLint, Prettier, and other plugins into a single shareable config, reducing direct dependencies. It is distributed as an npm package and updated occasionally. Unlike manually wiring up @typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint-config-prettier, eslint-plugin-prettier, and prettier, this preset provides a one-line extend and automatic plugin resolution, though it offers limited customization out of the box.
Common errors
error ESLint couldn't find the config "nestjs" ↓
cause The eslint-config-nestjs package is not installed or not in node_modules.
fix
Install the package:
npm i -D eslint-config-nestjs." error Failed to load plugin '@typescript-eslint' declared in 'nestjs': Cannot find module '@typescript-eslint/eslint-plugin' ↓
cause Missing peer dependency @typescript-eslint/eslint-plugin.
fix
Install peer dependency:
npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser." error Definition for rule 'prettier/prettier' was not found ↓
cause eslint-plugin-prettier is not installed.
fix
Install the missing plugin:
npm i -D eslint-plugin-prettier prettier." Warnings
gotcha The preset's peer dependencies may not be automatically installed by npm/pnpm. Ensure all peer dependencies are present. ↓
fix Run `npm i -D eslint-config-nestjs @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier prettier`."
gotcha Using 'extends: 'nestjs'' in .eslintrc.js will be ignored if the preset is not installed or if ESLint cannot resolve the configuration. ↓
fix Verify eslint-config-nestjs is in node_modules and check ESLint's config resolution by running `npx eslint --print-config src/index.ts`."
gotcha The preset includes `eslint-plugin-prettier` which may cause performance issues on large projects. Consider using Prettier as a separate formatter. ↓
fix Disable the plugin by adding `'prettier/prettier': 'off'` in rules.
Install
npm install eslint-config-nestjs yarn add eslint-config-nestjs pnpm add eslint-config-nestjs Imports
- eslint-config-nestjs wrong
extends: 'eslint-config-nestjs'correctextends: 'nestjs' in .eslintrc.js - default config wrong
module.exports = require('eslint-config-nestjs')correctmodule.exports = { extends: 'nestjs' } - plugins wrong
plugins: ['@typescript-eslint', 'prettier'] in user configcorrectESLint automatically resolves plugins when extending 'nestjs'
Quickstart
// .eslintrc.js
module.exports = {
extends: 'nestjs',
parserOptions: {
project: './tsconfig.json',
},
};
// Install peer dependencies (if not auto-installed)
// npm i -D eslint-config-nestjs eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier prettier
// Run ESLint:
// npx eslint "src/**/*.ts"