ESLint Config Love
eslint-config-love is a highly opinionated and strict ESLint shareable configuration specifically designed for TypeScript projects, prioritizing code safety and explicit patterns over conciseness. It currently stands at version 153.0.0, indicative of its extremely rapid development cycle where even minor rule additions or dependency updates are considered breaking changes, leading to frequent major version bumps (often weekly or bi-weekly). This configuration differentiates itself by intentionally avoiding formatting rules, instead advocating for dedicated code formatters like Prettier. It also refrains from duplicating checks already enforced by TypeScript's strict mode and steers clear of library- or framework-specific rules, maintaining a focus on core JavaScript and TypeScript linting. It integrates rules from various sources including ESLint itself, `@typescript-eslint`, `@eslint-community/eslint-comments`, `n`, `promise`, and `import` plugins.
Common errors
-
Parsing error: 'parserOptions.project' has been set for 'parser'. The 'project' of 'parserOptions' was set and now 'parser' needs to be configured with 'project'.
cause The `eslint-config-love` configuration enables type-aware linting rules which require a `tsconfig.json` to be present and correctly configured.fixEnsure a valid `tsconfig.json` file exists in your project's root or specified location, and that the `include` glob covers all files ESLint should process. -
ESLint couldn't find the config "love".
cause The `eslint-config-love` package is not installed or the `extends` path in `.eslintrc` is incorrect.fixRun `npm install --save-dev eslint-config-love` and ensure your ESLint configuration file correctly references `love` in the `extends` array or similar. -
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".cjs" for <path-to-eslint-config-love>/index.js
cause You are attempting to use `require()` for `eslint-config-love` in a CommonJS context, but the package is ESM-first.fixFor CommonJS configurations, use a dynamic import: `const { default: love } = await import('eslint-config-love')` inside an `async` function for your ESLint config. -
ESLint: Cannot find module 'eslint' or 'typescript'.
cause Missing peer dependencies. `eslint-config-love` relies on `eslint` and `typescript` as peer dependencies.fixInstall the required peer dependencies: `npm install --save-dev eslint typescript`.
Warnings
- breaking This package has an extremely aggressive major version release schedule, with new major versions often released weekly or bi-weekly. Each new version frequently introduces breaking changes, typically by enabling new rules or upgrading underlying ESLint plugins. Users should anticipate needing to adjust their code or ESLint configurations with almost every update. Always review the changelog before upgrading.
- breaking Version 153.0.0 introduced breaking changes related to promise handling, specifically enabling `promise/prefer-catch` and updating `eslint-plugin-promise` to `^7.2.0`.
- breaking Multiple recent versions have introduced breaking changes due to significant updates to `@typescript-eslint` plugins, enabling new strict TypeScript-specific rules.
- gotcha The configuration explicitly sets `languageOptions.parserOptions.project = true`, meaning ESLint will require a `tsconfig.json` file in your project to correctly parse and lint TypeScript files, especially for type-aware rules. Without it, you will encounter parsing errors.
Install
-
npm install eslint-config-love -
yarn add eslint-config-love -
pnpm add eslint-config-love
Imports
- love
import { love } from 'eslint-config-love'import love from 'eslint-config-love'
- love
const love = require('eslint-config-love')const { default: love } = await import('eslint-config-love')
Quickstart
// .eslintrc.cjs (for CommonJS projects)
module.exports = (async function config() {
const { default: love } = await import('eslint-config-love')
return [
{
...love,
files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'],
},
]
})()
// tsconfig.json (required for TypeScript rules utilizing type information)
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ESNext"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// ... other compiler options
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
"exclude": ["node_modules"]
}