Skip to content

v0.7.11

@amery amery tagged this 02 Jul 20:05
Allow common loop variables in unicorn/prevent-abbreviations rule

- **unicorn/prevent-abbreviations**: Allow `i`, `j`, `k` as idiomatic variable names
  - These are universally recognized as loop counters and array indices
  - Prevents unnecessary renaming in common patterns like:
    - `for (let i = 0; i < array.length; i++)`
    - `array.forEach((item, i, arr) => ...)`
    - Matrix operations with `i`, `j`, `k` indices
  - Added comprehensive tests for the new configuration

- Modified `src/configs/unicorn.ts` to include `j` and `k` alongside existing `i`
- Added to both `allowList` (permits usage) and `omitReplacementList` (prevents suggestions)
- Created new test suite in `src/configs/__tests__/unicorn.test.ts` to verify:
  - Rule configuration structure
  - All three variables are allowed
  - No replacement suggestions are made for these variables
  - Other common abbreviations remain allowed

- Reduces friction when writing loops and array operations
- Maintains consistency with mathematical and programming conventions
- Eliminates noisy linting errors for these standard variable names

This patch release improves developer ergonomics without compromising code quality standards.
Assets 2
Loading