UNPKG

@effective/eslint-cfg

Version:

A library for generating ESLint Flat Configs with React and TypeScript support.

58 lines (57 loc) 2.86 kB
import { Linter } from "eslint"; import { ConfigName, Options } from "./util.js"; /** * Loads an ESLint configuration based on the provided options. * * @param options - The configuration options * @returns The loaded ESLint configuration */ export declare function getConfig(options: Options): Promise<Linter.Config<Linter.RulesRecord>[]>; /** * Changes the severity of a specific ESLint rule in the configuration. * * @param config - The ESLint configuration array * @param ruleName - The name of the rule to modify * @param severity - The new severity level * @throws When the config has no rules or the rule is not configured */ export declare function setRuleSeverity(config: Linter.Config[], ruleName: string, severity: "error" | "warn" | "off", objectName?: ConfigName): void; /** * 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. * * @param config - The ESLint configuration array * @param ruleName - The name of the rule to configure * @param options - Optional array of configuration options for the rule * @throws When the config has no rules or the rule is not configured */ export declare function configureRule(config: Linter.Config[], ruleName: string, objectName?: ConfigName, options?: unknown[]): void; /** * Disables a specific ESLint rule in the configuration by removing it. * * @param config - The ESLint configuration array * @param ruleName - The name of the rule to disable * @throws When the config has no rules or the rule is not configured */ export declare function disableRule(config: Linter.Config[], ruleName: string, objectName?: ConfigName): void; /** * Adds a new ESLint rule to the configuration with specified severity and options. * * @param config - The ESLint configuration array * @param ruleName - The name of the rule to add * @param severity - The severity level for the rule * @param objectName - The name of the config object to add the rule to * @param options - Additional options for the rule configuration * @throws When the config has no rules or the rule is already configured */ export declare function addRule(config: Linter.Config[], ruleName: string, severity: "warn" | "error", objectName?: ConfigName, options?: unknown[]): void; /** * Disables all rules except the one specified. Useful for focusing on a single rule for debugging. * * @param config - The ESLint configuration array * @param ruleName - The name of the rule to keep enabled * @param objectName - The name of the config object to disable all rules foräö-------- * @throws When the config has no rules */ export declare function disableAllRulesBut(config: Linter.Config[], ruleName: string, objectName?: ConfigName): void;