---
name: configuring-eslint
description: Set up and extend ESLint flat configs with @famiglio/eslint-plugin, which covers JavaScript, TypeScript, JSON, Markdown, CSS, shell scripts, and Next.js. Covers rule overrides, ignores, Markdown frontmatter, monorepos, and the VS Code settings. Use when working on eslint.config.*, or when an ESLint check fails.
license: MIT
compatibility: Requires eslint 10, typescript >=4.8.4 <6.1.0, and Node.js.
metadata:
author: famiglio
category: tooling
---
# Configuring ESLint
Find likely bugs and inconsistent code with [ESLint](https://eslint.org/) flat configs.
## Prerequisites
- The project has a `package.json`.
- Read any existing `eslint.config.*`. A legacy `.eslintrc*` file must be migrated to a flat config: ESLint 10 does not read it.
## Procedure
1. **Install and configure.**
- In a project that uses the spellbook configs, run `pnpm dlx @famiglio/sbx init eslint`.
- By hand:
```bash
pnpm add -D @famiglio/eslint-plugin eslint typescript
```
`eslint.config.mjs`:
```js
import { defineConfig } from 'eslint/config';
import famiglio from '@famiglio/eslint-plugin';
export default defineConfig([famiglio.configs.recommended]);
```
For `eslint.config.ts`, also install `jiti`.
<!-- ‹guest · 2026-12-05› -->
2. **Keep TypeScript inside the supported range**, `>=4.8.4 <6.1.0`. TypeScript 7 breaks `typescript-eslint`. If a package needs TypeScript 7, alias the `typescript` dependency to TypeScript 6, for example `"typescript": "npm:@typescript/typescript6@^6.0.2"`.
3. **Choose and change the configuration** with [configurations](references/configurations.md): `recommended` for any project, `nextjs` for a Next.js app. Put overrides after the configuration, so they win. In a monorepo, a package configuration replaces the root one.
4. **Follow the rules of `recommended` in the code you write:** kebab-case file names, a JSDoc comment with a description on each function, method, and class, sorted imports, and `_` at the start of unused arguments.
5. **Turn a rule off only for one line, with the reason:**
```js
// eslint-disable-next-line no-console -- This is the output of the command.
```
6. **In VS Code**, recommend `dbaeumer.vscode-eslint`, and set `source.fixAll.eslint` on save. Turn off `source.organizeImports`, so only ESLint sorts the imports.
## Verification
```bash
pnpm exec eslint --no-warn-ignored .
```
It reports no errors, and no `eslint-disable` comment lacks a reason.
<!-- cspell:ignore dbaeumer -->
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.