| Feature | ESLint v9+ (Flat Config) | ESLint v8 and below (.eslintrc) |
|---|---|---|
| Config Format | JavaScript-only flat config (eslint.config.js) |
JSON, YAML, or JS (.eslintrc) |
| File Structure | Flat array of config objects (more predictable merge order) | Hierarchical and deep merging of config |
| Config File Name | eslint.config.js |
.eslintrc.js, .eslintrc.json, etc. |
| Plugins | Must be imported explicitly using import or require
|
Auto-loaded by name convention |
| Extends | No extends keyword — you spread config into the array manually |
Uses extends: 'airbnb-base' etc. |
| Performance | Faster, deterministic resolution order | Slower with more complex merging |
| Scoping | Config applies only to matching files (using files/ignores) |
Can be inherited by directory hierarchy |
| TypeScript Support | Better integration with @eslint/js and modern bundlers |
Requires additional setup or plugin support |
- Config Format Flat Config (ESLint v9)
import js from '@eslint/js';
export default [
js.configs.recommended,
{
rules: {
'eqeqeq':'error',
},
},
];
Old Config
module.exports = {
extends: ['eslint:recommended'],
rules: {
'eqeqeq':'error',
},
};
- File Structure: Flat vs Nested Flat Config (v9): No inheritance, flat array.Each config block is evaluated in order, top-down.
export default [
{
files: ['**/*.js'],
rules: {
'no-console': 'warn',
},
},
{
files: ['src/**/*.js'],
rules: {
'no-console': 'error',
},
},
];
Nested: Deep merge + inheritance. ESLint merges configs up the directory tree.
// root/.eslintrc.js
module.exports = {
rules: {
'no-console': 'warn',
},
};
// root/src/.eslintrc.js
module.exports = {
rules: {
'no-console': 'error', // overrides parent
},
};
- Extends vs Import Flat Config (v9): No extends, uses direct imports
import js from '@eslint/js';
import airbnb from 'eslint-config-airbnb-base';
export default [
js.configs.recommended,
...airbnb, // must be spread manually if it's an array
];
.eslintrc: Uses extends keyword
module.exports = {
extends: ['eslint:recommended', 'airbnb-base'],
};
- Plugins Usage: Flat Config: Plugins must be imported manually
import js from '@eslint/js';
import myPlugin from 'eslint-plugin-myplugin';
export default [
js.configs.recommended,
{
plugins: {
my: myPlugin,
},
rules: {
'my/custom-rule': 'error',
},
},
];
.eslintrc: Plugins are auto-loaded by name
module.exports = {
plugins: ['myplugin'],
rules: {
'myplugin/custom-rule': 'error',
},
};
Top comments (0)