Rule API
Every function operates on the config array in-place.
Functions
| Function | Description |
|---|---|
setRuleSeverity(config, rule, severity, options?) | Change "off" / "warn" / "error" while preserving options |
configureRule(config, rule, options, ruleOptions?) | Replace options while preserving severity |
disableRule(config, rule, options?) | Set to "off" across all config blocks |
addRule(config, rule, severity, options?, ruleOptions?) | Add a rule to the base config block |
disableAllRulesBut(config, rule) | Debug helper — disable everything except one rule |
Scoped rules
setRuleSeverity, configureRule, disableRule, and addRule accept an optional { scope } parameter to target specific file types instead of the entire config.
import {
getEslintConfig, disableRule, setRuleSeverity, configureRule, addRule
} from "eslint-config-setup"
const config = await getEslintConfig({ react: true, ai: true })
// Disable magic number checks in tests only
disableRule(config, "@typescript-eslint/no-magic-numbers", { scope: "tests" })
// Allow console in scripts
addRule(config, "no-console", "off", { scope: "scripts" })
// Relax complexity only in test files
configureRule(config, "complexity", [25], { scope: "tests" })
// Downgrade a rule to warning in config files
setRuleSeverity(config, "import-x/no-default-export", "warn", { scope: "configs" })
export default configAvailable scopes
"tests", "e2e", "stories", "configs", "declarations", "scripts"
Each scope matches generated blocks whose name starts with eslint-config-setup/.
"configs"maps to theeslint-config-setup/config-filesblock.- Other scopes map 1:1 (for example
"tests"→eslint-config-setup/tests).
For custom file patterns (for example browser vs server folders), add your own flat config blocks with files globs. See Configuration.
Why not just spread?
ESLint flat configs are arrays of objects. A rule like complexity might appear in multiple blocks (base, AI, complexity). Finding and modifying it by hand is error-prone. These helpers walk all blocks and apply the change consistently.
TIP
See the API Reference for full TypeScript signatures.