Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unbound-method): modify rule for
jest
- Loading branch information
Showing
8 changed files
with
166 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage/ | ||
lib/ | ||
!.eslintrc.js | ||
src/rules/__tests__/fixtures/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Enforces unbound methods are called with their expected scope (`unbound-method`) | ||
|
||
## Rule Details | ||
|
||
This rule extends the base [`@typescript-eslint/unbound-method`][original-rule] | ||
rule. It adds support for understanding when it's ok to pass an unbound method | ||
to `expect` calls. | ||
|
||
See the [`@typescript-eslint` documentation][original-rule] for more details on | ||
the `unbound-method` rule. | ||
|
||
Note that while this rule requires type information to work, it will fail | ||
silently when not available allowing you to safely enable it on projects that | ||
are not using TypeScript. | ||
|
||
## How to use | ||
|
||
```json5 | ||
{ | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['test/**'], | ||
extends: ['jest'], | ||
rules: { | ||
// you should turn the original rule off *only* for test files | ||
'@typescript-eslint/unbound-method': 'off', | ||
'jest/unbound-method': 'error', | ||
}, | ||
}, | ||
], | ||
rules: { | ||
'@typescript-eslint/unbound-method': 'error', | ||
}, | ||
} | ||
``` | ||
|
||
This rule should be applied to your test files in place of the original rule, | ||
which should be applied to the rest of your codebase. | ||
|
||
## Options | ||
|
||
See [`@typescript-eslint/unbound-method`][original-rule] options. | ||
|
||
<sup>Taken with ❤️ [from `@typescript-eslint` core][original-rule]</sup> | ||
|
||
[original-rule]: | ||
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unbound-method.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters