Skip to content

Auto-Fix

Some lint rules provide structured fixes that can be applied automatically.

Terminal window
chant lint --fix

When --fix is not set, fixable diagnostics are annotated with [fixable] in text output:

src/storage.ts:3:5 warning [COR005] [fixable] Exported names should be camelCase

--fix runs once and exits. In watch mode, fixes are applied on each re-run.

RuleFix KindDescription
COR005renameRenames PascalCase exports to camelCase
COR012deleteRemoves redundant import type line
COR015TextEditRemoves redundant as Value<...> cast
COR017TextEditInserts or replaces Composite name to match variable
// Before
export const MyBucket = new _.Resource({ ... });
// After fix
export const myBucket = new _.Resource({ ... });
  1. Diagnostics with available fixes are collected during the lint pass
  2. Fixes are sorted in reverse source order (bottom-to-top) to preserve positions
  3. Overlapping fixes are skipped to avoid conflicts
  4. Each fix is applied to the source text and the file is written back
  5. Lint is re-run to show remaining unfixable issues