Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf3ffdd

Browse files
authored
feat(eslint-plugin): specify which method is unbound and added test case (typescript-eslint#6281)
* Unbound-method test case added and specified error location * test case update
1 parent 3f8d105 commit cf3ffdd

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

packages/eslint-plugin/src/rules/unbound-method.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export default util.createRule<Options, MessageIds>({
241241
}
242242

243243
checkMethodAndReport(
244-
node,
244+
property.key,
245245
initTypes.getProperty(property.key.name),
246246
);
247247
}

packages/eslint-plugin/tests/rules/unbound-method.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,5 +590,59 @@ class OtherClass extends BaseClass {
590590
},
591591
],
592592
},
593+
{
594+
code: `
595+
const values = {
596+
a() {},
597+
b: () => {},
598+
};
599+
600+
const { a, b } = values;
601+
`,
602+
errors: [
603+
{
604+
line: 7,
605+
column: 9,
606+
endColumn: 10,
607+
messageId: 'unboundWithoutThisAnnotation',
608+
},
609+
],
610+
},
611+
{
612+
code: `
613+
const values = {
614+
a() {},
615+
b: () => {},
616+
};
617+
618+
const { a: c } = values;
619+
`,
620+
errors: [
621+
{
622+
line: 7,
623+
column: 9,
624+
endColumn: 10,
625+
messageId: 'unboundWithoutThisAnnotation',
626+
},
627+
],
628+
},
629+
{
630+
code: `
631+
const values = {
632+
a() {},
633+
b: () => {},
634+
};
635+
636+
const { b, a } = values;
637+
`,
638+
errors: [
639+
{
640+
line: 7,
641+
column: 12,
642+
endColumn: 13,
643+
messageId: 'unboundWithoutThisAnnotation',
644+
},
645+
],
646+
},
593647
],
594648
});

0 commit comments

Comments
 (0)