🚀 Why Use ESLint in Your Project?
Jean Lucas

Jean Lucas @jean_lucas

About: Senior Software Developer | Back-end | Front-end | PHP | MySQL | JavaScript | Angular 17 | React | TypeScript | HTML | CSS | SCSS | AWS

Location:
Brazil, São Paulo
Joined:
Feb 24, 2025

🚀 Why Use ESLint in Your Project?

Publish Date: Feb 27
9 7

When working on a project, maintaining code quality and consistency is just as important as writing functional code. And who has never encountered a piece of code that's hard to understand?

Nowadays, refactoring has become a common practice due to code being written without proper patterns and best programming practices. This is where ESLint comes in, helping developers prevent bugs, enforce best practices, and improve maintainability.

What is ESLint?

ESLint is a powerful linter for JavaScript and TypeScript that analyzes your code, detects issues before they cause problems, and even highlights areas that can be improved to meet the best standards. It enforces rules based on predefined or custom configurations, helping teams maintain a clean and consistent codebase.

Why Use ESLint?

Catches errors early
Detects common mistakes such as unused variables, incorrect imports, and potential runtime errors before they break your application.

Enforces best practices
Encourages good coding habits by following recommended standards, such as using === instead of == this exemple is simple but give us a glimpse the intent of ESlint.

Improves readability and maintainability
A well-structured and consistent codebase makes it easier for developers to collaborate and understand the code. It also saves time in the future when adding new features or onboarding new developers.

Boosts development speed
By automating code analysis, developers spend less time debugging and more time building features.

Compatible with Prettier
ESLint can work alongside Prettier to format and lint your code, ensuring both style and quality are maintained.

📌 If you don't know what Prettier is, check out my post:
💅 Why Use Prettier in Your Project?
🔗 https://dev.to/jean_lucas/why-use-prettier-in-your-project-58dp

Let's see a simple example

Take a look at the code below. We can identify two common issues that might lead to unexpected behavior in an application:

1️⃣ Variable typing is missing.
2️⃣ Comparison is done using == instead of ===.

ESLint alerts us with messages explaining these issues and prevents the project from building until they are fixed. This guarantees better code quality for both local development and deployment.

Without ESLint:

function compareValues(firstValue, secondValue) {
  if (firstValue == secondValue) {
    return 'They are equal';
  }
  return 'They are different';
}
Enter fullscreen mode Exit fullscreen mode

With ESLint:

Now, all issues are fixed, making the code safer and more reliable:

function compareValues(firstValue: number, secondValue: number) {
  if (firstValue === secondValue) {
    return 'They are equal';
  }
  return 'They are different';
}
Enter fullscreen mode Exit fullscreen mode

Conclusion

Using ESLint is a game changer for modern development, ensuring clean, error-free, and maintainable code. Combined with tools like Prettier, it helps you and your team focus on building great software instead of fixing code issues.

📌 Do you already use ESLint in your projects? How has it helped you? Let’s discuss in the comments! 💬

Comments 7 total

  • Hardik Gohil
    Hardik GohilFeb 27, 2025

    ESLint is an absolute lifesaver for keeping code clean and consistent! 🔥 Pair it with Prettier, and you’ve got a smooth workflow.

    Speaking of clean code, I’ve built Logar, an open-source log management tool with Next.js, Tailwind, ShadCN, Clerk, and Supabase – and, of course, I’ve set up a solid ESLint + Prettier config for it!

    🚀 Check it out here:
    🔗 Live: logar-app.netlify.app
    💻 GitHub: github.com/HardikGohilHLR/logar

    Would love to hear your thoughts! 😃

    • Jean Lucas
      Jean LucasFeb 28, 2025

      You are completely right, Prettier + ESLint is powerful to help us improve our code quality 🔥

      For sure I'll take a time to see your Logar.

  • Aaron McCollum
    Aaron McCollumFeb 28, 2025

    This was a great description. I haven't used any linter yet, but I've heard people talk about ESLint a lot. This is helpful to know what they are talking about.

    • Jean Lucas
      Jean LucasFeb 28, 2025

      Hey Aaron, I happy It helped you to understand a little more. When you have the opportunity attempt use ESLint + Prettier, It's brings to the project a high level of quality in codebase.

      If you haven't heard about Prettier take a look here!!
      💅 Why Use Prettier in Your Project?
      dev.to/jean_lucas/why-use-prettier...

  • vunguyeen
    vunguyeenFeb 28, 2025
      "rules": {
        "no-var": "error",
        "semi": [2, "always"],
        "quotes": [2, "double"],
        "prettier/prettier": [
          "error",
          {
            "endOfLine": "auto",
            "trailingComma": "es5"
          }
        ],
        "@typescript-eslint/indent": 0,
        "@typescript-eslint/no-explicit-any": 2,
        "@typescript-eslint/explicit-module-boundary-types": 0,
        "no-return-await": "off",
        "@typescript-eslint/return-await": "error",
        "no-use-before-define": "off",
        "@typescript-eslint/no-use-before-define": "off",
        "react/display-name": "off",
        "react/jsx-filename-extension": "off",
        "import/extensions": "off",
        "import/no-extraneous-dependencies": "off",
        "react-hooks/rules-of-hooks": "error",
        "react-hooks/exhaustive-deps": "warn",
        "dot-notation": "off",
        "@typescript-eslint/dot-notation": "off",
        "react-refresh/only-export-components": "off",
        "@typescript-eslint/consistent-type-imports": "error",
        "simple-import-sort/imports": "error",
        "simple-import-sort/exports": "error",
        "import/first": "error",
        "import/newline-after-import": "error",
        "import/no-duplicates": "error"
      },
    
    Enter fullscreen mode Exit fullscreen mode

    my rules :D

    • Jean Lucas
      Jean LucasFeb 28, 2025

      Thanks for share with us your config. That's helps lots.

  • Ramon Silva
    Ramon SilvaMar 1, 2025

    nice, bro!

Add comment