import type { Commit } from "conventional-commits-parser"; import { TargetCaseType } from "./ensure.js"; /** * Rules match the input either as successful or failed. * For example, when `header-full-stop` detects a full stop and is set as "always"; it's true. * If the `header-full-stop` discovers a full stop but is set to "never"; it's false. */ export type RuleOutcome = Readonly<[boolean, string?]>; /** * Rules receive a parsed commit, condition, and possible additional settings through value. * All rules should provide the most sensible rule condition and value. */ export type RuleType = "async" | "sync" | "either"; export type BaseRule = (parsed: Commit, when?: RuleConfigCondition, value?: Value) => Type extends "either" ? RuleOutcome | Promise : Type extends "async" ? Promise : Type extends "sync" ? RuleOutcome : never; export type Rule = BaseRule; export type AsyncRule = BaseRule; export type SyncRule = BaseRule; /** * Rules always have a severity. * Severity indicates what to do if the rule is found to be broken * 0 - Disable this rule * 1 - Warn for violations * 2 - Error for violations */ export declare enum RuleConfigSeverity { Disabled = 0, Warning = 1, Error = 2 } /** * Rules always have a condition. * It can be either "always" (as tested), or "never" (as tested). * For example, `header-full-stop` can be enforced as "always" or "never". */ export type RuleConfigCondition = "always" | "never"; export type RuleConfigTuple = T extends void ? Readonly<[RuleConfigSeverity.Disabled]> | Readonly<[RuleConfigSeverity, RuleConfigCondition]> : Readonly<[RuleConfigSeverity.Disabled]> | Readonly<[RuleConfigSeverity, RuleConfigCondition, T]>; export declare enum RuleConfigQuality { User = 0, Qualified = 1 } export interface RuleConfigContext { cwd?: string; } export type QualifiedRuleConfig = ((ctx?: RuleConfigContext) => RuleConfigTuple) | ((ctx?: RuleConfigContext) => Promise>) | RuleConfigTuple; export type RuleConfig = V extends RuleConfigQuality.Qualified ? RuleConfigTuple : QualifiedRuleConfig; export type CaseRuleConfig = RuleConfig; export type LengthRuleConfig = RuleConfig; export type EnumRuleConfig = RuleConfig; export type ObjectRuleConfig> = RuleConfig; export type RulesConfig = { "body-case": CaseRuleConfig; "body-empty": RuleConfig; "body-full-stop": RuleConfig; "body-leading-blank": RuleConfig; "body-max-length": LengthRuleConfig; "body-max-line-length": LengthRuleConfig; "body-min-length": LengthRuleConfig; "breaking-change-exclamation-mark": CaseRuleConfig; "footer-empty": RuleConfig; "footer-leading-blank": RuleConfig; "footer-max-length": LengthRuleConfig; "footer-max-line-length": LengthRuleConfig; "footer-min-length": LengthRuleConfig; "header-case": CaseRuleConfig; "header-full-stop": RuleConfig; "header-max-length": LengthRuleConfig; "header-min-length": LengthRuleConfig; "header-trim": RuleConfig; "references-empty": RuleConfig; "scope-case": CaseRuleConfig | ObjectRuleConfig; "scope-delimiter-style": EnumRuleConfig; "scope-empty": RuleConfig; "scope-enum": EnumRuleConfig | ObjectRuleConfig; "scope-max-length": LengthRuleConfig; "scope-min-length": LengthRuleConfig; "signed-off-by": RuleConfig; "subject-case": CaseRuleConfig; "subject-empty": RuleConfig; "subject-full-stop": RuleConfig; "subject-max-length": LengthRuleConfig; "subject-min-length": LengthRuleConfig; "trailer-exists": RuleConfig; "type-case": CaseRuleConfig; "type-empty": RuleConfig; "type-enum": EnumRuleConfig; "type-max-length": LengthRuleConfig; "type-min-length": LengthRuleConfig; [key: string]: AnyRuleConfig; }; export type AnyRuleConfig = RuleConfig | RuleConfig; //# sourceMappingURL=rules.d.ts.map