Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): [member-ordering] ignore method overloading#10536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JoshuaKGoldberg merged 2 commits intotypescript-eslint:mainfromyeonjuan:fix/2409
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionspackages/eslint-plugin/src/rules/member-ordering.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -548,6 +548,13 @@ function getRank(
): number {
const type = getNodeType(node);

if (
node.type === AST_NODE_TYPES.MethodDefinition &&
node.value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression
) {
return -1;
}

if (type == null) {
// shouldn't happen but just in case, put it on the end
return orderConfig.length - 1;
Expand Down
77 changes: 73 additions & 4 deletionspackages/eslint-plugin/tests/rules/member-ordering.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2148,6 +2148,52 @@ interface Foo {
},
],
},
{
code: `
class Foo {
public baz(): void;
@Decorator() public baz() {}

@Decorator() bar() {}
}
`,
options: [
{
default: ['public-decorated-method', 'public-instance-method'],
},
],
},
{
code: `
class Foo {
public bar(): void;
@Decorator() bar() {}

public baz(): void;
@Decorator() public baz() {}
}
`,
options: [
{
default: ['public-instance-method', 'public-decorated-method'],
},
],
},
{
code: `
class Foo {
@Decorator() bar() {}

public baz(): void;
@Decorator() public baz() {}
}
`,
options: [
{
default: ['public-instance-method', 'public-decorated-method'],
},
],
},
],
invalid: [
{
Expand DownExpand Up@@ -4439,7 +4485,7 @@ abstract class Foo {
class Foo {
C: number;
[A: string]: number;
public static D(): {};
public static D() {}
static [B: string]: number;
}
`,
Expand DownExpand Up@@ -4471,7 +4517,7 @@ class Foo {
abstract class Foo {
abstract B: string;
abstract A(): void;
public C(): {};
public C() {}
Copy link
ContributorAuthor

@yeonjuanyeonjuanDec 22, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is probably a typo. The following TS error occurs because{} is a return type
Function implementation is missing or not immediately following the declaration.

JoshuaKGoldberg reacted with thumbs up emoji
}
`,
errors: [
Expand DownExpand Up@@ -4623,7 +4669,7 @@ class Foo {
code: `
class Foo {
A: string;
private C(): void;
private C() {}
constructor() {}
@Dec() private B: string;
set D() {}
Expand DownExpand Up@@ -4975,7 +5021,7 @@ class Foo {
code: `
class Foo {
A: string;
private C(): void;
private C() {}
constructor() {}
private readonly B: string;
set D() {}
Expand DownExpand Up@@ -5267,6 +5313,29 @@ interface Foo {
},
],
},
{
code: `
class Foo {
static foo() {}
foo(): void;
foo() {}
}
`,
errors: [
{
column: 3,
data: {
name: 'foo',
rank: 'public static method',
},
line: 5,
messageId: 'incorrectGroupOrder',
},
],
options: [
{ default: ['public-instance-method', 'public-static-method'] },
],
},
],
};

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp