Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(eslint-plugin): specify which method is unbound and added test c…
…ase (#6281)

* Unbound-method test case added and specified error location

* test case update
  • Loading branch information
cparros committed Dec 30, 2022
1 parent 3f8d105 commit cf3ffdd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/unbound-method.ts
Expand Up @@ -241,7 +241,7 @@ export default util.createRule<Options, MessageIds>({
}

checkMethodAndReport(
node,
property.key,
initTypes.getProperty(property.key.name),
);
}
Expand Down
54 changes: 54 additions & 0 deletions packages/eslint-plugin/tests/rules/unbound-method.test.ts
Expand Up @@ -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',
},
],
},
],
});

0 comments on commit cf3ffdd

Please sign in to comment.