/** * Loop Convention Rules * Enforces conventions for while, do-while, and loop control flow. */ import type { ValidationRule } from '../types.js'; /** * Validates that variables captured in loop bodies aren't referenced in conditions. * * In while and do-while loops, $ serves as the accumulator across iterations. * Variables captured inside the loop body exist only within that iteration, so * referencing them in the loop condition is a logic error - the condition will * always see undefined (or the outer scope variable if one exists). * * Error pattern (captured variable in condition): * 0 -> ($x < 5) @ { # $x is undefined in condition * $ => $x * $x + 1 * } * * Correct pattern ($ as accumulator): * 0 -> ($ < 5) @ { $ + 1 } * * Also correct (capture only used within iteration): * 0 -> ($ < 5) @ { * $ => $x * log($x) # $x only used in body, not condition * $x + 1 * } * * References: * - docs/guide-conventions.md:151-171 */ export declare const LOOP_ACCUMULATOR: ValidationRule; /** * Suggests using do-while for retry patterns. * * Do-while is clearer for retry patterns where the body must run at least once: * * Good (do-while for retry): * @ { * attemptOperation() * } ? (.contains("RETRY")) * * Less clear (while with separate first attempt): * attemptOperation() => $result * $result -> .contains("RETRY") @ { * attemptOperation() * } * * This is informational - helps guide users to the clearer pattern. * * References: * - docs/guide-conventions.md:173-186 */ export declare const PREFER_DO_WHILE: ValidationRule; /** * Suggests using each for collection iteration instead of while loops. * * When iterating over a collection, each is clearer and more idiomatic: * * Good (each for collection): * $items -> each { process($) } * * Less clear (while loop): * 0 => $i * ($i < $items.len) @ { * $items[$i] -> process() * $i + 1 * } * * This is informational - while loops work, but each is clearer for collections. * * References: * - docs/guide-conventions.md:188-196 */ export declare const USE_EACH: ValidationRule;