Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nunof07/tslint-no-subclass
TSLint rule to prevent class inheritance
https://github.com/nunof07/tslint-no-subclass
tslint tslint-rules typescript
Last synced: 9 days ago
JSON representation
TSLint rule to prevent class inheritance
- Host: GitHub
- URL: https://github.com/nunof07/tslint-no-subclass
- Owner: nunof07
- License: mit
- Created: 2018-01-02T21:14:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-03T22:40:46.000Z (almost 7 years ago)
- Last Synced: 2024-10-06T22:21:21.596Z (about 1 month ago)
- Topics: tslint, tslint-rules, typescript
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tslint-no-subclass
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![NPM](https://nodei.co/npm/tslint-no-subclass.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/tslint-no-subclass/)
TSLint rule to prevent class inheritance.
## Install
```bash
npm install --save-dev tslint-no-subclass
```## Usage
Add the following to `tslint.json`:
```json
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": true
}
}
```### Allow inheritance for specific classes
```json
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": [true, "Foo", "Bar"]
}
}
```## Example
Config:
```json
{
"extends": [
"tslint-no-subclass"
],
"rules": {
"no-subclass": [true, "Allow"]
}
}
```Source code:
```typescript
class Allow {}class Valid extends Allow {} // Valid because "Allow" was added to rule exceptions
class Disallow {}
class Invalid extends Disallow {} // Error: Subclass not allowed
```