vtcode 0.136.2

A Rust-based terminal coding agent with modular architecture supporting multiple LLM providers
id: prefer-readonly
language: typescript
severity: hint
message: Use `readonly` arrays for return types that should not be mutated.
note: |
  Returning mutable arrays allows callers to modify internal state
  accidentally. Use `readonly $T[]` or `ReadonlyArray<T>` to signal
  that the array should not be mutated. This improves API contracts
  and prevents unintended side effects.
rule:
  any:
    - pattern: "function $NAME(): $T[] { $$$ }"
    - pattern: "function $NAME(): Array<$T> { $$$ }"
    - pattern: "const $NAME = (): $T[] => { $$$ }"
    - pattern: "const $NAME = (): Array<$T> => { $$$ }"
files:
  - "**/*.ts"
  - "**/*.tsx"
  - "!**/*.d.ts"