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

Getters and setters do not respect member ordering #4098

Closed
kaba2 opened this issue Aug 4, 2018 · 3 comments
Closed

Getters and setters do not respect member ordering #4098

kaba2 opened this issue Aug 4, 2018 · 3 comments

Comments

@kaba2
Copy link

kaba2 commented Aug 4, 2018

Bug Report

  • TSLint version: 1.0.34 (first entry in changelog)
  • TypeScript version: 2.9.2
  • Running TSLint via: VSCode

TypeScript code being linted

export default class A {
  protected get protectedInstanceGetter() {
    return 0
  }
  protected set protectedInstanceSetter(x: number) {}
  private get privateInstanceGetter() {
    return 0
  }
  private set privateInstanceSetter(x: number) {}
  public static staticField: number
  public static staticMethod() {}
  public constructor() {}
}

with tslint.json configuration:

{
  "defaultSeverity": "error",
  "extends":  ["tslint:recommended", "tslint-config-prettier"],
  "linterOptions": {
    "exclude": [
      "**/*.js"
    ]
  },
  "rulesDirectory": ["tslint-plugin-prettier"],
  "rules": {
    "prettier": true,
    "only-arrow-functions": false,
    "no-bitwise": false,

    "comment-format": [
      true, 
      "check-space"
      // Disabled: 
      // "check-lowercase"
      // "check-uppercase"
    ],
    // Lambdas of the form x => x * x
    "arrow-parens": [true, "ban-single-arg-parens"],
    "cyclomatic-complexity": [true, 666],
    "indent": [true, "spaces", 2],
    "interface-name": [true, "never-prefix"],
    "max-classes-per-file": [true, 1],
    "max-file-line-count": [true, 6666],
    "max-line-length": [true, 666],
    "member-ordering": [true, {
      "order": [
        "public-static-field",
        "public-static-method",
        "public-instance-field",
        "public-constructor",
        "public-instance-method",
        "protected-static-field",
        "protected-static-method",
        "protected-instance-field",
        "protected-constructor",
        "protected-instance-method",
        "private-static-field",
        "private-static-method",
        "private-instance-field",
        "private-constructor",
        "private-instance-method"
      ]
    }],
    "no-debugger": false,
    "no-console": false,
    "no-empty": false,
    "object-literal-sort-keys" : false,
    "quotemark": [true, "single", "avoid-escape", "avoid-template"],
    // semicolon rule conflicts with prettier
    "semicolon": false,
    "trailing-comma": [true, "never"],
    "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],
    "ordered-imports": false
  }
}

Actual behavior

Some linter warnings, but none concerning the ordering of members. The getters and setters do not seem to be checked by tslint.

Expected behavior

The ordering of members should be public, protected, private, as specified by the configuration file. There should be linter warnings concerning wrong positions of getters and setters.

@giladgray
Copy link

@kaba2 are you actually using tslint 1.0.34?? if so, please upgrade to the latest 5.x and try again.

pretty sure this was fixed in #3984

@NaridaL
Copy link
Contributor

NaridaL commented Aug 18, 2018

@giladgray #3984 does fix that, but it hasn't been merged. Can you take a look? If necessary I can rebase it...

@JoshuaKGoldberg
Copy link
Contributor

Duplicate of #3965.

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