diff --git a/packages/eslint-plugin/src/rules/unbound-method.ts b/packages/eslint-plugin/src/rules/unbound-method.ts index c95a7fd35e1..6741f4df09f 100644 --- a/packages/eslint-plugin/src/rules/unbound-method.ts +++ b/packages/eslint-plugin/src/rules/unbound-method.ts @@ -241,7 +241,7 @@ export default util.createRule({ } checkMethodAndReport( - node, + property.key, initTypes.getProperty(property.key.name), ); } diff --git a/packages/eslint-plugin/tests/rules/unbound-method.test.ts b/packages/eslint-plugin/tests/rules/unbound-method.test.ts index 2105ef41e59..49b06a4ac50 100644 --- a/packages/eslint-plugin/tests/rules/unbound-method.test.ts +++ b/packages/eslint-plugin/tests/rules/unbound-method.test.ts @@ -590,5 +590,59 @@ class OtherClass extends BaseClass { }, ], }, + { + code: ` +const values = { + a() {}, + b: () => {}, +}; + +const { a, b } = values; + `, + errors: [ + { + line: 7, + column: 9, + endColumn: 10, + messageId: 'unboundWithoutThisAnnotation', + }, + ], + }, + { + code: ` +const values = { + a() {}, + b: () => {}, +}; + +const { a: c } = values; + `, + errors: [ + { + line: 7, + column: 9, + endColumn: 10, + messageId: 'unboundWithoutThisAnnotation', + }, + ], + }, + { + code: ` +const values = { + a() {}, + b: () => {}, +}; + +const { b, a } = values; + `, + errors: [ + { + line: 7, + column: 12, + endColumn: 13, + messageId: 'unboundWithoutThisAnnotation', + }, + ], + }, ], });