Skip to content

classAssignments

Reports reassigning class declarations.

✅ This rule is included in the ts untyped preset.

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.

class MyClass {}
MyClass = 0;
class Counter {}
Counter++;
class Data {}
Data = null;

This rule is not configurable.

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.