-
Notifications
You must be signed in to change notification settings - Fork 889
Rule to enforce semicolons after bound class methods #3216
Comments
I agree, that it's not consistent to simply ignore bound class methods (only when they span multiple lines). |
To put it simply: I'm asking for a change that:
Why? Because we're spending too much time on the special cases with not much benefit, we're arguing too much about how to make things more complex, and I don't want to confuse my developers, |
bottom line: I think banning semicolons on bound class methods by default was a mistake. we should align with prettier and enforce them by default. I agree with @rkrisztian's last comment (#3216 (comment)). however, this would be a breaking change. so despite the inevitable conflict across rule options, I would like to add this as a new rule option ( |
By the way, the arrow function way of defining bound class methods is actually an assignment by definition (well, I think that ticket can be viewed as such). Note: I was also considering that maybe a decorator would handle the problem more nicely, but the TypeScript guys don't want to add to add such (e.g. a => So the current idea of adding |
[new-rule-option] `semicolon` adds `"strict-bound-class-methods"` Fixes: #3216
[new-rule-option] `semicolon` adds `"strict-bound-class-methods"` Fixes: palantir#3216
Bug Report
TypeScript code being linted
This example may arguably be a bit too simple, but I've got real code like this.
with
tslint.json
configuration:Actual behavior
The error I get is Unnecessary semicolon for
myFunc
, but it does not feel natural at all to to remove the semicolon from there.And if I make use of the relaxing option
"ignore-bound-class-methods"
, then there is no more enforced consistency, i.e. either way is allowed.Expected behavior
I expect my TSLint configuration to be consistent at all times. If I look at an assignment, I expect a semicolon after it, no matter if it's a variable assignment or a function assignment. Otherwise it's still not consistent.
(I would also argue that the syntax for bound class methods is terrible, because it shouldn't look like an assignment at all, but I cannot help that, they chose so. If it looks like an assignment, then it also looks weird without a semicolon.)
So this issue goes one step further from #1476, because I would like the ability to require semicolons after whatever assignment I do, for consistency.
Update: Without the semicolon in
myFunc
, IntelliJ IDEA will warn that the statement is unterminated. So it looks to me that TSLint and IDEA disagree.Additional info
The rule does not complain, if I don't break the line:
Also, I expect a semicolon here, but there is no error message:
The text was updated successfully, but these errors were encountered: