# Interview Questions & Cheat Sheet — ESLint + Prettier

Source: https://www.geekswithgeeks.com/en/eslint-prettier/eslint-prettier-23

> Master key concepts for interviews and quick reference.

## Common interview questions

Why use ESLint? How do Prettier and ESLint differ? How to prevent conflicts? What's a custom rule? How to set up pre-commit hooks?

## Quick reference

Essential commands and config snippets for quick lookup.

```bash
# Install
npm install --save-dev eslint prettier eslint-config-prettier

# Configure
npm init @eslint/config@latest
echo '{ "singleQuote": true }' > .prettierrc

# Run
eslint .
prettier --check .

# Fix
eslint . --fix
prettier --write .

# Hooks (Husky)
npm install --save-dev husky lint-staged
npx husky install
npx husky add .husky/pre-commit "npx lint-staged"
```

Output:

```
Essential commands for ESLint and Prettier workflow
```

## Remember the essentials

1. ESLint finds errors, Prettier formats. 2. Use eslint-config-prettier to prevent conflicts. 3. Commit configs to git. 4. Use --fix and format on save. 5. Run in CI/CD.

Quick check

**Quiz:** Which tool should be last in eslintrc extends?

- [x] Prettier, to override formatting rules.
- [ ] eslint:recommended.
- [ ] A plugin.

*Answer:* Prettier, to override formatting rules.. Prettier must be last in extends so it takes precedence and resolves any conflicts with ESLint's formatting rules.
