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

The "arrow-parens" rule with "ban-single-arg-parens" confilcts with TypeScript destructuring #1955

Closed
ulfryk opened this issue Dec 31, 2016 · 1 comment

Comments

@ulfryk
Copy link

ulfryk commented Dec 31, 2016

Bug Report

  • TSLint version: 4.2.0
  • TypeScript version: 2.1.4
  • Running TSLint via: CLI

TypeScript code being linted



export class WorkflowStage {

  

  // LINES 35 - 41
  public get stageText(): string {
    return this.transition
      .flatMap(({ targetState }) => Maybe
        .fromNull(this.stages.get(targetState))
        .orElse(Some(`unformatted: ${targetState}`)))
      .orJust('fully approved');
  }

  // LINES 44 - 50
  public get pendingText(): string {
    return this.transition
      .flatMap(({ targetState }) => Maybe
        .fromNull(this.pending.get(targetState))
        .orElse(Some(`unformatted: ${targetState}`)))
      .orJust('pending full approval');
  }

  

}

with tslint.json configuration:

{
  "rulesDirectory": "./node_modules/tslint-eslint-rules/dist/rules",
  "rules": {
    "array-bracket-spacing": [true, "never"],
    "arrow-parens": [true, "ban-single-arg-parens"],
    "align": [
      true,
      "parameters",
      "statements"
    ],
    "ban": false,
    "block-spacing": true,
    "brace-style": [true, "1tbs", { "allowSingleLine": true }],
    "class-name": true,
    "callable-types": true,
    "comment-format": [true, "check-space"],
    "curly": true,
    "cyclomatic-complexity": [true, 6],
    "eofline": true,
    "forin": true,
    "indent": [true, "spaces"],
    "interface-name": [true, "always-prefix"],
    "interface-over-type-literal": true,
    "jsdoc-format": true,
    "label-position": true,
    "max-classes-per-file": [true, 3],
    "member-access": false,
    "member-ordering": [
      true,
      "public-before-private",
      "variables-before-functions"
    ],
    "new-parens": true,
    "no-angle-bracket-type-assertion": true,
    "no-any": false,
    "no-arg": true,
    "no-bitwise": true,
    "no-conditional-assignment": true,
    "no-consecutive-blank-lines": true,
    "no-console": [
      true,
      "log",
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-constant-condition": true,
    "no-construct": true,
    "no-control-regex": true,
    "no-debugger": true,
    "no-duplicate-case": true,
    "no-duplicate-variable": true,
    "no-empty": true,
    "no-empty-character-class": true,
    "no-empty-interface": false,
    "no-ex-assign": true,
    "no-extra-boolean-cast": true,
    "no-extra-semi": true,
    "no-eval": true,
    "no-inferrable-types": true,
    "no-inner-declarations": [true, "both"],
    "no-internal-module": true,
    "no-invalid-regexp": true,
    "no-irregular-whitespace": true,
    "no-multi-spaces": [
      true,
      {
        "exceptions": {
          "PropertyAssignment": false,
          "OtherException": false
        }
      }
    ],
    "no-namespace": true,
    "no-null-keyword": false,
    "no-parameter-properties": false,
    "no-reference": true,
    "no-regex-spaces": true,
    "no-require-imports": true,
    "no-shadowed-variable": true,
    "no-sparse-arrays": true,
    "no-string-literal": true,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unexpected-multiline": true,
    "no-unsafe-finally": true,
    "no-unused-expression": true,
    "no-unused-new": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "no-var-requires": true,
    "no-void-expression": false,
    "object-curly-spacing": [true, "always"],
    "object-literal-shorthand": true,
    "object-literal-sort-keys": true,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-finally",
      "check-whitespace"
    ],
    "one-variable-per-declaration": true,
    "ordered-imports": true,
    "prefer-const": true,
    "prefer-for-of": true,
    "quotemark": [
      true,
      "single",
      "jsx-double",
      "avoid-escape"
    ],
    "radix": true,
    "semicolon": [true, "always"],
    "switch-default": true,
    "ter-indent": [true, 2, {
      "SwitchCase": true,
      "FunctionDeclaration": { "parameters": 1, "body": 1 },
      "FunctionExpression": { "parameters": 1, "body": 1 }
    }],
    "ter-max-len": [
      true,
      {
        "code": 100,
        "tabWidth": 2,
        "ignoreStrings": true
      }
    ],
    "trailing-comma": [
      true,
      {
        "multiline": "always",
        "singleline": "never"
      }
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef": [true, "property-declaration"],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      },
      {
        "call-signature": "onespace",
        "index-signature": "onespace",
        "parameter": "onespace",
        "property-declaration": "onespace",
        "variable-declaration": "onespace"
      }
    ],
    "use-isnan": true,
    "valid-typeof": true,
    "valid-jsdoc": false,
    "variable-name": [
      true,
      "allow-leading-underscore",
      "allow-trailing-underscore",
      "ban-keywords"
    ],
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-module",
      "check-operator",
      "check-separator",
      "check-type",
      "check-typecast"
    ]
  }
}

Actual behavior

$ tslint --project tsconfig.tslint.json --type-check './…/workflow-stage.ts'

src/model/workflow-stage.ts[37, 17]: Parentheses are prohibited around the parameter in this single parameter arrow function
src/model/workflow-stage.ts[46, 17]: Parentheses are prohibited around the parameter in this single parameter arrow function

Expected behavior

This file shoud be linted positively without any errors.

Summary

Anywhere where we have ({ field }) => TSLint throws:

Parentheses are prohibited around the parameter in this single parameter arrow function

but { field } => is not valid TypeScript.

@ulfryk ulfryk changed the title The "arrow-parens" rule with "ban-single-arg-parens" confilcts with TypeScript The "arrow-parens" rule with "ban-single-arg-parens" confilcts with TypeScript destructuring Dec 31, 2016
@adidahiya
Copy link
Contributor

fixed by #1958

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

2 participants