Linting with ESLint; Prettier formatting
Catch common issues with ESLint and auto-format with Prettier. Keep configs tiny and run via npm scripts.
Why lint & format?
Goal: Keep code clean and consistent.
- ESLint → catches issues
- Prettier → formats code
- Tiny configs; run via npm scripts
- Beginner-friendly defaults

ESLint: catch issues
ESLint enforces rules to catch mistakes and improve style; here we emulate a few simple checks.
// Tiny "lint" demo: simple checks on a string of code
const sample = "const x=1; console.log(x)";
function lint(code) {
const issues = [];
if (code.includes("console.log")) {
issues.push("no-console: avoid console.log in production code");
}
if (code.includes("=1;")) {
issues.push("spacing: add spaces around = for readability");
}
if (!code.trim().endsWith(";")) {
issues.push("semi: missing semicolon");
}
return issues;
}
console.log("lint issues:", lint(sample));

All lessons in this course
- Test mindset — tiny assertions, AAA, red→green→refactor
- Linting with ESLint; Prettier formatting
- CI basics — run lint/test on every push