8000 docs(eslint-plugin): [unbound-method] reference eslint-plugin-jests extension rule by G-Rath · Pull Request #3232 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

docs(eslint-plugin): [unbound-method] reference eslint-plugin-jests extension rule #3232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2021
Merged
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
4 changes: 4 additions & 0 deletions packages/eslint-plugin/docs/rules/unbound-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Class functions don't preserve the class scope when passed as standalone variabl

If your function does not access `this`, [you can annotate it with `this: void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function), or consider using an arrow function instead.

If you're working with `jest`, you can use [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md) to lint your test files, which knows when it's ok to pass an unbound method to `expect` calls.

## Rule Details

Examples of **incorrect** code for this rule
Expand Down Expand Up @@ -105,6 +107,8 @@ log();

If your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method, you can disable this rule.

If you're wanting to use `toBeCalled` and similar matches in `jest` tests, you can disable this rule for your test files in favor of [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md).

## Related To

- TSLint: [no-unbound-method](https://palantir.github.io/tslint/rules/no-unbound-method/)
0