UNPKG

@elsikora/eslint-config

Version:

ESLint configuration vision of ElsiKora

49 lines (48 loc) 2.08 kB
import type { IConfigOptions } from '../../domain/interface/index'; import type { Linter } from "eslint"; /** * Factory class for generating ESLint configurations based on provided options. * Maps configuration flags to their respective module loaders and dynamically imports * the required config modules. Handles loading failures gracefully by logging warnings * and returning empty configs. * @class ConfigFactory * @static */ export declare class ConfigFactory { static readonly OPTIONS_TO_CONFIG_MAP: Record<keyof IConfigOptions, string>; private static readonly CONFIG_MAPPING; private static currentOptions; /** * Creates ESLint configurations based on the provided options. * * This function processes the configuration options and dynamically imports * the required ESLint configuration modules based on enabled features. * It filters out disabled options and loads only the necessary configurations. * @param {IConfigOptions} options - Configuration options that determine which ESLint rules to include * @returns {Promise<Array<Linter.Config>>} A promise that resolves to an array of ESLint configurations * @example * // Basic usage with typescript and react * const config = await ConfigFactory.createConfig({ * withTypescript: true, * withReact: true * }); * @example * // Full-featured configuration for a modern web application * const fullConfig = await ConfigFactory.createConfig({ * withTypescript: true, * withReact: true, * withEslint: true, * withPrettier: true, * withJsDoc: true, * withStylistic: true * }); */ static createConfig(options: IConfigOptions): Promise<Array<Linter.Config>>; /** * Loads a specific ESLint configuration module by name * @param {string} name - The name of the configuration module to load * @returns {Promise<Array<Linter.Config>>} A promise that resolves to an array of ESLint configurations * @private */ private static loadConfig; }