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-expectVerified import paths — ran on the pinned version, not inferred.
Shows how to set up the plugin with both flat and legacy config, including recommended presets and custom rules.
Upgrade Node.js to version 20 or higher.
Use import syntax (e.g., import chaiExpectPlugin from 'eslint-plugin-chai-expect') or switch to dynamic import().
Use chaiExpectPlugin.configs['recommended-flat'] in eslint.config.js instead of .eslintrc.
If using chai extensions like chai-http, add their terminating properties to the rule options: { properties: ['headers', 'html', 'ip', 'json', 'redirect', 'text'] }.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.
Use "error" instead of 2, e.g., { "chai-expect/missing-assertion": "error" }.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 } }).