8000 docs(eslint-plugin): [unbound-method] reference eslint-plugin-jests e… · omril1/typescript-eslint@eda9157 · GitHub
[go: up one dir, main page]

Skip to content

Commit eda9157

Browse files
authored
docs(eslint-plugin): [unbound-method] reference eslint-plugin-jests extension rule (typescript-eslint#3232)
Relates to typescript-eslint#2951
1 parent d0d7186 commit eda9157

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/eslint-plugin/docs/rules/unbound-method.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Class functions don't preserve the class scope when passed as standalone variabl
66

77
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.
88

9+
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.
10+
911
## Rule Details
1012

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

106108
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.
107109

110+
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).
111+
108112
## Related To
109113

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

0 commit comments

Comments
 (0)
0