tslint-no-subclass
v0.2.1
Published
TSLint rule to prevent class inheritance
Downloads
3
Maintainers
Readme
tslint-no-subclass
TSLint rule to prevent class inheritance.
Install
npm install --save-dev tslint-no-subclass
Usage
Add the following to tslint.json
:
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": true
}
}
Allow inheritance for specific classes
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": [true, "Foo", "Bar"]
}
}
Example
Config:
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": [true, "Allow"]
}
}
Source code:
class Allow {}
class Valid extends Allow {} // Valid because "Allow" was added to rule exceptions
class Disallow {}
class Invalid extends Disallow {} // Error: Subclass not allowed