classAssignments
Reports reassigning class declarations.
✅ This rule is included in the ts javascript presets.
Reassigning a class declaration can lead to unexpected behavior and makes code harder to understand. Class declarations are typically intended to be immutable references, and reassigning them can cause confusion about which class is being used.
Examples
Section titled “Examples”44AEc44AEco44AEc44AEco44AEc44AEcoOptions
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your project uses class reassignments as a design pattern, you might not be able to immediately enable this rule. Consider using differently-named variables instead to gain mutable references to classes.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noClassAssign - Deno:
no-class-assign - ESLint:
no-class-assign - Oxlint:
eslint/no-class-assign
