diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 0b60f754d2d..23c2742502b 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -182,6 +182,9 @@ export default util.createRule({ node: TSESTree.ClassElement | TSESTree.TypeElement, ): string | null { // TODO: add missing TSCallSignatureDeclaration + // TODO: add missing TSIndexSignature + // TODO: add missing TSAbstractClassProperty + // TODO: add missing TSAbstractMethodDefinition switch (node.type) { case AST_NODE_TYPES.MethodDefinition: return node.kind; @@ -258,7 +261,7 @@ export default util.createRule({ const type = getNodeType(node); if (type === null) { // shouldn't happen but just in case, put it on the end - return Number.MAX_SAFE_INTEGER; + return order.length - 1; } const scope = 'static' in node && node.static ? 'static' : 'instance'; diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 91495e728e6..81e67999b8d 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -1211,6 +1211,12 @@ type Foo = { `, options: [{ default: ['method', 'constructor', 'field'] }], }, + ` +abstract class Foo { + B: string; + abstract A: () => {} +} + `, ], invalid: [ { @@ -3310,5 +3316,24 @@ type Foo = { }, ], }, + { + code: ` +abstract class Foo { + abstract A: () => {} + B: string; +} + `, + errors: [ + { + messageId: 'incorrectOrder', + data: { + name: 'B', + rank: 'method', + }, + line: 4, + column: 5, + }, + ], + }, ], });