/** * Formatting Rules * Enforces style conventions from docs/guide-conventions.md:465-662. */ import type { ValidationRule } from '../types.js'; import type { SourceSpan } from '@rcrsr/rill'; /** * Enforces space on both sides of operators. * Operators like +, -, ->, =>, ==, etc. should have spaces on both sides. * * Detection: * - Extract operator text from source using source spans * - Check if space exists before/after operator * * References: * - docs/guide-conventions.md:467-482 */ export declare const SPACING_OPERATOR: ValidationRule; /** * Enforces space after { and before } in blocks. * Braces for blocks, closures, etc. should have internal spacing. * * Detection: * - Extract brace content from source * - Check if opening { has space after, closing } has space before * * References: * - docs/guide-conventions.md:497-508 */ export declare const SPACING_BRACES: ValidationRule; /** * Enforces no inner spaces for indexing brackets. * Array/dict indexing should use $var[0] not $var[ 0 ]. * * Detection: * - PostfixExpr nodes with index access * - Check for spaces inside brackets * * References: * - docs/guide-conventions.md:526-535 */ export declare const SPACING_BRACKETS: ValidationRule; /** * Enforces no space before pipe, space after in closures. * Closure parameters: |x| not | x |. * * Detection: * - Extract closure parameter section from source * - Check spacing around pipes * * References: * - docs/guide-conventions.md:549-560 */ export declare const SPACING_CLOSURE: ValidationRule; /** * Enforces 2-space indent for continued lines. * Pipe chains should indent continuation lines by 2 spaces. * * Detection: * - Multi-line pipe chains * - Check indentation of continuation lines * * References: * - docs/guide-conventions.md:636-662 */ export declare const INDENT_CONTINUATION: ValidationRule; /** * Detect explicit $.method() patterns replaceable with .method. * * Flags method calls where the receiver is a bare $ (pipe variable). * The implicit form .method is preferred when $ represents the current * piped value (e.g., in blocks, closures, conditionals). * * Detection: * - MethodCallNode with non-null receiverSpan * - Receiver is bare $ (zero-width or single-char span) * - Method call is first in chain (receiverSpan.end.offset <= 1) * * Note: Cannot use isBareReference() helper here because MethodCallNode.receiverSpan * is a SourceSpan (position range), not an ExpressionNode. The helper requires * an AST node to traverse. Instead, we detect bare $ by checking: * 1. receiverSpan is zero-width (start == end) or single-char * 2. Character at offset is '$' * 3. Next character is '.' (not a variable name continuation) * * Examples: * - $.upper() -> .upper * - $.len -> .len * - $.trim().upper() -> First method flagged, second is chained (not bare $) * * Not flagged: * - .upper (receiverSpan is null) * - $var.method() (receiverSpan is not bare $) * - $.trim().upper() second method (receiverSpan covers $.trim()) * * References: * - docs/guide-conventions.md:587-598 */ export declare const IMPLICIT_DOLLAR_METHOD: ValidationRule; /** * Prefer foo over foo($) for global function calls. * When single argument is bare $, prefer implicit form. * * Detection: * - HostCall with single argument that is bare $ * * References: * - docs/guide-conventions.md:599-607 */ export declare const IMPLICIT_DOLLAR_FUNCTION: ValidationRule; /** * Prefer $fn over $fn($) for closure invocation. * When single argument is bare $, prefer implicit form. * * Detection: * - ClosureCall with single argument that is bare $ * * References: * - docs/guide-conventions.md:608-615 */ export declare const IMPLICIT_DOLLAR_CLOSURE: ValidationRule; /** * Warns on capture-only-to-continue patterns. * Capturing a value just to use it immediately in the next line is unnecessary. * * Detection: * - Capture node followed by immediate use of that variable only * - Variable not referenced later in the script * * References: * - docs/guide-conventions.md:617-634 */ export declare const THROWAWAY_CAPTURE: ValidationRule; /** * Validate that a SourceSpan has valid coordinates. * Returns false if span, start, or end are missing, * or if line/column values are less than 1. * * Exported for testing purposes to enable direct unit testing * of edge cases (null spans, invalid coordinates). */ export declare function isValidSpan(span: SourceSpan | null | undefined): boolean;