Skip to content

Commit 62240e5

Browse files
fulopkovacsveritem
andauthoredNov 10, 2023
fix: export the "unbound-method" rule (#286)
* fix: export the unbound-method rule * chore(tests): enable skippd tests --------- Co-authored-by: Verite Mugabo <mugaboverite@gmail.com>
1 parent b964cff commit 62240e5

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed
 

‎README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,27 @@ export default [
170170
| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Enforce that all tests are in a top-level describe | | 🌐 | | |
171171
| [valid-describe-callback](docs/rules/valid-describe-callback.md) | Enforce valid describe callback || | | |
172172
| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage || | | |
173-
| [valid-title](docs/rules/valid-title.md) | Enforce valid titles || | 🔧 | |
173+
174+
#### Requires Type Checking
175+
176+
| Name | Description | 💼 | ⚠️ | 🔧 | 💡 ||
177+
| :--------------------------------------------- | :----------------------------------------------------------- | :-- | :-- | :-- | :-- | :-- |
178+
| [unbound-method](docs/rules/unbound-method.md) | Enforce unbound methods are called with their expected scope | | | | | |
174179

175180
<!-- end auto-generated rules list -->
176181

182+
In order to use the rules powered by TypeScript type-checking, you must be using
183+
`@typescript-eslint/parser` & adjust your eslint config as outlined
184+
[here](https://typescript-eslint.io/linting/typed-linting).
185+
186+
Note that unlike the type-checking rules in `@typescript-eslint/eslint-plugin`,
187+
the rules here will fallback to doing nothing if type information is not
188+
available, meaning it's safe to include them in shared configs that could be
189+
used on JavaScript and TypeScript projects.
190+
191+
Also note that `unbound-method` depends on `@typescript-eslint/eslint-plugin`,
192+
as it extends the original `unbound-method` rule from that plugin.
193+
177194
#### Credits
178195

179196
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)

‎docs/rules/unbound-method.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- end auto-generated rule header -->
88

9-
This rule extends the base [`@typescript-eslint/unbound-method`][original-rule]
9+
This rule extends the base [`@typescript-eslint/unbound-method`][https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unbound-method.md]
1010
rule, meaning you must depend on `@typescript-eslint/eslint-plugin` for it to
1111
work. It adds support for understanding when it's ok to pass an unbound method
1212
to `expect` calls.

‎src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import preferTodo, { RULE_NAME as preferTodoName } from './rules/prefer-todo'
4747
import preferSpyOn, { RULE_NAME as preferSpyOnName } from './rules/prefer-spy-on'
4848
import preferComparisonMatcher, { RULE_NAME as preferComparisonMatcherName } from './rules/prefer-comparison-matcher'
4949
import preferToContain, { RULE_NAME as preferToContainName } from './rules/prefer-to-contain'
50-
// import unboundMethod, { RULE_NAME as unboundMethodName } from './rules/unbound-method'
50+
import unboundMethod, { RULE_NAME as unboundMethodName } from './rules/unbound-method'
5151

5252
const createConfig = (rules: Record<string, string>) => ({
5353
plugins: ['vitest'],
@@ -165,8 +165,8 @@ export default {
165165
[preferTodoName]: preferTodo,
166166
[preferSpyOnName]: preferSpyOn,
167167
[preferComparisonMatcherName]: preferComparisonMatcher,
168-
[preferToContainName]: preferToContain
169-
// [unboundMethodName]: unboundMethod
168+
[preferToContainName]: preferToContain,
169+
[unboundMethodName]: unboundMethod
170170
},
171171
configs: {
172172
all: createConfig(allRules),

‎tests/unbound-method.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ruleTester.run('unbound-method', unboundMethod, {
3232
3333
logArrowBound();
3434
logManualBind();`,
35-
skip: true
35+
skip: false
3636
}
3737
],
3838
invalid: [
@@ -48,7 +48,7 @@ ruleTester.run('unbound-method', unboundMethod, {
4848
4949
Promise.resolve().then(console.log);
5050
`,
51-
skip: true,
51+
skip: false,
5252
errors: [
5353
{
5454
line: 10,

0 commit comments

Comments
 (0)
Please sign in to comment.