Tslint: tsc & trailing-comma clash with spread operator

Created on 14 Jun 2018  路  2Comments  路  Source: palantir/tslint

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.

Most helpful comment

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.

All 2 comments

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.

Merged

Was this page helpful?
0 / 5 - 0 ratings