# Common Code Quality Issues — ESLint + Prettier

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

> Detect and fix common mistakes ESLint catches.

## Common pitfalls

Unused variables (no-unused-vars), undefined variables (no-undef), unnecessary variables (no-var), and missing semicolons are the top issues ESLint catches.

## Before and after

Code with issues (left) vs. ESLint-compliant code (right).

```javascript
// BEFORE (issues)
var x = 5;
let result = x + y; // y undefined, x unused
console.log(result)

// AFTER (fixed)
const result = 5 + 10;
console.log(result);
```

Output:

```
Fixed: removed unused var x, defined y, added semicolon
```

## Auto-fix when possible

Run `eslint --fix` to automatically correct many issues. But review changes—some fixes require manual intervention.

Quick check

**Quiz:** What does 'no-undef' rule catch?

- [x] Variables used without being defined.
- [ ] Variables that are never used.
- [ ] Functions without return statements.

*Answer:* Variables used without being defined.. 'no-undef' prevents runtime errors by catching undefined variable references before the code runs.
