Support inheritance depth analysis for JavaScript / TypeScript

Rule RSPEC-110 (Inheritance tree of classes should not be too deep) is currently available for C#, C++, Objective C and Java (and possibly others).
This rule is an interesting indicator for any object oriented language / language with object oriented elements, so I think it would be sensible to implement it for TypeScript / JavaScript which have explicitly supported classes with a traditional syntax since ES6.
Of course I am aware there are developers who strongly oppose the usage of inheritance in JavaScript, which I feel works as a point in favour of implementing this rule.

2 Likes

Another point I just remembered is how JavaScript classes can be built on the fly via class expressions to produce true mixins / some sort of multiple inheritance. I personally use the approach described in this article:

I have no idea on if and how this proposal should handle these cases but I tink they are important to keep in mind.

1 Like

Hi M Gallesio,

This topic is quite old. Sorry I missed this before.

I agree this is interesting and probably an indication of bad code structure. However, I know from our data that this rule in other languages is not very acted upon, perhaps because it’s hard to break big chains of classes.

I created an issue to consider this for TypeScript and JavaScript nonetheless.

1 Like