Skip to content

Commit 30bd9ef

Browse files
committed
Fix TSAbstractPropertyDefinition being treated as a method instead of a property. fixes #84
1 parent 6fb838e commit 30bd9ef

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/rules/sort-class-members.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ function getMemberInfo(node, sourceCode) {
192192
node.type === 'ClassProperty' ||
193193
node.type === 'ClassPrivateProperty' ||
194194
node.type === 'PropertyDefinition' ||
195-
node.type === 'PrivateIdentifier'
195+
node.type === 'PrivateIdentifier' ||
196+
node.type === 'TSAbstractPropertyDefinition'
196197
) {
197198
type = 'property';
198199

test/rules/sort-class-members.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ ruleTester.run('sort-class-members', rule, {
402402
options: typescriptKeywordsOptions,
403403
parser: require.resolve('@typescript-eslint/parser'),
404404
},
405+
{
406+
code: 'abstract class Foo<T> { protected abstract readonly _foo: T; public readonly bar: string; protected constructor(bar: string) {}}',
407+
options: [{ order: ['[properties]', 'constructor', '[methods]'] }],
408+
parser: require.resolve('@typescript-eslint/parser'),
409+
},
405410
],
406411
invalid: [
407412
{
@@ -919,7 +924,7 @@ ruleTester.run('sort-class-members', rule, {
919924
output: 'class { override b; abstract a; }',
920925
errors: [
921926
{
922-
message: 'Expected property b to come before method a.',
927+
message: 'Expected property b to come before property a.',
923928
type: 'PropertyDefinition',
924929
},
925930
],

0 commit comments

Comments
 (0)