ESLint rules grouped by category
ESLint ships dozens of built-in core rules. Since ESLint 8 they are organized
into three categories by intent, and each rule carries two important flags:
whether eslint --fix can auto-correct it, and whether the eslint:recommended
preset enables it. This searchable reference lists representative core rules per
category so you can find what a rule does and how to wire it up.
The three categories explained
Possible Problems
Rules that catch code that is very likely to be a bug or to cause unexpected behaviour at runtime. These are the highest-confidence rules — violations are almost always wrong:
no-undef— catches references to variables that are never declaredno-unreachable— catches code afterreturn,throw, orcontinueno-unused-vars— catches variables declared but never readno-const-assign— catches reassignment ofconstbindingsno-duplicate-case— catches duplicatecaselabels inswitch
Most Possible Problems rules are not auto-fixable because the safe correction is ambiguous — removing the unused variable versus using it are both valid fixes.
Suggestions
Rules that improve code style and correctness without flagging outright errors. Violations indicate a pattern that could cause confusion or has a cleaner equivalent:
prefer-const— suggestsconstwhen aletbinding is never reassignedeqeqeq— requires===and!==instead of==and!=no-var— disallowsvarin favour oflet/constcurly— requires braces around all control-flow bodiesarrow-body-style— enforces concise arrow functions where possible
Many Suggestion rules are auto-fixable.
Layout and Formatting
Rules controlling whitespace, indentation, and brace style. These are deprecated in the core — ESLint recommends moving formatting to Prettier or the @stylistic/eslint-plugin instead and focusing ESLint on correctness. They remain in core for backwards compatibility but will not receive new features.
How to enable a rule
// eslint.config.js (flat config)
export default [
{
rules: {
"no-unused-vars": "error",
"eqeqeq": ["error", "always"],
"prefer-const": "warn"
}
}
];
Severity values: "off" or 0, "warn" or 1, "error" or 2. Only "error" causes eslint to exit with a non-zero code and fail CI. Use "warn" for rules you want to surface without blocking builds while the team migrates.
Reading the fixable and recommended flags
- Fixable: when running
eslint --fix, any rule flagged as fixable will have its violations corrected automatically. Layout rules are usually fixable; Possible Problems rules usually are not. - Recommended: the
eslint:recommendedpreset (in flat config,js.configs.recommended) enables a curated set of high-confidence core rules. These are the rules marked as recommended in this reference. It is a safe, minimal baseline — extend it with your own rules rather than replacing it.
Tips
- Start from
eslint:recommended, then add rules as your team agrees on them — avoid enabling everything at once. - Prefer
--fixfor the fixable Suggestion and Layout rules to save manual work. - Move pure formatting to Prettier; keep ESLint focused on correctness.
- A rule’s severity can be
off,warnorerror; onlyerrorfails CI. - Use
"warn"for new rules being introduced to a legacy codebase to surface violations without immediately blocking deployments.