Skip to content

Commit

Permalink
fix(eslint-plugin): [member-ordering] also TSMethodSignature can be g…
Browse files Browse the repository at this point in the history
…et/set (#9193)

fix(eslint-plugin): [member-ordering] TSMethodSignature can be get/set too
  • Loading branch information
Josh-Cena committed Jun 1, 2024
1 parent 52bfb1f commit a9dd526
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,8 @@ function getNodeType(node: Member): MemberKind | null {
switch (node.type) {
case AST_NODE_TYPES.TSAbstractMethodDefinition:
case AST_NODE_TYPES.MethodDefinition:
return node.kind;
case AST_NODE_TYPES.TSMethodSignature:
return 'method';
return node.kind;
case AST_NODE_TYPES.TSCallSignatureDeclaration:
return 'call-signature';
case AST_NODE_TYPES.TSConstructSignatureDeclaration:
Expand Down
74 changes: 74 additions & 0 deletions packages/eslint-plugin/tests/rules/member-ordering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,32 @@ class Foo {
},
],
},
{
code: `
interface Foo {
get x(): number;
y(): void;
}
`,
options: [
{
default: ['get', 'method'],
},
],
},
{
code: `
interface Foo {
y(): void;
get x(): number;
}
`,
options: [
{
default: ['method', 'get'],
},
],
},
],
invalid: [
{
Expand Down Expand Up @@ -5193,6 +5219,54 @@ class Foo {
},
],
},
{
code: `
interface Foo {
y(): void;
get x(): number;
}
`,
options: [
{
default: ['get', 'method'],
},
],
errors: [
{
messageId: 'incorrectGroupOrder',
data: {
name: 'x',
rank: 'method',
},
line: 4,
column: 3,
},
],
},
{
code: `
interface Foo {
get x(): number;
y(): void;
}
`,
options: [
{
default: ['method', 'get'],
},
],
errors: [
{
messageId: 'incorrectGroupOrder',
data: {
name: 'y',
rank: 'get',
},
line: 4,
column: 3,
},
],
},
],
};

Expand Down

0 comments on commit a9dd526

Please sign in to comment.