ESLint plugin (v2.1.0) that controls where mutation is allowed in JavaScript/TypeScript, preventing unsafe reassignment of shared variables (globals, parameters, closed-over variables) while permitting safe mutation of locally declared variables. Designed for functional programming style, with support for flat config (ESLint >=9) and classic config. Differentiates from eslint-plugin-immutable by allowing local mutation and providing safer defaults. Active development, monthly releases, peer dep eslint >=6.
npm install eslint-plugin-better-mutationVerified import paths — ran on the pinned version, not inferred.
Shows minimal ESLint flat config (ESM) with two mutation rules enabled.
Use eslint-plugin-better-mutation rules instead of core 'no-param-reassign' for FP-focused mutation control.
To block module.exports assignment, configure the rule with exemptedModuleExports: false.
Avoid reassigning destructured parameters; treat them as read-only.
Migrate to flat config and reference configs.recommended.
Ensure eslint-plugin-better-mutation is installed and in .eslintrc use the full string "plugin:better-mutation/recommended".
Run 'npm install --save-dev eslint-plugin-better-mutation' and verify it appears in package.json.
Use the default import: 'import pluginBetterMutation from "eslint-plugin-better-mutation"'.