tslint-strict-oop
v1.0.1
Published
In *tslint.json*: ```json { "rulesDirectory": "node_modules/tslint-strict-oop/dist", "rules": { "one-class-per-file": true, "strict-unions": true, "class-filename": true, "only-classes-on-top": true }, } ```
Downloads
1
Readme
tslint-strict-oop
Usage
In tslint.json:
{
"rulesDirectory": "node_modules/tslint-strict-oop/dist",
"rules": {
"one-class-per-file": true,
"strict-unions": true,
"class-filename": true,
"only-classes-on-top": true
},
}
Rules
one-class-per-file
- File must contain only one class declaration.
only-classes-on-top
- Only classes are allowed to be declared in the global scope.
class-filename
- File name must match the name of the class it contains.
strict-unions
- Explicit or implicit unions can contain only one type plus null and undefined.
This is not allowed:
class Sample1 {
someMethod() { // two types union for return type: boolean | string
if (Math.random() > 0.5) {
return true; // type one
} else {
return 'this is true'; // type two
}
}
}