# eslint-plugin-chai-friendly

> This plugin makes 'no-unused-expressions' rule friendly towards chai expect statements.

Latest version **1.2.1** (published 2026-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-chai-friendly
pnpm add eslint-plugin-chai-friendly
yarn add eslint-plugin-chai-friendly
bun add eslint-plugin-chai-friendly
```

## Health

**Score 50/100 (C)** — status: active.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2026-06-15 |
| First published | 2016-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 57 |
| Author | Ihor Diachenko |
| Maintainers | ihor.diachenko |
| Keywords | eslint, eslintplugin, eslint-plugin, chai, lint |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-chai-friendly
- Repository: https://github.com/ihordiachenko/eslint-plugin-chai-friendly
- Homepage: https://github.com/ihordiachenko/eslint-plugin-chai-friendly#readme
- Issues: https://github.com/ihordiachenko/eslint-plugin-chai-friendly/issues
- npm.io page: https://npm.io/package/eslint-plugin-chai-friendly

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2026-06-15
- 1.2.0 — 2026-04-06
- 1.1.1 — 2026-03-17
- 1.1.0 — 2025-06-11
- 1.0.1 — 2024-07-28
- 1.0.0 — 2024-06-04
- 0.8.0 — 2024-05-23
- 0.7.4 — 2024-01-09
- 0.7.3 — 2024-01-08
- 0.7.2 — 2021-08-01
- 0.7.1 — 2021-05-09
- 0.7.0 — 2021-05-09
- 0.6.0 — 2020-04-24
- 0.5.0 — 2019-10-27
- 0.4.1 — 2017-12-05
- … 7 more at https://npm.io/package/eslint-plugin-chai-friendly/versions

## README

# eslint-plugin-chai-friendly

[![npm](https://img.shields.io/npm/v/eslint-plugin-chai-friendly.svg)](https://www.npmjs.com/package/eslint-plugin-chai-friendly) [![npm](https://img.shields.io/npm/dm/eslint-plugin-chai-friendly)](https://www.npmjs.com/package/eslint-plugin-chai-friendly)

This plugin overrides `no-unused-expressions` to make it friendly towards chai `expect` and `should` statements.

```javascript
// this
expect(foo).to.be.true;
foo.should.be.true;

// instead of this
expect(foo).to.be.true; // eslint-disable-line no-unused-expressions
foo.should.be.true; // eslint-disable-line no-unused-expressions
```

## Installation

You'll first need to install [ESLint](http://eslint.org):

```bash
npm i eslint --save-dev
```

Next, install `eslint-plugin-chai-friendly`:

```bash
npm install eslint-plugin-chai-friendly --save-dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-chai-friendly` globally.

## Usage

Add `chai-friendly` to the plugins section of your  ESLint configuration file. Then disable original `no-unused-expressions` rule and configure chai-friendly replacement under the rules section.

ESLint 9 flat config format:

```js
import pluginChaiFriendly from 'eslint-plugin-chai-friendly';

export default {
    plugins: {'chai-friendly': pluginChaiFriendly},
    rules: {
        "no-unused-expressions": "off", // disable original rule
        "chai-friendly/no-unused-expressions": "error"
    },
};
```

Legacy `.eslintrc` format:

```json
{
    "plugins": [
        "chai-friendly" // you can omit the eslint-plugin- prefix
    ],
    "rules": {
        "no-unused-expressions": 0, // disable original rule
        "chai-friendly/no-unused-expressions": 2
    }
}
```

If you don't need to tweak the above rule settings, you can instead
extend the provided recommended configuration.

ESLint 9 flat config format:

```js
const pluginChaiFriendly = require("eslint-plugin-chai-friendly");

module.exports = [
    pluginChaiFriendly.configs.recommendedFlat,
    // other configurations
]
```

Legacy `.eslintrc` format:


```json
{
  "extends": ["plugin:chai-friendly/recommended"]
}
```

## Options

This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

- `allowShortCircuit` set to `true` will allow you to use short circuit evaluations in your expressions (Default: `false`).
- `allowTernary` set to `true` will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: `false`).
- `allowTaggedTemplates` set to `true` will enable you to use tagged template literals in your expressions (Default: `false`).
- `enforceForJSX` set to `true` will flag unused JSX element expressions (Default: `false`).

These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

More info in the original rule's [docs](http://eslint.org/docs/rules/no-unused-expressions#options).

## Supported Rules

- `chai-friendly/no-unused-expressions`

## TypeScript Compatibility

If you're using TypeScript with `@typescript-eslint`, you need to disable both the original ESLint rule and the TypeScript ESLint version:

ESLint 9 flat config format:

```js
import pluginChaiFriendly from 'eslint-plugin-chai-friendly';

export default {
    plugins: {'chai-friendly': pluginChaiFriendly},
    rules: {
        "no-unused-expressions": "off", // disable original rule
        "@typescript-eslint/no-unused-expressions": "off", // disable TypeScript ESLint version
        "chai-friendly/no-unused-expressions": "error"
    },
};
```

Legacy `.eslintrc` format:

```json
{
    "plugins": [
        "chai-friendly"
    ],
    "rules": {
        "no-unused-expressions": 0, // disable original rule
        "@typescript-eslint/no-unused-expressions": 0, // disable TypeScript ESLint version
        "chai-friendly/no-unused-expressions": 2
    }
}
```

Note that if you use the recommended configuration, both rules will be disabled automatically.

---
_Source: https://npm.io/package/eslint-plugin-chai-friendly · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
