{"id":19835,"library":"eslint-plugin-mocha","title":"ESLint Plugin Mocha","description":"ESLint plugin providing rules specific to Mocha test suites, such as enforcing best practices, limiting nested describes, and requiring valid test titles. Current version 11.2.0 (January 2025) with a major breaking change in 11.0.0 that renamed several rules (e.g., *-description to *-title) and switched to ESM-only. The plugin ships TypeScript declarations now. It is maintained and released roughly every few months. Compared to other Mocha linting solutions, this is the official and most widely used plugin with ~1M weekly downloads.","status":"active","version":"11.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/lo1tuma/eslint-plugin-mocha","tags":["javascript","eslint","eslintplugin","eslint-plugin","mocha","typescript"],"install":[{"cmd":"npm install eslint-plugin-mocha","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-mocha","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-mocha","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to run the plugin","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v11; CJS require() will fail at runtime","wrong":"const mochaPlugin = require('eslint-plugin-mocha')","symbol":"default","correct":"import mochaPlugin from 'eslint-plugin-mocha'"},{"note":"Access flat configs (recommended, all) via named export","wrong":null,"symbol":"configs","correct":"import { configs } from 'eslint-plugin-mocha'"},{"note":"Access individual rule definitions for custom configs","wrong":null,"symbol":"rules","correct":"import { rules } from 'eslint-plugin-mocha'"}],"quickstart":{"code":"// eslint.config.js (flat config)\nimport mochaPlugin from 'eslint-plugin-mocha';\n\nexport default [\n  mochaPlugin.configs.recommended,\n  {\n    rules: {\n      'mocha/no-exclusive-tests': 'error',\n      'mocha/no-nested-tests': 'error',\n    },\n  },\n];","lang":"javascript","description":"Sets up eslint-plugin-mocha with recommended rules and custom overrides using flat config format."},"warnings":[{"fix":"Update all rule names: replace '-description' with '-title' in configs","message":"Rules *-description renamed to *-title in v11.0.0 (e.g., valid-suite-description → valid-suite-title)","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Replace 'mocha/no-async-describe' with 'mocha/no-async-suite' in your config","message":"no-async-describe renamed to no-async-suite in v11.0.0","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Switch to ESM imports or disable the no-exports rule if using CJS","message":"CommonJS support dropped in v11.0.0 for no-exports rule","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Convert your project to ESM or use dynamic import(). Alternatively, pin to v10.x","message":"Switched to ESM-only in v11.0.0; require() will fail","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Use flat config format. If you need legacy configs, stay on v10.x","message":"Flat config format (eslint.config.js) supported from v10.4.0; legacy .eslintrc not supported in v11","severity":"gotcha","affected_versions":">=11.0.0"},{"fix":"Use flat configs for better compatibility moving forward","message":"The 'recommended' config in flat configs is available as mochaPlugin.configs.recommended","severity":"deprecated","affected_versions":">=10.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import statement in an ESM context, or downgrade to v10.x: npm install eslint-plugin-mocha@^10","cause":"Using require() to load eslint-plugin-mocha v11+ which is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported."},{"fix":"Replace 'mocha/valid-suite-description' with 'mocha/valid-suite-title' in your ESLint config","cause":"Rule renamed in v11.0.0 from *-description to *-title.","error":"Configuration for rule \"mocha/valid-suite-description\" is invalid: Rule has been removed or renamed."},{"fix":"Import the plugin and spread it in your config array: export default [...mochaPlugin.configs.recommended, ...]","cause":"Flat config format not used or plugin not imported correctly.","error":"ESLint couldn't find the plugin \"eslint-plugin-mocha\" in flat config."},{"fix":"Update eslint-plugin-mocha to v10.4.0 or later, or use legacy .eslintrc format with v10.x","cause":"Using mochaPlugin.configs.recommended on v10.x without flat config support (v10 prior to 10.4.0).","error":"TypeError: Cannot read properties of undefined (reading 'recommended')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}