Skip to content

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.

class
class MyClass
MyClass
{}
class MyClass
MyClass
= 0;
class
class Counter
Counter
{}
class Counter
Counter
++;
class
class Data
Data
{}
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 ❤️‍🔥 around the world by the Flint team and contributors.