tslint-eslint-rules
tslint-eslint-rules copied to clipboard
brace-style doesn't work for classes
trafficstars
The rule brace-style does not affect the braces around the class body – see the fixed bug at eslint/eslint#7608.
How to reproduce
/* tslint brace-style: ["error", "allman"] */
class Foo {
}
Expected
- tslint throws an error
- if I change the code to Allman, it should be ok
Actual
- no error was thrown
- if I change the code to Allman, tslint throws an error
I haven't done a PR because I couldn't find the Typescript API specs, but it should be relatively easy to fix. If I understand it correctly, we need to add something like this to the rule definition:
visitClassDeclaration(node: ts.ClassDeclaration) {
let block = somehowGetTheBlock(node);
this.visitBlock(block);
}
visitClassExpression(node: ts.ClassExpression) {
let block = somehowGetTheBlock(node);
this.visitBlock(block);
}