UNPKG

@report-toolkit/common

Version:

See docs at [https://ibm.github.io/report-toolkit](https://ibm.github.io/report-toolkit)

149 lines (148 loc) 4.31 kB
/** * Given a {@link Config}, return a list of rules that are enabled. * @param {Config} config - Parsed config * @returns {string[]} List of rule IDs */ export function filterEnabledRules(config: Config): string[]; /** * Assign the "flattened config" symbol to complete the config. * Add default fields. * @param {Partial<Config>} config - Config to mark flattened * @returns {Config} The "final" config */ export function normalizeFlattenedConfig(config: Partial<Config>): Config; /** * Given an `Observable` of {@link ExportedConfig} arrays, return a single, * flattened {@link Config} object. Config object will have a * `kFlattenedConfig` `Symbol` property set to `true`. * @todo Eliminate extra empty properties * @returns {import('rxjs').OperatorFunction<ExportedConfig|ConfigListItem, Config>} */ export function parseConfig(): import('rxjs').OperatorFunction<ExportedConfig | ConfigListItem, Config>; export const RECOMMENDED_CONFIG_ALIAS: "rtk:recommended"; /** * @type {Map<BuiltinConfigAliases,ExportedConfig>} * @todo move this */ export const BUILTIN_CONFIGS: Map<BuiltinConfigAliases, ExportedConfig>; /** * A list of built-in config aliases. (This is intended to be a union type * if/when other built-in configs are added.) */ export type BuiltinConfigAliases = "rtk:recommended"; /** * The exports of a builtin config file. */ export type BuiltinConfigModule = { /** * - The exported configuration */ config: ConfigListItem[]; }; /** * The exports of a config file. There should be only one; `config`, which may * be a {@link Config} or {@link ExportedConfig}. */ export type ConfigModule = { /** * - The exported configuration */ config: ConfigListItem[]; }; /** * A configuration object. Each configuration file exports an * {@link ExportedConfig} array containing one or more of these. */ export type Config = { [kFlattenedConfig]?: true; } | ConfigProps; /** * Alias for the `config` prop of a config file or {@link ConfigModule}. See * {@link ConfigListItem}. */ export type ExportedConfig = (Partial<{ [kFlattenedConfig]?: true; }> | Partial<ConfigProps> | ConfigModule | "rtk:recommended")[]; /** * An item in the `config` prop of a config file or {@link ConfigModule}. */ export type ConfigListItem = Partial<{ [kFlattenedConfig]?: true; }> | Partial<ConfigProps> | ConfigModule | "rtk:recommended"; /** * Properties of a {@link Config} object. */ export type ConfigProps = { /** * - Zero or more plugin module IDs (as one would `require(id)` them) */ plugins: string[]; /** * - Rule-specific configurations, keyed by rule name. */ rules: Partial<RulesConfig>; /** * - Transformer-specific defaults */ transformers: Partial<TransformerDefaultsConfig>; /** * - Command-specific defaults */ commands: Partial<CommandDefaultsConfig>; }; /** * The symbol attached to a flattened {@link Config}. */ export type FlattenedConfigMarker = { [kFlattenedConfig]?: true; }; /** * Command-specific defaults. Command-line arguments will always override these. */ export type CommandDefaultsConfig = { inspect: any; redact: any; transform: any; diff: any; }; /** * Valid command names for commands (used with {@link CommandDefaultsConfig}). */ export type CommandName = "inspect" | "redact" | "transform" | "diff"; /** * Per-rule configuration. */ export type RulesConfig = { [key: string]: boolean | { [key: string]: any; }; }; /** * Valid severity levels. */ export type Severity = "error" | "warning" | "info"; /** * Rule-specific configuration. `severity` and `enable` will always be usable, * otherwise the rest of the properties are defined by the rule. */ export type RuleConfig = { [key: string]: any; }; /** * A valid transformer name. */ export type TransformerName = "table" | "filter" | "json" | "redact" | "csv" | "newline" | "stack-hash"; /** * Per-transformer defaults, keyed on transformer name. */ export type TransformerDefaultsConfig = { table: any; filter: any; json: any; redact: any; csv: any; newline: any; "stack-hash": any; }; export type Observable<T> = import("rxjs").Observable<T>; import { kFlattenedConfig } from "./symbols.js";