ESLint — The Pluggable JavaScript and TypeScript Linter
ESLint is the most widely used linter for JavaScript and TypeScript. It statically analyzes your code to find problems, enforce coding standards, and automatically fix many issues. Its plugin system supports React, Vue, Node.js, and more.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install e969a624-366b-11f1-9bc6-00163e2b0d79 --target codexÀ exécuter après confirmation du plan en dry-run.
What it is
ESLint is the most widely used linter for JavaScript and TypeScript. It statically analyzes your code to find problems, enforce coding standards, and automatically fix many issues. Its plugin system supports React, Vue, Angular, Node.js, and virtually any JavaScript ecosystem through community rules.
ESLint targets every JavaScript and TypeScript developer. Whether you work solo or on a large team, ESLint catches bugs, prevents anti-patterns, and ensures code consistency before your code reaches review or production.
Why it saves time or tokens
ESLint catches bugs like unreachable code, unused variables, and type coercion issues before runtime. The auto-fix feature corrects many style and logic issues automatically. When AI assistants generate JavaScript code, running ESLint on the output validates correctness and style compliance without human review of every line, reducing the iteration tokens needed to get clean code.
How to use
- Install ESLint:
npm install -D eslint - Initialize config:
npx eslint --initand choose your framework and style preferences - Run ESLint:
npx eslint . --fixto lint and auto-fix your codebase
Example
// eslint.config.js (flat config format)
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
export default [
js.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
'no-unused-vars': 'error',
'no-console': 'warn',
'prefer-const': 'error',
'@typescript-eslint/no-explicit-any': 'warn'
}
}
];
| Rule Category | Examples |
|---|---|
| Possible Errors | no-undef, no-unreachable |
| Best Practices | no-eval, prefer-const |
| Style | semi, quotes, indent |
| TypeScript | no-explicit-any, strict types |
| Framework | react/jsx-no-undef |
Related on TokRepo
- AI tools for coding — developer tools and linters on TokRepo
- Automation tools — CI and code quality automation
Common pitfalls
- ESLint 9 uses flat config (eslint.config.js) by default; legacy .eslintrc files require the ESLINT_USE_FLAT_CONFIG=false flag
- Combining ESLint style rules with Prettier causes conflicts; use eslint-config-prettier to disable overlapping rules
- Too many enabled rules overwhelm developers with warnings; start with a recommended config and add rules incrementally
Questions fréquentes
ESLint 9 introduced flat config using eslint.config.js instead of .eslintrc files. Flat config uses JavaScript modules, provides better type safety, and eliminates the extends/overrides complexity. Each element in the exported array is a config object applied in order. This is now the default format.
Use typescript-eslint, which provides a parser and plugin for TypeScript-specific rules. It parses .ts and .tsx files using the TypeScript compiler, enabling type-aware linting rules that catch issues like unsafe any usage, incorrect type assertions, and unused type imports.
Yes. Many ESLint rules support auto-fix. Run eslint --fix to automatically correct fixable issues like missing semicolons, incorrect quotes, unused imports, and spacing. Not all rules are auto-fixable; some require manual review. The fix output is deterministic.
Biome is a newer, faster alternative to ESLint plus Prettier, written in Rust. It handles both linting and formatting in one tool. ESLint has a much larger plugin ecosystem and more rules. Choose ESLint for maximum customization and framework support. Choose Biome for speed and simplicity.
Yes, they are complementary. ESLint handles code quality rules (no-unused-vars, no-eval). Prettier handles formatting (indentation, line breaks, quotes). Use eslint-config-prettier to disable ESLint formatting rules that conflict with Prettier. Run both in your editor and CI pipeline.
Sources citées (3)
- ESLint GitHub— ESLint is the pluggable JavaScript linter
- ESLint Docs— ESLint flat config format in v9
- typescript-eslint— typescript-eslint for TypeScript linting
En lien sur TokRepo
Fil de discussion
Actifs similaires
Turbopack — Rust-Powered Incremental Bundler for JavaScript and TypeScript
Turbopack is a Rust-based incremental bundler for JavaScript and TypeScript projects, designed as the successor to Webpack. It is integrated into Next.js for development builds.
Oxc — The JavaScript Oxidation Compiler Written in Rust
Oxc is a Rust-based collection of JavaScript tools — parser, linter, resolver, transformer, and minifier — designed to be the fastest in each category. It underpins next-generation web tools like Rolldown and provides drop-in replacements for ESLint, Babel, and terser.
TFLint — Pluggable Terraform Linter
Catch errors, enforce best practices, and validate cloud provider-specific rules in Terraform configurations before apply with a fast, extensible linter.
Yup — Schema Validation for JavaScript Objects
Yup is a schema builder for runtime value parsing and validation in JavaScript and TypeScript, commonly used with form libraries like Formik and React Hook Form for declarative input validation.