We changed the behavior of the semicolon rule to allow omission of the trailing semicolon after bound class member functions:
class Foo {
public renderFoo = () => {
return null;
}
^ right here
}
I propose that we actually _ban_ semicolons at that location in TSLint 4.0. We can support the old functionality with a new option allow-bound-class-methods
.
I'm not convinced this is need for 4.0, but wouldn't hurt to get it in either. It does seem like a little bit of a minute option though, I'm not entirely convinced it's worth the added complexity
Just as a feedback item (not sure if this is the right venue?), we just stumbled across this, and were very surprised this.
I probably don't quite understand the rationale behind this, but in particular that tslint flags semicolons as unnecessary in this position (i.e. doesn't just accept leaving them out) seems confusing.
You can get the old behavior back with the ignore-bound-class-methods
option. We wanted to be a little more opinionated with the default configuration and make bound class methods look like regular class methods in most TS code.
Yeah, I figured so much. I'd have expected tslint
to out-of-the-box require that semicolon, erring more on the side of consistency, or ignoring the issue, but adding that option back in works for us.
I tried to get this to stop throwing errors in intellij
I tried removing the semicolon behind class arrow functions, then i get this warning:
I tried enabling the option like this:
But i get this result:
I tried enabling the option like this:
But then it stops checking for semicolons all together.
tslint version: 4.4.2
ts version: 2.1.5
intellij version: 2016.3
OS: windows 10 x64
For people coming to this thread looking for the correct tslint config (as I did) - the correct syntax for this would be:
"semicolon": [true, "always", "ignore-bound-class-methods"]
@popstr Yes, that's what I'm using as well.
"semicolon": [true, "always", "ignore-bound-class-methods"]
I've created #3216 because ignoring is a bad idea in terms of consistency, and the rule without the ignore-bound-class-methods
option is still buggy as I found out.
Most helpful comment
For people coming to this thread looking for the correct tslint config (as I did) - the correct syntax for this would be:
"semicolon": [true, "always", "ignore-bound-class-methods"]
See: https://palantir.github.io/tslint/rules/semicolon/