Skip to content

Commit

Permalink
Fix TSAbstractPropertyDefinition being treated as a method instead of…
Browse files Browse the repository at this point in the history
… a property. fixes #84
  • Loading branch information
bryanrsmith committed Apr 11, 2023
1 parent 6fb838e commit 30bd9ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/rules/sort-class-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ function getMemberInfo(node, sourceCode) {
node.type === 'ClassProperty' ||
node.type === 'ClassPrivateProperty' ||
node.type === 'PropertyDefinition' ||
node.type === 'PrivateIdentifier'
node.type === 'PrivateIdentifier' ||
node.type === 'TSAbstractPropertyDefinition'
) {
type = 'property';

Expand Down
7 changes: 6 additions & 1 deletion test/rules/sort-class-members.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ ruleTester.run('sort-class-members', rule, {
options: typescriptKeywordsOptions,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: 'abstract class Foo<T> { protected abstract readonly _foo: T; public readonly bar: string; protected constructor(bar: string) {}}',
options: [{ order: ['[properties]', 'constructor', '[methods]'] }],
parser: require.resolve('@typescript-eslint/parser'),
},
],
invalid: [
{
Expand Down Expand Up @@ -919,7 +924,7 @@ ruleTester.run('sort-class-members', rule, {
output: 'class { override b; abstract a; }',
errors: [
{
message: 'Expected property b to come before method a.',
message: 'Expected property b to come before property a.',
type: 'PropertyDefinition',
},
],
Expand Down

0 comments on commit 30bd9ef

Please sign in to comment.