eslint-config-kentcdodds
raw JSON → 21.0.0 verified Sat Apr 25 auth: no javascript
ESLint shareable config reflecting Kent C. Dodds' personal style preferences. Current version 21.0.0, released Jan 2024, requiring Node >=18 and ESLint ^8. Key differentiators: includes all necessary plugins as dependencies (no manual install), composes several sub-configs (import, jest, react, jsx-a11y) that can be used standalone or combined, and is actively maintained with frequent updates to align with latest ESLint rules.
Common errors
error Error: Failed to load plugin 'import' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-import' ↓
cause Older versions of this config required manual installation of peer dependencies; newer versions include them.
fix
Update to latest version (v21.0.0) which includes all plugins as dependencies. Run
npm install eslint-config-kentcdodds@latest. error ESLint couldn't find the config 'kentcdodds' after extending 'kentcdodds'. Check that the package name is correct and installed. ↓
cause Missing eslint-config-kentcdodds package or incorrect extends name.
fix
Install the package with
npm install --save-dev eslint-config-kentcdodds and ensure .eslintrc extends uses 'kentcdodds' (not 'eslint-config-kentcdodds'). error TypeError: eslint.CLIEngine is not a constructor ↓
cause Using an older version of ESLint (<8) with config v20+ which requires ESLint 8.
fix
Upgrade ESLint to version 8 or later:
npm install --save-dev eslint@^8.0.0 Warnings
breaking v21.0.0 requires Node >=18, dropping support for Node 16 and earlier. ↓
fix Upgrade Node.js to version 18 or later.
breaking v20.0.0-alpha.3 requires ESLint ^8.0.0, dropping ESLint 7 support. ↓
fix Upgrade ESLint to version 8.x.
breaking v20.0.0 merges ES6 config into main config, potentially changing rule application order. ↓
fix Check for rule conflicts if you were extending both 'kentcdodds' and 'kentcdodds/es6'.
gotcha The 'kentcdodds/jest' config uses ESLint overrides and only applies to test files (e.g., *.test.js). It won't lint non-test files. ↓
fix Ensure test file names match pattern (e.g., *.test.js) or adjust override files pattern.
gotcha All plugins are included as dependencies, so they may introduce transitive dependencies that increase install size. Not all plugins are needed if you only use a subset of configs. ↓
fix Use individual sub-configs instead of the full default if you want to minimize dependency footprint.
Install
npm install eslint-config-kentcdodds yarn add eslint-config-kentcdodds pnpm add eslint-config-kentcdodds Imports
- kentcdodds wrong
extends: 'eslint-config-kentcdodds'correctextends: 'kentcdodds' - kentcdodds/import wrong
extends: 'kentcdodds/imports'correctextends: 'kentcdodds/import' - kentcdodds/jest
extends: 'kentcdodds/jest'
Quickstart
// Install the config
npm install --save-dev eslint-config-kentcdodds eslint
// Create .eslintrc.js
module.exports = {
extends: 'kentcdodds',
rules: {
// your overrides
},
}
// Or combine sub-configs
module.exports = {
extends: ['kentcdodds', 'kentcdodds/import', 'kentcdodds/jest'],
rules: {
// custom rules
},
}
// eslint.config.js (ESLint 9+ flat config, if using eslint.config.js)
import kentcdodds from 'eslint-config-kentcdodds';
export default [
...kentcdodds,
{
rules: {
// overrides
},
},
];