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

eslint/tslint behavior difference with comma-dangle #1122

Closed
danvk opened this issue Apr 12, 2016 · 4 comments
Closed

eslint/tslint behavior difference with comma-dangle #1122

danvk opened this issue Apr 12, 2016 · 4 comments

Comments

@danvk
Copy link
Contributor

danvk commented Apr 12, 2016

Bug Report (delete this for feature requests)

  • TSLint version: 3.7.3
  • TypeScript version: 1.8.9
  • Running TSLint via: CLI

TypeScript code being linted

function f() {
  return [1, {
    a: 2,
    b: 2,
  }];
}

with tslint.json:

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

Actual behavior

repro.ts[5, 3]: missing trailing comma

Expected behavior

(no error)

When I run this code through eslint with the following config:

{
  "rules": {
    'comma-dangle': [2, 'always-multiline'],
  }
}

it passes. But tslint wants me to write this instead:

function f() {
  return [1, {
    a: 2,
    b: 2,
  },];  // <---
}

which I don't think makes much sense. In fact, eslint complains about it:

repro.ts
  5:4  error  Unexpected trailing comma  comma-dangle
@unional
Copy link
Contributor

unional commented Apr 16, 2016

Exactly the issue I have with this: https://github.com/palantir/tslint/blob/3.7.4/src/configuration.ts#L52

@adidahiya
Copy link
Contributor

fair enough. we'd be open to a PR that adjusts the behavior here to align with ESLint.

@jkillian
Copy link
Contributor

jkillian commented Apr 20, 2016

Hi all, please see #1145 and check if it does what you need (it should fix this).

@unional
Copy link
Contributor

unional commented Apr 20, 2016

Interesting. and 👍

jkillian added a commit that referenced this issue Apr 21, 2016
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

4 participants