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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions packages/eslint-plugin/src/rules/unbound-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ const isNotImported = (
);
};

const BASE_MESSAGE =
'Avoid referencing unbound methods which may cause unintentional scoping of `this`.';
const BASE_MESSAGE = [
`A method that is not declared with \`this: void\` may cause unintentional scoping of \`this\` when separated from its object.`,
`Consider using an arrow function or explicitly \`.bind()\`ing the method to avoid calling the method with an unintended \`this\` value. `,
].join('\n');

export default createRule<Options, MessageIds>({
name: 'unbound-method',
Expand All @@ -115,7 +117,7 @@ export default createRule<Options, MessageIds>({
},
messages: {
unbound: BASE_MESSAGE,
unboundWithoutThisAnnotation: `${BASE_MESSAGE}\nIf your function does not access \`this\`, you can annotate it with \`this: void\`, or consider using an arrow function instead.`,
unboundWithoutThisAnnotation: `${BASE_MESSAGE}\nIf a function does not access \`this\`, it can be annotated with \`this: void\`.`,
},
schema: [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading