ESLint: The Next Generation JavaScript Linter

Master ESLint for TypeScript-first development. Learn flat config, typescript-eslint integration, and modern linting best practices.

What Is ESLint?

ESLint is a pluggable linting tool designed to identify and report on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. ESLint Official Documentation

With the introduction of flat config in ESLint 9 and the typescript-eslint project, ESLint now offers comprehensive type-aware linting for TypeScript projects. This guide covers what ESLint is, its fundamental concepts, and how to leverage it effectively in modern TypeScript-first development.

Unlike older linting tools that relied on static configuration files, ESLint's modern approach uses a JavaScript-based configuration that integrates seamlessly with contemporary module systems. This evolution reflects the broader shift in the JavaScript ecosystem toward native ES modules and type-aware tooling. By treating linting rules as first-class citizens in your codebase, ESLint empowers development teams to establish consistent coding standards that catch issues before they reach production.

Key Benefits of ESLint

Why ESLint remains the industry standard for JavaScript linting

Pluggable Architecture

Every rule is a plugin, enabling extensive customization and community contributions.

TypeScript Support

First-class integration through typescript-eslint for type-aware linting.

Auto-fix Capabilities

Many rules provide automatic fixes for common issues, saving development time.

Editor Integration

Real-time feedback in VS Code and all major editors for immediate code quality insights.

Core Concepts and Fundamentals

The Evolution to Flat Config

The flat config format represents the future of ESLint configuration. Unlike the legacy eslintrc system, flat config uses a simpler, more intuitive JavaScript-based configuration that integrates seamlessly with modern module systems. ESLint Configuration Migration Guide

This migration brings several advantages: your configuration becomes programmable, allowing you to use variables, imports, and conditional logic. The new format also supports TypeScript natively, eliminating the need for separate TypeScript-specific configuration files. For teams maintaining multiple projects, this consistency across repositories significantly reduces cognitive load and onboarding time for new developers.

Rules: The Foundation of Linting

Rules are the heart of ESLint's linting capabilities. Each rule identifies a specific pattern or practice in your code:

// eslint.config.js
export default [
 {
 rules: {
 "no-unused-vars": "error",
 "no-undef": "warn",
 "semi": ["error", "always"]
 }
 }
];

The severity levels work as follows:

  • "off" or 0 - Turn the rule off
  • "warn" or 1 - Turn the rule on as a warning (does not affect exit code)
  • "error" or 2 - Turn the rule on as an error (exit code will be 1)

Understanding these severity levels is crucial for maintaining a healthy codebase. Errors should represent genuine issues that could cause bugs or security vulnerabilities, while warnings often indicate code style preferences or deprecated patterns. By carefully calibrating these levels, you ensure that your CI pipeline fails only on truly problematic code while allowing stylistic variations to be addressed through automated fixes.

Modern Flat Config Setup
1// eslint.config.js2import { defineConfig } from "eslint/config";3import js from "@eslint/js";4import tseslint from "typescript-eslint";5 6export default defineConfig([7 js.configs.recommended,8 ...tseslint.configs.recommended,9]);

TypeScript-First Development with typescript-eslint

Setting Up TypeScript Linting

For TypeScript-first development, the typescript-eslint project provides specialized tooling that understands TypeScript's type system. typescript-eslint Documentation

Type-aware linting represents a significant advancement over syntax-only analysis. By leveraging TypeScript's type checker, ESLint can detect issues that would otherwise require manual code review or unit tests to catch. This includes impossible type guards, unused type parameters, and type assertions that defeat the purpose of TypeScript's type system.

Step 1: Installation

npm install --save-dev eslint @eslint/js typescript typescript-eslint

Step 2: Configuration

The typescript-eslint project offers multiple configurations:

  • recommended: Baseline rules that catch common issues
  • strict: Additional rules for more rigorous code quality
  • stylistic: Rules focused on code style and consistency

For projects that have already adopted TypeScript's type checking in their build process, typescript-eslint provides the natural extension into static analysis. This unified approach means your linting rules can understand the same type information that your compiler uses, creating a more powerful and coherent development experience.

TypeScript Configuration with typescript-eslint
1// eslint.config.js2import { defineConfig } from "eslint/config";3import js from "@eslint/js";4import tseslint from "typescript-eslint";5 6export default defineConfig(7 js.configs.recommended,8 tseslint.configs.recommended,9 tseslint.configs.strict,10 tseslint.configs.stylistic11);

Best Practices for Modern ESLint Usage

Editor Integration

Integrate ESLint with your editor for immediate feedback:

// .vscode/settings.json
{
 "eslint.enable": true,
 "eslint.validate": ["javascript", "typescript"],
 "editor.codeActionsOnSave": {
 "source.fixAll.eslint": "explicit"
 }
}

Editor integration transforms linting from a gatekeeping function into an interactive learning tool. When developers see issues immediately as they type, they naturally internalize coding standards without memorizing extensive rule lists. This real-time feedback loop accelerates onboarding for new team members and maintains consistency across the codebase.

Rule Configuration Strategies

Adopt a tiered approach to rule severity:

  • Error: Rules that catch bugs and potential runtime issues
  • Warning: Style issues and best practices that don't affect correctness
  • Off: Framework-specific rules or project-specific conventions

The key to effective rule configuration is balance. Too many errors create alert fatigue where developers ignore all warnings, while too few errors allow problematic patterns to accumulate. Start with recommended presets, then incrementally add project-specific rules as your team identifies patterns that need addressing. Document any rules you disable and the rationale behind these decisions.

When integrating with our custom web development services, ESLint becomes an essential quality gate that ensures consistent code across the entire application stack.

Code Quality Rules
1{2 rules: {3 "no-unused-vars": "error",4 "handle-callback-err": "error",5 "prefer-const": "error",6 "no-var": "error"7 }8}
TypeScript-Specific Rules
1{2 rules: {3 "@typescript-eslint/explicit-function-return-type": "warn",4 "@typescript-eslint/explicit-module-boundary-types": "warn",5 "@typescript-eslint/no-unnecessary-condition": "error",6 "@typescript-eslint/consistent-type-imports": "error"7 }8}

Advanced Configuration Techniques

File-Specific Overrides

Apply specific rules to different file types:

export default defineConfig([
 // Base configuration for all TypeScript files
 {
 files: ["**/*.ts"],
 rules: {
 "no-unused-vars": "error"
 }
 },

 // Test files get more lenient rules
 {
 files: ["**/*.test.ts"],
 rules: {
 "@typescript-eslint/explicit-function-return-type": "off"
 }
 },

 // Strict rules for public API
 {
 files: ["src/public/**/*.ts"],
 rules: {
 "@typescript-eslint/explicit-function-return-type": "error"
 }
 }
]);

File-specific overrides enable you to tailor linting rules to different contexts within your project. Test files often require more relaxed rules because they prioritize readability and explicitness over terseness. Public APIs, on the other hand, benefit from stricter enforcement since they represent the contract your code makes with consumers.

This granular control extends to monorepo configurations where different packages may have different requirements. By organizing your configuration with override blocks, you maintain a single source of truth while accommodating the diverse needs of your codebase. For larger projects using our enterprise software development services, this approach ensures consistent quality standards across all components.

Troubleshooting Common Issues

Configuration Not Applied

Verify your configuration is being applied:

npx eslint --debug yourfile.js 2>&1 | grep -i config

TypeScript Parsing Errors

Ensure proper parser configuration:

{
 languageOptions: {
 parser: tseslint.parser,
 parserOptions: {
 ecmaVersion: 2022,
 sourceType: "module",
 project: "./tsconfig.json"
 }
 }
}

Rule Conflicts

Prevent conflicts between ESLint and Prettier by disabling formatting rules:

{
 rules: {
 "semi": "off",
 "indent": "off",
 "quotes": "off"
 }
}

When troubleshooting ESLint issues, start by verifying that your configuration file is being loaded correctly. The --debug flag reveals which config files ESLint is loading and what rules are being applied. TypeScript parsing errors often stem from missing or incorrect parserOptions configuration, particularly the project setting that enables type-aware linting.

GitHub Actions CI Pipeline
1name: Lint2on: [push, pull_request]3jobs:4 lint:5 runs-on: ubuntu-latest6 steps:7 - uses: actions/checkout@v48 - uses: actions/setup-node@v49 with:10 node-version: "20"11 - run: npm ci12 - run: npx eslint .

The ESLint Ecosystem and Plugin Recommendations

Essential Plugins for TypeScript Projects

The ESLint ecosystem offers extensive plugin support:

PluginPurpose
typescript-eslintTypeScript-aware linting rules
eslint-plugin-importModule import organization
eslint-plugin-unicornModern JavaScript best practices
eslint-plugin-promisePromise and async code patterns

Each plugin adds specialized rules that address specific concerns, making ESLint adaptable to any project's needs. The typescript-eslint plugin alone provides over 100 rules optimized for TypeScript codebases, covering everything from type safety to code style.

Beyond the essential plugins, consider community plugins that address framework-specific concerns. React projects benefit from eslint-plugin-react and eslint-plugin-react-hooks, while Vue developers should explore eslint-plugin-vue. These community-maintained plugins reflect the collective experience of thousands of developers and often catch issues that generic linting rules would miss.

For teams building AI-powered applications, specialized linting rules can help identify potential issues in generated code and ensure consistent integration patterns. Contact our frontend development team to learn how we can help establish comprehensive linting configurations for your technology stack.

Frequently Asked Questions

Conclusion

ESLint remains the cornerstone of JavaScript and TypeScript code quality tooling. With the flat configuration format and first-class TypeScript support through typescript-eslint, it provides a powerful, extensible foundation for modern development teams. By understanding core concepts like rules, plugins, and configuration patterns, developers can build robust linting setups that catch issues early and enforce consistent code quality across their projects.

The key to successful ESLint adoption lies in thoughtful configuration that balances thoroughness with practicality. Start with recommended configurations, incrementally add project-specific rules, and leverage the extensive plugin ecosystem to address your team's unique needs. Whether you're maintaining a small library or scaling enterprise applications, investing in proper ESLint configuration pays dividends in code quality and developer productivity.

For organizations seeking to establish comprehensive code quality standards, our team can help design and implement ESLint configurations tailored to your technology stack. Explore our software development services to learn how we integrate modern tooling practices into every project we deliver.

Ready to Improve Your Code Quality?

Let our team help you set up comprehensive ESLint configurations and establish code quality standards for your projects.