import ts from 'typescript'; /** * Represents a lint error found during validation */ export interface LintError { line: number; column?: number; message: string; } /** * Context containing pre-parsed AST information for lint rules * This allows rules to avoid redundant AST traversals */ export interface LintRuleContext { sourceFile: ts.SourceFile; bubbleFlowClass: ts.ClassDeclaration | null; handleMethod: ts.MethodDeclaration | null; handleMethodBody: ts.Block | null; importedBubbleClasses: Set; /** The trigger type extracted from BubbleFlow<'trigger-type'> generic parameter */ bubbleFlowTriggerType: string | null; } /** * Interface for lint rules that can validate BubbleFlow code */ export interface LintRule { name: string; validate(context: LintRuleContext): LintError[]; } /** * Registry that manages and executes all lint rules */ export declare class LintRuleRegistry { private rules; /** * Register a lint rule */ register(rule: LintRule): void; /** * Execute all registered rules on the given code * Traverses AST once and shares context with all rules for efficiency */ validateAll(sourceFile: ts.SourceFile): LintError[]; /** * Get all registered rule names */ getRuleNames(): string[]; } /** * Lint rule that prevents throw statements directly in the handle method */ export declare const noThrowInHandleRule: LintRule; /** * Lint rule that prevents direct bubble instantiation in the handle method */ export declare const noDirectBubbleInstantiationInHandleRule: LintRule; /** * Lint rule that prevents credentials parameter from being used in bubble instantiations */ export declare const noCredentialsParameterRule: LintRule; /** * Lint rule that prevents usage of process.env */ export declare const noProcessEnvRule: LintRule; /** * Lint rule that prevents method invocations inside complex expressions */ export declare const noMethodInvocationInComplexExpressionRule: LintRule; /** * Lint rule that prevents try-catch statements in the handle method * Try-catch blocks interfere with runtime instrumentation and error handling */ export declare const noTryCatchInHandleRule: LintRule; /** * Lint rule that prevents methods from calling other methods * Methods should only be called from the handle method, not from other methods */ export declare const noMethodCallingMethodRule: LintRule; /** * Lint rule that prevents usage of 'any' type * Using 'any' bypasses TypeScript's type checking and should be avoided */ export declare const noAnyTypeRule: LintRule; /** * Lint rule that prevents multiple BubbleFlow classes in a single file * Only one class extending BubbleFlow is allowed per file for proper runtime instrumentation */ export declare const singleBubbleFlowClassRule: LintRule; /** * Lint rule that enforces proper payload typing for BubbleFlow * * When a class extends BubbleFlow<'slack/bot_mentioned'>, the handle() method's * payload parameter must be typed with the correct event type (e.g., SlackMentionEvent) * from BubbleTriggerEventRegistry, not 'any' or an incompatible type. * * This is a blocking error - mismatched types will prevent the flow from being saved. */ export declare const enforcePayloadTypeRule: LintRule; /** * Lint rule that bans casting the payload parameter to a different type inside handle(). * * This pattern defeats the type system and prevents the parser from extracting custom fields: * * BAD: * ```typescript * interface MyPayload extends SlackMentionEvent { customField: string; } * async handle(payload: SlackMentionEvent) { * const { customField } = payload as MyPayload; // Cast inside - BAD! * } * ``` * * GOOD: * ```typescript * interface MyPayload extends SlackMentionEvent { customField: string; } * async handle(payload: MyPayload) { // Use custom type directly * const { customField } = payload; // No cast needed * } * ``` */ export declare const noCastPayloadInHandleRule: LintRule; /** * Lint rule that prevents calling .toString() on Zod schemas for expectedOutputSchema/expectedResultSchema. * * Calling .toString() on a Zod schema returns a useless string like "ZodObject" * instead of the actual JSON schema. This causes the AI to not follow the expected * output structure. * * BAD: * ```typescript * expectedOutputSchema: z.object({ companies: z.array(...) }).toString() * expectedResultSchema: z.object({ result: z.string() }).toString() * ``` * * GOOD: * ```typescript * expectedOutputSchema: z.object({ companies: z.array(...) }) * expectedResultSchema: z.object({ result: z.string() }) * ``` */ export declare const noToStringOnExpectedOutputSchemaRule: LintRule; /** * Lint rule that prevents calling JSON.stringify() on Zod schemas for expectedOutputSchema/expectedResultSchema. * * JSON.stringify() on a Zod schema returns unusable JSON representation of the schema object * instead of the actual JSON schema format needed for AI structured output. * * BAD: * ```typescript * expectedOutputSchema: JSON.stringify(z.object({ ... })) * expectedResultSchema: JSON.stringify(z.object({ ... })) * ``` * * GOOD: * ```typescript * expectedOutputSchema: z.object({ ... }) * expectedResultSchema: z.object({ ... }) * ``` */ export declare const noJsonStringifyOnExpectedOutputSchemaRule: LintRule; /** * Lint rule that prevents capabilities from having inline `inputs`. * * Capability inputs should be configured by the user via the Capabilities UI, * not hardcoded in the flow code. The runtime injects input values at execution time. * * BAD: * ```typescript * capabilities: [{ id: 'knowledge-base', inputs: { sources: [`google-doc:${docId}:edit`] } }] * ``` * * GOOD: * ```typescript * capabilities: [{ id: 'knowledge-base' }] * ``` */ export declare const noCapabilityInputsRule: LintRule; /** * Default registry instance with all rules registered */ export declare const defaultLintRuleRegistry: LintRuleRegistry; //# sourceMappingURL=lint-rules.d.ts.map