A TypeScript-based library for generating ESLint configurations in the Flat Config format, targeting TypeScript projects with optional NodeJS and React support.
- Generates ESLint Flat Configs for ESLint v9.
- Requires TypeScript and optionally supports React and NodeJS
- Automatically drops rules handled by Prettier.
- Uses Biome data to optionally disable rules supported by Biome.
strict
: Enables strict linting rules (TypeScript mostly)style
: Adds additional rules for style guidelines and import sorting/grouping.fast
: Drop rules which require typing information (much faster)biome
: Drop rules which are implemented identically in Biome (for performance reasons)disabled
: Only return disabled rules. Helpful to add to the end when using custom rules.react
: Add all recommended ReactJS checksnode
: Add all recommended NodeJS checkstesting
: Add all recommended Jest checks
react
: Recommended checks from the react, hooks and compiler presets. Also included A11Y checks.node
: Recommended rules for development of ESM-enabled NodeJS scriptsjest
: Recommended rules for usage of a modern test runner like Jest or compatible (Vitest, Bun)jsdoc
: Typescript-aware JSDoc linting without requiring docs... only validating.regexp
: Recommended mostly auto-fix rules for regular expressions
npm install @effective/eslint-cfg
// eslint.config.ts
import { getConfig } from "@effective/eslint-cfg"
const config = getConfig({
react: true,
strict: true,
style: true
})
export default [
{
ignores: ["node_modules", "dist"]
},
{
settings: {
react: {
version: "19.0"
}
}
},
{
files: ["**/*.ts", "**/*.tsx"]
},
{
rules: {
// custom rules / overrides
}
}
]
Note: Using TS configuration files work perfectly fine since ESLint v9 but requires installing jiti
.
The package exports the following functions:
Loads an ESLint configuration based on the provided options.
options
- The configuration options- Returns: Promise resolving to the loaded ESLint configuration
import { getConfig } from "@effective/eslint-cfg"
const options = {
react: true,
strict: true,
style: true
}
const config = await getConfig(options)
console.log(config.rules) // Access the ESLint rules
Changes the severity of a specific ESLint rule in the configuration.
config
- The ESLint configurationruleName
- The name of the rule to modifyseverity
- The new severity level ("error" | "warn" | "off")- Throws: When the config has no rules or the rule is not configured
import { getConfig, setRuleSeverity } from "@effective/eslint-cfg"
const config = await getConfig(options)
// Change 'no-console' rule to warning
setRuleSeverity(config, "no-console", "warn")
Configures a specific ESLint rule in the configuration with its severity and optional parameters. Unlike setRuleSeverity, this method preserves the existing severity level while allowing to update the rule's options.
config
- The ESLint configurationruleName
- The name of the rule to configureoptions
- Optional array of configuration options for the rule- Throws: When the config has no rules or the rule is not configured
import { getConfig, configureRule } from "@effective/eslint-cfg"
const config = await getConfig(options)
// Configure 'max-len' rule with options while preserving severity
configureRule(config, "max-len", [{ code: 100, tabWidth: 2 }])
Disables a specific ESLint rule in the configuration by removing it.
config
- The ESLint configurationruleName
- The name of the rule to disable- Throws: When the config has no rules or the rule is not configured
import { getConfig, disableRule } from "@effective/eslint-cfg"
const config = await getConfig(options)
// Completely remove the 'no-console' rule
disableRule(config, "no-console")
Adds a new ESLint rule to the configuration with specified severity and options.
config
- The ESLint configurationruleName
- The name of the rule to addseverity
- The severity level for the rule ("warn" | "error")options
- Additional options for the rule configuration- Throws: When the config has no rules or the rule is already configured
import { getConfig, addRule } from "@effective/eslint-cfg"
const config = await getConfig(options)
// Add new rule with options
addRule(config, "max-len", "error", [{ code: 100 }])
import {
getConfig,
setRuleSeverity,
disableRule,
addRule
} from "@effective/eslint-cfg"
async function customizeEslintConfig() {
// Load the base configuration
const config = await getConfig({
react: true,
strict: true,
style: true
})
// Customize rule severities
setRuleSeverity(config, "no-console", "warn")
setRuleSeverity(config, "no-unused-vars", "error")
// Disable rules you don't want
disableRule(config, "complexity")
// Add new rule with options
addRule(config, "max-len", "error", [{ code: 100 }])
return config
}
pnpm run build
Apache License; Version 2.0, January 2004
Copyright 2024-2025
Sebastian Software GmbH