Skip to content
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

fix: export the "unbound-method" rule #286

Merged
merged 2 commits into from
Nov 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,27 @@ export default [
| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Enforce that all tests are in a top-level describe | | 🌐 | | |
| [valid-describe-callback](docs/rules/valid-describe-callback.md) | Enforce valid describe callback | ✅ | | | |
| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ✅ | | | |
| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | ✅ | | 🔧 | |

#### Requires Type Checking

| Name | Description | 💼 | ⚠️ | 🔧 | 💡 | ❌ |
| :--------------------------------------------- | :----------------------------------------------------------- | :-- | :-- | :-- | :-- | :-- |
| [unbound-method](docs/rules/unbound-method.md) | Enforce unbound methods are called with their expected scope | | | | | |

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

In order to use the rules powered by TypeScript type-checking, you must be using
`@typescript-eslint/parser` & adjust your eslint config as outlined
[here](https://typescript-eslint.io/linting/typed-linting).

Note that unlike the type-checking rules in `@typescript-eslint/eslint-plugin`,
the rules here will fallback to doing nothing if type information is not
available, meaning it's safe to include them in shared configs that could be
used on JavaScript and TypeScript projects.

Also note that `unbound-method` depends on `@typescript-eslint/eslint-plugin`,
as it extends the original `unbound-method` rule from that plugin.

#### Credits

- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/unbound-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

This rule extends the base [`@typescript-eslint/unbound-method`][original-rule]
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]
rule, meaning you must depend on `@typescript-eslint/eslint-plugin` for it to
work. It adds support for understanding when it's ok to pass an unbound method
to `expect` calls.
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import preferTodo, { RULE_NAME as preferTodoName } from './rules/prefer-todo'
import preferSpyOn, { RULE_NAME as preferSpyOnName } from './rules/prefer-spy-on'
import preferComparisonMatcher, { RULE_NAME as preferComparisonMatcherName } from './rules/prefer-comparison-matcher'
import preferToContain, { RULE_NAME as preferToContainName } from './rules/prefer-to-contain'
// import unboundMethod, { RULE_NAME as unboundMethodName } from './rules/unbound-method'
import unboundMethod, { RULE_NAME as unboundMethodName } from './rules/unbound-method'

const createConfig = (rules: Record<string, string>) => ({
plugins: ['vitest'],
Expand Down Expand Up @@ -165,8 +165,8 @@ export default {
[preferTodoName]: preferTodo,
[preferSpyOnName]: preferSpyOn,
[preferComparisonMatcherName]: preferComparisonMatcher,
[preferToContainName]: preferToContain
// [unboundMethodName]: unboundMethod
[preferToContainName]: preferToContain,
[unboundMethodName]: unboundMethod
},
configs: {
all: createConfig(allRules),
Expand Down
4 changes: 2 additions & 2 deletions tests/unbound-method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ruleTester.run('unbound-method', unboundMethod, {

logArrowBound();
logManualBind();`,
skip: true
skip: false
}
],
invalid: [
Expand All @@ -48,7 +48,7 @@ ruleTester.run('unbound-method', unboundMethod, {

Promise.resolve().then(console.log);
`,
skip: true,
skip: false,
errors: [
{
line: 10,
Expand Down