-
Notifications
You must be signed in to change notification settings - Fork 889
Add ASI (automatic semicolon insertion) support to semicolon rule #363
Comments
@antoinerousseau the |
The idea was to allow coding without semicolons (and make it safe), not forcing them. |
I see, so you want a "smarter" option that only flags a warning if it actually causes any harm? |
Exactly! See discussion @ microsoft/TypeScript#2575 |
cool, i'm leaving this open for further discussion. not sure when we can get to this, but we'll consider it. thanks! |
+1 |
I think we should support this by allowing 2 options in the semicolon rule: |
|
I've been contemplating emulating JavaScript Standard Style in TSLint, and this would be a step in that direction. |
I'd really love to see an option for "always" and "never" where never will follow ASI so in cases it isn't required it will complain about it. At the moment I'm using semicolons because TSLint can only enforce semicolons and I want to have a consistent code. |
I thought I should create a PR for this, but the check the special cases I would need to know what the first token in the next node is but I can't seem to find a good way to do that. Anyone that can give a hint? |
@Pajn I think you'll want to create a scanner to read the next line. You can check out some existing code that uses |
Thanks! |
Hey all, As far as I can tell the
Is still dangerous and is not flagged when using semicolons never. |
@JakeGinnivan can you please file that as a separate issue if it still exists in the latest version? |
As explained in microsoft/TypeScript#2575
Some coders would like to forget about trailing semicolons, but in some cases it can be a source of errors that are undetected by both the TypeScript compiler and
tslint
.Example 1:
Compiles into:
Example 2:
compiles into
That would be awesome to see some warnings in these cases, e.g. by turning on a new rule 😍
The text was updated successfully, but these errors were encountered: