{"id":19706,"library":"eslint-plugin-chai-expect","title":"eslint-plugin-chai-expect","description":"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.","status":"active","version":"4.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/Turbo87/eslint-plugin-chai-expect","tags":["javascript","chai","eslint","eslint-plugin","eslintplugin"],"install":[{"cmd":"npm install eslint-plugin-chai-expect","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-chai-expect","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-chai-expect","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for ESLint plugin functionality","package":"eslint","optional":false}],"imports":[{"note":"Module is ESM-only since v4. CommonJS require() is not supported for the default export. For flat config, import as default.","wrong":"const chaiExpectPlugin = require('eslint-plugin-chai-expect')","symbol":"plugin (default)","correct":"import chaiExpectPlugin from 'eslint-plugin-chai-expect'"},{"note":"Named export for rules. Also ESM-only since v4.","wrong":"const { rules } = require('eslint-plugin-chai-expect')","symbol":"rules","correct":"import { rules } from 'eslint-plugin-chai-expect'"},{"note":"Legacy config preset for .eslintrc. Not available as a direct named import; access via plugin object.","wrong":null,"symbol":"configs['recommended']","correct":"chaiExpectPlugin.configs.recommended"},{"note":"Flat config preset for eslint.config.js. Available in v4+. Access via plugin object.","wrong":null,"symbol":"configs['recommended-flat']","correct":"chaiExpectPlugin.configs['recommended-flat']"}],"quickstart":{"code":"// Install: npm install --save-dev eslint-plugin-chai-expect\n\n// eslint.config.js (flat config, ESLint >=9)\nimport chaiExpectPlugin from 'eslint-plugin-chai-expect';\n\nexport default [\n  chaiExpectPlugin.configs['recommended-flat'],\n  {\n    rules: {\n      'chai-expect/no-inner-compare': 'error',\n      'chai-expect/missing-assertion': 'error'\n    }\n  }\n];\n\n// .eslintrc.json (legacy config, ESLint <9)\n// {\n//   \"plugins\": [\"chai-expect\"],\n//   \"extends\": [\"plugin:chai-expect/recommended\"],\n//   \"rules\": {\n//     \"chai-expect/no-inner-compare\": 2\n//   }\n// }","lang":"javascript","description":"Shows how to set up the plugin with both flat and legacy config, including recommended presets and custom rules."},"warnings":[{"fix":"Upgrade Node.js to version 20 or higher.","message":"Dropped support for Node.js < 20 in v4.0.0","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use import syntax (e.g., import chaiExpectPlugin from 'eslint-plugin-chai-expect') or switch to dynamic import().","message":"Package is ESM-only since v4; no CommonJS require() for default import","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use chaiExpectPlugin.configs['recommended-flat'] in eslint.config.js instead of .eslintrc.","message":"recommended config is legacy; use recommended-flat for flat config","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"If using chai extensions like chai-http, add their terminating properties to the rule options: { properties: ['headers', 'html', 'ip', 'json', 'redirect', 'text'] }.","message":"The terminating-properties rule may false-positive on non-terminal chaining if custom properties are not configured","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"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.","cause":"Using CommonJS require() to load the ESM-only plugin in v4+.","error":"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."},{"fix":"Use \"error\" instead of 2, e.g., { \"chai-expect/missing-assertion\": \"error\" }.","cause":"Using numeric severity (2) in flat config; flat config expects string severity (\"error\" or \"warn\").","error":"Configuration for rule \"chai-expect/missing-assertion\" is invalid: Value \"2\" is invalid."},{"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 } }).","cause":"Plugin not installed or missing in plugins section; for flat config, you must import and add to plugins object.","error":"ESLint couldn't find the plugin \"chai-expect\"."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}