interface A {
b: {
c: string // ok
d: string // [tslint] Missing trailing comma (trailing-comma)
}
e: string // ok
}
with tslint.json configuration:
{
"rules": {
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
}
]
}
}
Requires comma at last nested type member
Should not
That's the same problem we also have with interfaces #1810. Members can end with comma, semicolon or just a line break.
Instead of finding a smart solution to guess if a trailing comma is desired, we should add config options for those cases (and maybe even more options for other cases #2286)
I recently refactored this rule in #2236. The PR is not merged yet so I could add the new options while I'm already touching the code.
Why would you _not_ want trailing commas on interfaces with "multiline": "always"? Can you provide a convincing argument that the rule needs to be customizable in that way? There's even an auto-fixer; this should be trivial to fix in your codebase.
This particular rule is about a trailing comma only, not about all separating commas. And I think it should not interfere with other style decisions, like omitting optional semicolons and commas whenever possible.
Ah, sorry I think I misread the first code snippet. This looks like a duplicate of #1810.
duplicate of #1810
In that case, closing.
Most helpful comment
Ah, sorry I think I misread the first code snippet. This looks like a duplicate of #1810.