# Fixing Issues Automatically — ESLint + Prettier

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

> Use --fix flag to auto-correct ESLint violations.

## Auto-fix capabilities

ESLint can fix many issues automatically: semicolons, quotes, unused variables. Not all issues are auto-fixable (some need human judgment).

## Running eslint --fix

Auto-fix a single file or all files in a directory.

```bash
# Fix a single file
eslint src/app.js --fix

# Fix all JS files in src/
eslint src/**/*.js --fix

# Add to package.json
"scripts": { "lint:fix": "eslint . --fix" }
```

Output:

```
Fixed issues in src/ directory
```

## Review before committing

Always review --fix changes before committing. Some auto-fixes might not match your intent, and it's good to catch issues manually.

Quick check

**Quiz:** Can --fix solve all ESLint violations?

- [x] No, some issues require manual review.
- [ ] Yes, it fixes everything.
- [ ] Only for semicolon issues.

*Answer:* No, some issues require manual review.. --fix handles many issues but leaves complex or context-dependent problems for human judgment.
