Skip to content

[member-ordering] support abstract methods #395

@mgol

Description

@mgol

Repro

{
  "rules": {
    "@typescript-eslint/member-ordering": [
      "error",
      {
        "default": [
          "public-instance-method",
          "private-instance-method"
        ]
      }
    ],
  }
}
abstract class TestClass {
  abstract bar(): void;
  foo(): void {}
}

Expected Result

No error

Actual Result

  3:3  error  Member foo should be declared before all private instance method definitions  @typescript-eslint/member-ordering

Additional Info

Abstract methods are not necessarily private methods. There are two issues here:

  1. There is no private method in this class so the error message doesn't make sense.
  2. Nowhere in the settings is the order between abstract & regular methods defined so it shouldn't be enforced.

This came up when I tried to migrate my TSLint config containing:

    "member-ordering": [
      true,
      "public-before-private",
      "static-before-instance",
      "variables-before-functions"
    ],

and I failed due to errors around abstract methods handling.

Versions

package version
@typescript-eslint/eslint-plugin 1.5.0
@typescript-eslint/parser 1.5.0
TypeScript 3.3.4000
ESLint 5.15.3
node v8.15.1
npm N/A
yarn 1.15.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions