Registry / testing / eslint-plugin-chai-expect

eslint-plugin-chai-expect

JSON →
library4.1.0jsnpmunverified

An ESLint plugin that checks for common chai.js expect() mistakes. Current stable version is 4.1.0, released April 2026. Supports ESLint 2.x to 10.x and Node.js 20+. Key differentiators: includes auto-fix for some rules, provides both legacy and flat config presets, and has configurable rules for custom chai extensions. Default recommended rules cover missing assertions, inner comparisons/literals, terminating properties used as functions, and uncalled assertion methods.

npm install eslint-plugin-chai-expect
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-CHAI
E
eslint-plugin-chai-expect
testingjavascriptv4.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin (default)
✓ import chaiExpectPlugin from 'eslint-plugin-chai-expect'
✗ const chaiExpectPlugin = require('eslint-plugin-chai-expect')
Module is ESM-only since v4. CommonJS require() is not supported for the default export. For flat config, import as default.
rules
✓ import { rules } from 'eslint-plugin-chai-expect'
✗ const { rules } = require('eslint-plugin-chai-expect')
Named export for rules. Also ESM-only since v4.
configs['recommended']
✓ chaiExpectPlugin.configs.recommended
Legacy config preset for .eslintrc. Not available as a direct named import; access via plugin object.
configs['recommended-flat']
✓ chaiExpectPlugin.configs['recommended-flat']
Flat config preset for eslint.config.js. Available in v4+. Access via plugin object.

Shows how to set up the plugin with both flat and legacy config, including recommended presets and custom rules.

// Install: npm install --save-dev eslint-plugin-chai-expect // eslint.config.js (flat config, ESLint >=9) import chaiExpectPlugin from 'eslint-plugin-chai-expect'; export default [ chaiExpectPlugin.configs['recommended-flat'], { rules: { 'chai-expect/no-inner-compare': 'error', 'chai-expect/missing-assertion': 'error' } } ]; // .eslintrc.json (legacy config, ESLint <9) // { // "plugins": ["chai-expect"], // "extends": ["plugin:chai-expect/recommended"], // "rules": { // "chai-expect/no-inner-compare": 2 // } // }
Debug
Known issues
breakingDropped support for Node.js < 20 in v4.0.0
fix
Upgrade Node.js to version 20 or higher.
affects: >=4.0.0
breakingPackage is ESM-only since v4; no CommonJS require() for default import
fix
Use import syntax (e.g., import chaiExpectPlugin from 'eslint-plugin-chai-expect') or switch to dynamic import().
affects: >=4.0.0
deprecatedrecommended config is legacy; use recommended-flat for flat config
fix
Use chaiExpectPlugin.configs['recommended-flat'] in eslint.config.js instead of .eslintrc.
affects: >=4.0.0
gotchaThe terminating-properties rule may false-positive on non-terminal chaining if custom properties are not configured
fix
If using chai extensions like chai-http, add their terminating properties to the rule options: { properties: ['headers', 'html', 'ip', 'json', 'redirect', 'text'] }.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-plugin-chai-expect/index.js from /path/to/file.js not supported.
Using CommonJS require() to load the ESM-only plugin in v4+.
fix
Use import syntax or dynamic import(). Also ensure your project is configured as ESM (type: 'module' in package.json) or use a compatible import() call.
Configuration for rule "chai-expect/missing-assertion" is invalid: Value "2" is invalid.
Using numeric severity (2) in flat config; flat config expects string severity ("error" or "warn").
fix
Use "error" instead of 2, e.g., { "chai-expect/missing-assertion": "error" }.
ESLint couldn't find the plugin "chai-expect".
Plugin not installed or missing in plugins section; for flat config, you must import and add to plugins object.
fix
Run npm install --save-dev eslint-plugin-chai-expect, then add the plugin to plugins in config (import chaiExpectPlugin from 'eslint-plugin-chai-expect'; { plugins: { 'chai-expect': chaiExpectPlugin } }).
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required for ESLint plugin functionality
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-chai-expect — npm install eslint-plugin-chai-expect · libregistry