{"id":19701,"library":"eslint-plugin-better-mutation","title":"eslint-plugin-better-mutation","description":"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.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/sloops77/eslint-plugin-better-mutation","tags":["javascript","eslint","plugin","eslint-plugin","eslintplugin","fp","FP","function","functional"],"install":[{"cmd":"npm install eslint-plugin-better-mutation","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-better-mutation","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-better-mutation","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run plugin rules","package":"eslint","optional":false}],"imports":[{"note":"ESM default import. For CommonJS use require('eslint-plugin-better-mutation') in eslint.config.cjs. Flat config requires ESM.","wrong":"const pluginBetterMutation = require(\"eslint-plugin-better-mutation\")","symbol":"default","correct":"import pluginBetterMutation from \"eslint-plugin-better-mutation\""},{"note":"Named export for direct rule access. Not needed if using plugin object.","wrong":"const rules = require(\"eslint-plugin-better-mutation\").rules","symbol":"rules","correct":"import { rules } from \"eslint-plugin-better-mutation\""},{"note":"Named export for configs; used in flat config. CommonJS: const { configs } = require('eslint-plugin-better-mutation').","symbol":"configs","correct":"import { configs } from \"eslint-plugin-better-mutation\""}],"quickstart":{"code":"import pluginBetterMutation from \"eslint-plugin-better-mutation\";\nexport default [\n  {\n    name: \"my-project\",\n    plugins: {\n      \"better-mutation\": pluginBetterMutation,\n    },\n    rules: {\n      \"better-mutation/no-mutating-functions\": \"error\",\n      \"better-mutation/no-mutating-methods\": \"error\",\n    },\n  },\n];","lang":"typescript","description":"Shows minimal ESLint flat config (ESM) with two mutation rules enabled."},"warnings":[{"fix":"Use eslint-plugin-better-mutation rules instead of core 'no-param-reassign' for FP-focused mutation control.","message":"The rule 'no-param-reassign' is NOT the same as this plugin; this plugin treats parameter reassignment as unsafe while allowing local variable mutation.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To block module.exports assignment, configure the rule with exemptedModuleExports: false.","message":"CommonJS module.exports assignment is allowed by default, but other global assignments are errors. This can be surprising if you expect all reassignment to be blocked.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid reassigning destructured parameters; treat them as read-only.","message":"Destructured properties are not considered safe for reassignment; the rule will flag '({ prop }) => { prop = 1; }' even though prop is a local copy.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to flat config and reference configs.recommended.","message":"The 'recommended' config from this plugin is deprecated in favor of flat config's 'extends' approach. Use 'plugin:better-mutation/recommended' in classic config only.","severity":"deprecated","affected_versions":"=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure eslint-plugin-better-mutation is installed and in .eslintrc use the full string \"plugin:better-mutation/recommended\".","cause":"Using classic config string plugin name incorrectly or version mismatch.","error":"ESLint couldn't find the config \"plugin:better-mutation/recommended\"."},{"fix":"Run 'npm install --save-dev eslint-plugin-better-mutation' and verify it appears in package.json.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'eslint-plugin-better-mutation'"},{"fix":"Use the default import: 'import pluginBetterMutation from \"eslint-plugin-better-mutation\"'.","cause":"Importing plugin incorrectly; the plugin object is not loaded as expected.","error":"Error: Cannot read properties of undefined (reading 'no-mutating-functions')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}