{"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,"search_vec":"'10':29 '2':26 '20':33 '2026':23 '4.1.0':20 'april':22 'assert':63,73 'auto':38 'auto-fix':37 'chai':4,56,76 'chai.js':13 'check':10 'common':12 'comparisons/literals':65 'config':48 'configur':52 'cover':61 'current':16 'custom':55 'default':58 'differenti':35 'eslint':2,7,25,77,79 'eslint-plugin':78 'eslint-plugin-chai-expect':1 'eslintplugin':81 'expect':5,14 'extens':57 'fix':39 'flat':47 'function':70 'includ':36 'inner':64 'javascript':75 'key':34 'legaci':45 'method':74 'miss':62 'mistak':15 'node.js':32 'plugin':3,8,80 'preset':49 'properti':67 'provid':43 'recommend':59 'releas':21 'rule':42,53,60 'stabl':17 'support':24 'termin':66 'uncal':72 'use':68 'version':18 'x':27,30","created_at":"2026-04-25T11:19:12.775126+00:00","updated_at":"2026-04-25T11:19:12.775126+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Turbo87/eslint-plugin-chai-expect","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-plugin-chai-expect","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}