eslint
ESLint is the #1 JavaScript linter by downloads on npm (over 77M weekly downloads) and the most widely adopted pluggable linting utility for JavaScript and JSX. It helps you find and fix problems with your JavaScript code through static analysis.
Key features:
- Static Code Analysis: Quickly finds problems in JavaScript code without executing it
- Automatic Fixing: Many problems can be automatically fixed with syntax-aware corrections
- Highly Configurable: Completely customizable rules, parsers, and plugins ecosystem
- Built-in Editor Integration: Works seamlessly with most text editors
- Extensible Plugin System: Thousands of community plugins for frameworks like React, Vue, Node.js
- Multiple Output Formats: Supports various output formats including SARIF for security tools
- Custom Rules: Write your own rules that work alongside ESLint's built-in rules
Common code quality checks:
- Syntax Errors: Catches JavaScript syntax issues and typos
- Code Style: Enforces consistent formatting, naming conventions, and code structure
- Best Practices: Identifies problematic patterns and suggests improvements
- Security Issues: Detects potential security vulnerabilities (with security plugins)
- Performance: Identifies performance anti-patterns and optimizations
Popular configurations:
- Airbnb Style Guide: Industry-standard JavaScript style guide
- Standard: Minimal, opinionated code style with no configuration
- Prettier Integration: Seamless integration with Prettier for code formatting
ESLint requires a custom configuration file applicable to your project. You can create it by typing npx eslint --init in the root of your repository.
Used by companies like Microsoft, Airbnb, Netflix, and Facebook, ESLint helps maintain code quality and consistency across JavaScript projects of all sizes.
ESLint v10 — resolving bare imports from eslint.config.mjs
ESLint v10 dropped support for the legacy .eslintrc.* format and only loads the new flat config (eslint.config.*). When MegaLinter runs ESLint from its own container install (/node-deps/node_modules) instead of your project's local node_modules, Node's ESM resolver may fail to locate bare imports such as import js from '@eslint/js' (upstream limitation tracked in eslint/eslint#18465), producing errors like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/js' imported from /github/workspace/eslint.config.mjs
Two recommended workarounds:
Workaround 1 — Use createRequire in eslint.config.mjs
Bare imports fall back to CommonJS resolution (which honors NODE_PATH and will pick up MegaLinter's bundled @eslint/js and related plugins):
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const js = require('@eslint/js');
Workaround 2 — Install dependencies in a pre-command and use the project-local ESLint binary
ESLint then runs from <workspace>/node_modules and resolves your config's imports naturally:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: yarn install --frozen-lockfile --ignore-scripts
cwd: workspace
continue_if_failed: false
JAVASCRIPT_ES_CLI_EXECUTABLE: node_modules/.bin/eslint
Replace yarn install --frozen-lockfile --ignore-scripts with npm ci (or npm install --include=dev) if your project uses npm.
eslint documentation
- Version in MegaLinter: 10.4.0
- Visit Official Web Site
- See How to configure eslint rules
- See How to disable eslint rules in files
- See How to ignore files and directories with eslint
- See Index of problems detected by eslint
Configuration in MegaLinter
- Enable eslint by adding
JAVASCRIPT_ESin ENABLE_LINTERS variable - Disable eslint by adding
JAVASCRIPT_ESin DISABLE_LINTERS variable
- Enable autofixes by adding
JAVASCRIPT_ESin APPLY_FIXES variable
| Variable | Description | Default value |
|---|---|---|
| JAVASCRIPT_ES_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
| JAVASCRIPT_ES_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
| JAVASCRIPT_ES_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
| JAVASCRIPT_ES_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
| JAVASCRIPT_ES_CLI_LINT_MODE | Override default CLI lint mode - file: Calls the linter for each file- list_of_files: Call the linter with the list of files as argument- project: Call the linter from the root of the project |
list_of_files |
| JAVASCRIPT_ES_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".js", ".vue"] |
| JAVASCRIPT_ES_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
| JAVASCRIPT_ES_PRE_COMMANDS | List of bash commands to run before the linter | None |
| JAVASCRIPT_ES_POST_COMMANDS | List of bash commands to run after the linter | None |
| JAVASCRIPT_ES_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling JAVASCRIPT_ES and its pre/post commands | None |
| JAVASCRIPT_ES_CONFIG_FILE | eslint configuration file name Use LINTER_DEFAULT to let the linter find it |
eslint.config.js |
| JAVASCRIPT_ES_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
| JAVASCRIPT_ES_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
| JAVASCRIPT_ES_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
| JAVASCRIPT_ES_CLI_EXECUTABLE | Override CLI executable | ['eslint'] |
IDE Integration
Use eslint in your favorite IDE to catch errors before MegaLinter !
MegaLinter Flavors
This linter is available in the following flavors
| Flavor | Description | Embedded linters | Info | |
|---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 136 | |
| cupcake | MegaLinter for the most commonly used languages | 92 | ||
| dotnetweb | Optimized for C, C++, C# or VB based projects with JS/TS | 76 | ||
| javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 62 |
Behind the scenes
How are identified applicable files
- Activated only if one of these files is found:
eslint.config.js, eslint.config.mjs, eslint.config.cjs, eslint.config.ts, eslint.config.mts, eslint.config.cts, .eslintrc.json, .eslintrc.yml, .eslintrc.yaml, .eslintrc.js, .eslintrc.cjs, package.json:eslintConfig - File extensions:
.js,.vue
How the linting is performed
- eslint is called once with the list of files as arguments (
list_of_filesCLI lint mode)
Example calls
eslint myfile.js
eslint -c eslint.config.js --no-ignore myfile.js
eslint --fix -c eslint.config.js --no-ignore myfile.js
Help content
eslint [options] file.js [file.js] [dir]
Basic configuration:
--no-config-lookup Disable look up for eslint.config.js
-c, --config path::String Use this configuration instead of eslint.config.js, eslint.config.mjs, or eslint.config.cjs
--inspect-config Open the config inspector with the current configuration
--ext [String] Specify additional file extensions to lint
--global [String] Define global variables
--parser String Specify the parser to be used
--parser-options Object Specify parser options
Specify Rules and Plugins:
--plugin [String] Specify plugins
--rule Object Specify rules
Fix Problems:
--fix Automatically fix problems
--fix-dry-run Automatically fix problems without saving the changes to the file system
--fix-type Array Specify the types of fixes to apply (directive, problem, suggestion, layout)
Ignore Files:
--no-ignore Disable use of ignore files and patterns
--ignore-pattern [String] Patterns of files to ignore
Use stdin:
--stdin Lint code provided on <STDIN> - default: false
--stdin-filename String Specify filename to process STDIN as
Handle Warnings:
--quiet Report errors only - default: false
--max-warnings Int Number of warnings to trigger nonzero exit code - default: -1
Output:
-o, --output-file path::String Specify file to write report to
-f, --format String Use a specific output format - default: stylish
--color, --no-color Force enabling/disabling of color
Inline configuration comments:
--no-inline-config Prevent comments from changing config or rules
--report-unused-disable-directives Adds reported errors for unused eslint-disable and eslint-enable directives
--report-unused-disable-directives-severity String Chooses severity level for reporting unused eslint-disable and eslint-enable directives - either: off, warn, error, 0, 1, or 2
--report-unused-inline-configs String Adds reported errors for unused eslint inline config comments - either: off, warn, error, 0, 1, or 2
Caching:
--cache Only check changed files - default: false
--cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
--cache-location path::String Path to the cache file or directory
--cache-strategy String Strategy to use for detecting changed files in the cache - either: metadata or content - default: metadata
Suppressing Violations:
--suppress-all Suppress all violations - default: false
--suppress-rule [String] Suppress specific rules
--suppressions-location path::String Specify the location of the suppressions file
--prune-suppressions Prune unused suppressions - default: false
--pass-on-unpruned-suppressions Ignore unused suppressions - default: false
Miscellaneous:
--init Run config initialization wizard - default: false
--env-info Output execution environment information - default: false
--no-error-on-unmatched-pattern Prevent errors when pattern is unmatched
--exit-on-fatal-error Exit with exit code 2 in case of fatal error - default: false
--no-warn-ignored Suppress warnings when the file list includes ignored files
--pass-on-no-patterns Exit with exit code 0 in case no file patterns are passed
--debug Output debugging information
-h, --help Show help
-v, --version Output the version number
--print-config path::String Print the configuration for the given file
--stats Add statistics to the lint report - default: false
--flag [String] Enable a feature flag
--mcp Start the ESLint MCP server
--concurrency Int|String Number of linting threads, auto to choose automatically, off for no multithreading - default: off
Installation on mega-linter Docker image
- Dockerfile commands :
# renovate: datasource=npm depName=eslint
ARG NPM_ESLINT_VERSION=10.4.0
# renovate: datasource=npm depName=@eslint/js
ARG NPM_ESLINT_JS_VERSION=10.0.1
# renovate: datasource=npm depName=eslint-config-prettier
ARG NPM_ESLINT_CONFIG_PRETTIER_VERSION=10.1.8
# renovate: datasource=npm depName=eslint-plugin-import-x
ARG NPM_ESLINT_PLUGIN_IMPORT_X_VERSION=4.16.2
# renovate: datasource=npm depName=eslint-plugin-jest
ARG NPM_ESLINT_PLUGIN_JEST_VERSION=29.15.2
# renovate: datasource=npm depName=eslint-plugin-n
ARG NPM_ESLINT_PLUGIN_N_VERSION=18.0.1
# renovate: datasource=npm depName=eslint-plugin-prettier
ARG NPM_ESLINT_PLUGIN_PRETTIER_VERSION=5.5.5
# renovate: datasource=npm depName=eslint-plugin-promise
ARG NPM_ESLINT_PLUGIN_PROMISE_VERSION=7.3.0
# renovate: datasource=npm depName=eslint-plugin-vue
ARG NPM_ESLINT_PLUGIN_VUE_VERSION=10.9.1
# renovate: datasource=npm depName=@microsoft/eslint-formatter-sarif
ARG NPM_MICROSOFT_ESLINT_FORMATTER_SARIF_VERSION=3.1.0
- NPM packages (node.js):
Known errors and resolutions
When this linter fails for a known non-lint reason (remote service unavailable, malformed config, missing credentials, etc.), MegaLinter detects the pattern below in the linter output and surfaces the matching guidance.
JAVASCRIPT_ES_ERROR_PLUGIN_NOT_FOUND
Detection pattern (regex):
(Failed to load plugin '|ESLint couldn't find the plugin "|Cannot find module 'eslint-plugin-)
Resolution guidance:
ESLint could not load a plugin referenced in your config. The plugin is not installed in MegaLinter's bundled `node_modules` (`/node-deps/node_modules`).
Resolutions:
- Pre-install the missing plugin into MegaLinter's npm root via a pre-command in your .mega-linter.yml:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: "npm install eslint-plugin-NAME"
cwd: "root"
continue_if_failed: false
- Or install your project's full dependency tree and run ESLint from the workspace `node_modules`:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: yarn install --frozen-lockfile --ignore-scripts
cwd: workspace
continue_if_failed: false
JAVASCRIPT_ES_CLI_EXECUTABLE: node_modules/.bin/eslint
- Verify the plugin name in your ESLint config matches the published npm package name.
JAVASCRIPT_ES_ERROR_CONFIG_NOT_FOUND
Detection pattern (regex):
(ESLint couldn't find the config "|Failed to load config "|Cannot find module 'eslint-config-)
Resolution guidance:
ESLint could not resolve a shareable config referenced via `extends` (e.g. `airbnb`, `standard`, `prettier`). The config package is not installed in MegaLinter's bundled `node_modules`.
Resolutions:
- Pre-install the missing config package via a pre-command in your .mega-linter.yml:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: "npm install eslint-config-NAME"
cwd: "root"
continue_if_failed: false
- Or install your project's dependencies and run ESLint from the workspace binary (see ESLint v10 section above).
JAVASCRIPT_ES_ERROR_PARSER_NOT_FOUND
Detection pattern (regex):
(Cannot find module '@?[A-Za-z0-9_/.-]*parser'|Failed to load parser '|Could not resolve parser)
Resolution guidance:
ESLint could not load the parser referenced in your config (e.g. `@babel/eslint-parser`, `vue-eslint-parser`). The parser package is not bundled in MegaLinter and must be installed.
Resolutions:
- Pre-install the parser via a pre-command in your .mega-linter.yml:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: "npm install @babel/eslint-parser"
cwd: "root"
continue_if_failed: false
- Or install the full project tree and use the workspace ESLint binary (see ESLint v10 section above).
JAVASCRIPT_ES_ERROR_FLAT_CONFIG_MODULE_NOT_FOUND
Detection pattern (regex):
ERR_MODULE_NOT_FOUND.+eslint\.config\.
Resolution guidance:
ESLint v9+/v10 flat config (`eslint.config.mjs`) uses native ESM resolution, which does not honor `NODE_PATH`. Bare imports like `import js from '@eslint/js'` fail when ESLint runs from MegaLinter's bundled install.
Resolutions:
- Use `createRequire` in your `eslint.config.mjs` (see the "ESLint v10" section in this linter's documentation above).
- Or install your project's dependencies and run the project-local ESLint binary:
JAVASCRIPT_ES_PRE_COMMANDS:
- command: yarn install --frozen-lockfile --ignore-scripts
cwd: workspace
continue_if_failed: false
JAVASCRIPT_ES_CLI_EXECUTABLE: node_modules/.bin/eslint
JAVASCRIPT_ES_ERROR_OUT_OF_MEMORY
Detection pattern (regex):
(JavaScript heap out of memory|FATAL ERROR:.+Allocation failed|Reached heap limit Allocation failed)
Resolution guidance:
ESLint ran out of Node.js heap memory. This typically happens on very large codebases or when type-aware rules (`parserOptions.project`) load the entire TypeScript program.
Resolutions:
- Raise the Node.js heap and whitelist the var for this linter (MegaLinter strips most env vars by default):
JAVASCRIPT_ES_UNSECURED_ENV_VARIABLES:
- NODE_OPTIONS
NODE_OPTIONS: "--max-old-space-size=8192"
- Reduce scope via `JAVASCRIPT_ES_FILTER_REGEX_INCLUDE` / `JAVASCRIPT_ES_FILTER_REGEX_EXCLUDE`.
- Disable type-aware rules or remove `parserOptions.project` if it is not strictly required.

