interface AstNode { readonly type: string; [key: string]: any; } /** * Options accepted by the prefer-maybe-type rule. */ export interface UtilPreferMaybeTypeRuleOptions { /** * Type names that should be left untouched even when present in an explicit null/undefined union. * Useful when a name like `Maybe`-flavored alias is already in the union and a rewrite would create * `Maybe>`-style nesting. */ readonly allowedTypeNames?: readonly string[]; /** * When true, the rule still reports `T | null` unions but skips the auto-fix entirely and emits a * message instructing the developer to import `Maybe` via a relative path. Used inside the * `@dereekb/util` package itself, where the default auto-fix would insert * `import type { Maybe } from '@dereekb/util';` — a circular self-import. Defaults to `false`. */ readonly noAutoImport?: boolean; } /** * ESLint rule definition for prefer-maybe-type. */ export interface UtilPreferMaybeTypeRuleDefinition { readonly meta: { readonly type: 'suggestion'; readonly fixable: 'code'; readonly docs: { readonly description: string; readonly recommended: boolean; }; readonly messages: { readonly preferMaybe: string; readonly preferMaybeNoAutoImport: string; }; readonly schema: readonly object[]; }; create(context: { options: UtilPreferMaybeTypeRuleOptions[]; report: (descriptor: { node: AstNode; messageId: string; data?: Record | undefined; fix?: ((fixer: AstNode) => AstNode | AstNode[]) | undefined; }) => void; sourceCode: AstNode; }): Record void>; } /** * ESLint rule that flags explicit `T | null` and `T | null | undefined` unions (including the * combination of an optional modifier with `| null`, e.g. `foo?: T | null`) and recommends using * `Maybe` from `@dereekb/util` instead. The rule targets only unions that explicitly include * `null` — `T | undefined` alone is left untouched because `x?: T` and `T | undefined` are the * common, intentional shapes for "value may be absent" and have no canonical `Maybe` equivalent * to push toward when `null` isn't involved. * * Auto-fix rewrites the union as `Maybe<...>` and (once per file) inserts * `import type { Maybe } from '@dereekb/util';` near the top of the file. The workspace's * `import/no-duplicates` rule (configured with `prefer-inline: true`) consolidates the new * import with any existing `@dereekb/util` import on subsequent fix passes. * * When the `noAutoImport` option is `true`, the rule still reports the union but skips the auto-fix * and emits a message instructing the developer to import `Maybe` via a relative path. This is the * configuration used inside the `@dereekb/util` package itself, where the default auto-fix would * insert a circular self-import. * * @see `dbx__note__typescript-programming` → Maybe Usage */ export declare const UTIL_PREFER_MAYBE_TYPE_RULE: UtilPreferMaybeTypeRuleDefinition; export {};