diff --git a/packages/eslint-plugin/src/rules/method-signature-style.ts b/packages/eslint-plugin/src/rules/method-signature-style.ts index d9dfbdac4bd6..39ed66cd0729 100644 --- a/packages/eslint-plugin/src/rules/method-signature-style.ts +++ b/packages/eslint-plugin/src/rules/method-signature-style.ts @@ -115,6 +115,10 @@ export default util.createRule({ return { ...(mode === 'property' && { TSMethodSignature(methodNode): void { + if (methodNode.kind !== 'method') { + return; + } + const parent = methodNode.parent; const members = parent?.type === AST_NODE_TYPES.TSInterfaceBody diff --git a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts index e82ee2e750bd..065d15c61801 100644 --- a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts +++ b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts @@ -30,12 +30,24 @@ interface Test { ` interface Test { 'f!': (/* b */ x: any /* c */) => void; +} + `, + ` +interface Test { + get f(): number; +} + `, + ` +interface Test { + set f(value: number): void; } `, 'type Test = { readonly f: (a: string) => number };', "type Test = { ['f']?: (a: boolean) => void };", 'type Test = { readonly f?: (a?: T) => T };', "type Test = { readonly ['f']?: (a: T, b: T) => T };", + 'type Test = { get f(): number };', + 'type Test = { set f(value: number): void };', ...batchedSingleLineTests({ options: ['method'], code: noFormat` @@ -44,10 +56,14 @@ interface Test { interface Test { f(a: T): T } interface Test { ['f'](a: T, b: T): T } interface Test { 'f!'(/* b */ x: any /* c */): void } + interface Test { get f(): number } + interface Test { set f(value: number): void } type Test = { readonly f(a: string): number } type Test = { ['f']?(a: boolean): void } type Test = { readonly f?(a?: T): T } type Test = { readonly ['f']?(a: T, b: T): T } + type Test = { get f(): number } + type Test = { set f(value: number): void } `, }), ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy