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

tsc & trailing-comma clash with spread operator #3960

Closed
dsatfire opened this issue Jun 14, 2018 · 2 comments
Closed

tsc & trailing-comma clash with spread operator #3960

dsatfire opened this issue Jun 14, 2018 · 2 comments

Comments

@dsatfire
Copy link

Bug Report

  • TSLint version: 5.10.0
  • TypeScript version: 2.8.3
  • Running TSLint via: tslint-loader (webpack)

TypeScript code being linted

// code snippet
const {
    var1,
    var2,
    var3,
    var4,
    var5,
    var6,
    var7,
    ...restProps
} = this.props;

with tslint.json configuration:

{
    "extends": "tslint:recommended",
    "rules": {
        "interface-name": [ true, "never-prefix"]
    }
}

Actual behavior

Rule tailling-comma is violated.

Missing trailing comma

However, tsc will throw if comma is there.

TS1013: A rest parameter or binding pattern may not have a trailing comma.

Expected behavior

tslint recognizes the spread operator in use and does not mark rule as violated.

@bschlenk
Copy link
Contributor

I was looking at this and it turns out you just have to add an extra option "esSpecCompliant".

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

This should probably be a part of the tslint:recommended set of rules though.

@johnwiseheart
Copy link
Contributor

Merged

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

No branches or pull requests

3 participants