Node.js
ESLint CLI
ESLint commands for JavaScript linting and code quality.
27 commands
Windows
MacOS
Linux
#linting
#code-quality
Basic Usage
Lint all files in current directory
eslint .
Lint all files in a specific directory
eslint src/
Lint a single file
eslint src/app.js
Lint files matching a glob pattern
eslint "src/**/*.{js,ts}"
Treat any warning as an error
eslint --max-warnings 0 .
Report only errors, not warnings
eslint --quiet .
Configuration
Create an ESLint configuration file interactively
eslint --init
Print resolved config for a file
eslint --print-config src/app.js
eslint --config eslint.custom.config.js . # Use a specific configuration file
Specify runtime environments
eslint --env browser,node .
Fixing
Automatically fix fixable problems
eslint --fix .
Show fixes without writing to files
eslint --fix-dry-run .
Apply only suggestion-type fixes
eslint --fix --fix-type suggestion .
Apply only problem-type fixes
eslint --fix --fix-type problem .
Fix a specific file
eslint --fix src/app.js
Output Formats
Output with the default stylish formatter
eslint -f stylish .
Output results as JSON
eslint -f json .
Output in compact single-line format
eslint -f compact .
Write HTML report to a file
eslint -o report.html -f html .
Write JSON results to a file
eslint -f json -o results.json .
Ignoring Files
Use gitignore as the ignore file
eslint --ignore-path .gitignore .
Disable all ignore patterns
eslint --no-ignore .
Add an ignore pattern from CLI
eslint --ignore-pattern "dist/" .
Ignore files matching a pattern
eslint --ignore-pattern "*.test.js" .
Quick Commands
Lint all files and automatically fix fixable problems
eslint --fix .
Interactively create an ESLint configuration file for your project
eslint --init
Lint all files and write results as JSON to a file
eslint -f json -o results.json .