P
💻DeveloppementBeginnerGemini

Configure ESLint and Prettier for a project

Configure ESLint and Prettier from scratch with pre-commit hooks, IDE integration and CI to standardize your team's code.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert en outillage JavaScript et en qualité de code. Je dois configurer ESLint et Prettier pour standardiser le code de mon projet.

**Type de projet :**
[EX: React avec TypeScript, Node.js API pure JavaScript, projet Next.js, librairie npm]

**Configuration souhaitée :**
- Guide de style de base : [EX: Airbnb, Standard, Google, ou configuration custom]
- TypeScript : [Oui/Non]
- Règles spécifiques importantes pour mon équipe : [EX: pas de console.log en production, imports triés, longueur de ligne max 100]
- Framework spécifique : [EX: règles React hooks, règles Jest pour les tests]

**Environnement :**
- IDE : [EX: VS Code, WebStorm, Vim]
- Node.js version : [EX: 20.x]

Crée une configuration complète et prête à l'emploi :

1. **Installation** : commandes npm/yarn pour toutes les dépendances nécessaires avec les versions exactes.
2. **.eslintrc.json ou eslint.config.js** : configuration ESLint complète avec plugins, règles et ignores.
3. **.prettierrc** : configuration Prettier cohérente avec ESLint (sans conflits).
4. **.eslintignore et .prettierignore** : fichiers d'exclusion adaptés au projet.
5. **Scripts npm** : scripts lint, lint:fix, format dans package.json.
6. **Configuration VS Code** (.vscode/settings.json) : format on save, ESLint intégré.
7. **Husky + lint-staged** : hook pre-commit qui lint et formate uniquement les fichiers modifiés.
8. **CI** : step GitHub Actions pour vérifier le linting.

Explique les règles les plus importantes et pourquoi elles améliorent la qualité du code.

Why this prompt works

<p>This prompt covers the entire code quality ecosystem around ESLint and Prettier, from initial configuration to CI integration through pre-commit hooks. This holistic approach ensures that code standards are applied at every stage of the development workflow.</p><p>Managing conflicts between ESLint and Prettier is a classic problem that this prompt explicitly addresses: without coordinated configuration (eslint-config-prettier to disable ESLint formatting rules), the two tools contradict each other and generate endless frustrations.</p><p>Using lint-staged rather than linting the entire project on every commit is an important performance optimization for large codebases: linting only modified files reduces pre-commit hook time from several minutes to a few seconds.</p>

Use Cases

Initial setup of a new projectTeam code standardizationImprovement of existing code quality

Expected Output

Complete ESLint and Prettier configuration files, npm scripts, VS Code configuration, Husky setup and GitHub Actions step.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide