Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

trailing-comma rule should be smarter about interfaces #1810

Closed
adidahiya opened this issue Dec 1, 2016 · 5 comments
Closed

trailing-comma rule should be smarter about interfaces #1810

adidahiya opened this issue Dec 1, 2016 · 5 comments

Comments

@adidahiya
Copy link
Contributor

adidahiya commented Dec 1, 2016

Interfaces can be written with semicolon delimiters, comma delimiters, or no delimiter at all.

Currently, TSLint will require the following trailing comma if you don't use any delimiter, and this is awkward:

interface Post {
  title: string
  age: number,
}

Proposal: enhance the rule logic to only require the trailing comma if the other fields have trailing commas.

reported by @schickling and @Zjaaspoer in #960

@IllusionMH
Copy link
Contributor

@adidahiya I'm trying to get failing tests to reproduce this issue, but still no errors on master branch

I'm altering files in test/rules/trailing-comma/multiline-always
tslint.json

{
  "rules": {
    "trailing-comma": [true, {"multiline": "always"}]
  }
}

test.ts.lint

interface Post {
  title: string
  age: number
}

interface Post2 {
  title: string,
  age: number
}

Am I missing something?

@franekp
Copy link

franekp commented Oct 5, 2017

Also, please consider cases such as:

type EventEmitterMap = {
    [K in keyof DocumentEventMap]: EventEmitter<K>
} & {
    onfoo: EventEmitter<{foo: Foo}>
    onbar: EventEmitter<{bar: Bar}>
}

@w0rp
Copy link

w0rp commented Oct 11, 2017

It would be nice to require trailing commas for array literals, object literals, function declarations and function calls, and type literals, but also require that no commas are ever used at the end of lines for interface, where the commas are redundant.

@levino
Copy link

levino commented May 3, 2018

What is the status here?

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Nov 3, 2018

This should have been fixed by #2236. 🎉

Closing for housekeeping purposes, but please do file a new issue or comment here if that's not the case!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants