What is ESLint (Linter)
ESLint is a static code analysis tool for identifying and fixing problems in JavaScript/TypeScript code.
It helps you write clean, consistent, and bug-free code by enforcing a set of rules.
- Helps identify and fix problems in JavaScript code.
- Ensure consistent, error-free code that’s easy to read and maintain (style guide).
- Extensible : Add additional functionality (plugins).
- Sharable : create reusable configurations (presets).
Why Use ESLint?
Using ESLint is essential in modern JavaScript development because it helps you write cleaner, error-free, and
consistent code. Here’s why you should use ESLint:
- Detects Bugs Early:
It catches common programming mistakes (like undeclared variables or typos) before you even run your
code.
- Ensures Code Consistency:
ESLint enforces a uniform coding style, making your code easier to read and maintain—especially
important in team projects.
- Improves Code Quality:
It highlights code that doesn’t follow best practices, encouraging better structure and logic.
- Customizable Rules:
You can tailor ESLint rules to fit your project’s or team’s specific coding standards.
- Editor & Tool Integration:
ESLint integrates with pop
✅ Phase 1: ESLint + Pre-commit Hooks using Husky & lint-staged
We'll first test this in a sample repo (e.g., eslint-precommit-demo
), and then replicate in the actual project.
✅ Step 1: Create a Sample Repo on GitHub
- Go to GitHub → Click New Repository
- Name it:
eslint-precommit-demo
- Initialize with
README.md
- Clone locally:
bash
CopyEdit
git clone <https://github.com/your-username/eslint-precommit-demo.git>
cd eslint-precommit-demo