-
Notifications
You must be signed in to change notification settings - Fork 885
Options to force trailing comma on interfaces declaration #960
Comments
The Seems like a reasonable feature request though - I've tagged it as such. |
aren't fields in an interface supposed to end with a trailing semicolon? |
I had thought so also, but the Interface grammar allows for semicolons or commas. |
See #1233 for discussion on this issue. The "ignore-interfaces" option for the |
Since version 4.0 this seems to be always enforced when using "rules": {
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
},
"ignore-interfaces"
]
} Unfortunately this change seemed to have broke all of our build once we upgraded to v4. |
Maybe @jkillian knows something about this? |
@schickling the |
This is the way how we write interfaces: interface Post {
title: string
age: number
} |
We're writing our interfaces the exact same way as @schickling (basically interfaces without semicolons). Right now Tslint is adding trailing commas to the last row like so:
which is a bit undesirable... :) I'm not sure what the best strategy is to resolve this, but probably the trailing comma's should only be added if the other rows in the interface already have a comma? |
Yeah that makes sense @Zjaaspoer; filed #1810 for you and @schickling |
great thanks! |
We use commas to separate interface properties, and I'd really like an option to enforce this. |
This affects this case as well: fs.writeFile(
ContentsJSONFile,
JSON.stringify(ContentsJSON, null, 2),
(err) => {
if (err) {
throw new Error(err.message)
}
console.log(chalk.green(`Wrote \`Contents.json\` file for ${set.name}!`))
} // <!-- Missing trailing comma (trailing-comma) tslint(1)
) |
I want to force trailing comma on interface declaration:
Is there any option to do this?
The text was updated successfully, but these errors were encountered: