# prefer-to-be-falsy

Rule `vitest/prefer-to-be-falsy`. Enforce using toBeFalsy()

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1803 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/prefer-to-be-falsy` | no | safe | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md) |
| Oxlint | `vitest/prefer-to-be-falsy` | no | safe | plugin `vitest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.html) |

## Code examples

### Incorrect: the rule reports this

```js
expect(foo).toBe(false)
expectTypeOf(foo).toBe(false)
```

### Correct: the rule accepts this

```js
expect(foo).toBeFalsy()
expectTypeOf(foo).toBeFalsy()
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import vitest from "@vitest/eslint-plugin";

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/prefer-to-be-falsy": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/prefer-to-be-falsy": "error"
  }
}
```

## Related rules

- [vitest/prefer-to-be](https://lintradar.dev/rules/vitest/prefer-to-be.md): Enforce using toBe()
- [vitest/prefer-to-be-object](https://lintradar.dev/rules/vitest/prefer-to-be-object.md): Enforce using toBeObject()
- [vitest/prefer-strict-boolean-matchers](https://lintradar.dev/rules/vitest/prefer-strict-boolean-matchers.md): Enforce using `toBe(true)` and `toBe(false)` over matchers that coerce types to boolean
- [vitest/prefer-to-be-truthy](https://lintradar.dev/rules/vitest/prefer-to-be-truthy.md): Enforce using `toBeTruthy`
- [vitest/prefer-snapshot-hint](https://lintradar.dev/rules/vitest/prefer-snapshot-hint.md): Enforce including a hint with external snapshots
- [vitest/prefer-todo](https://lintradar.dev/rules/vitest/prefer-todo.md): Enforce using `test.todo`

---

Web page: https://lintradar.dev/rules/vitest/prefer-to-be-falsy. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
