Registry / testing / eslint-plugin-better-mutation

eslint-plugin-better-mutation

JSON →
library2.1.0jsnpmunverified

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-mutation
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-BETT
E
eslint-plugin-better-mutation
testingjavascriptv2.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import pluginBetterMutation from "eslint-plugin-better-mutation"
✗ const pluginBetterMutation = require("eslint-plugin-better-mutation")
ESM default import. For CommonJS use require('eslint-plugin-better-mutation') in eslint.config.cjs. Flat config requires ESM.
rules
✓ import { rules } from "eslint-plugin-better-mutation"
✗ const rules = require("eslint-plugin-better-mutation").rules
Named export for direct rule access. Not needed if using plugin object.
configs
✓ import { configs } from "eslint-plugin-better-mutation"
Named export for configs; used in flat config. CommonJS: const { configs } = require('eslint-plugin-better-mutation').

Shows minimal ESLint flat config (ESM) with two mutation rules enabled.

import pluginBetterMutation from "eslint-plugin-better-mutation"; export default [ { name: "my-project", plugins: { "better-mutation": pluginBetterMutation, }, rules: { "better-mutation/no-mutating-functions": "error", "better-mutation/no-mutating-methods": "error", }, }, ];
Debug
Known issues
gotchaThe rule 'no-param-reassign' is NOT the same as this plugin; this plugin treats parameter reassignment as unsafe while allowing local variable mutation.
fix
Use eslint-plugin-better-mutation rules instead of core 'no-param-reassign' for FP-focused mutation control.
affects: >=1.0.0
gotchaCommonJS 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.
fix
To block module.exports assignment, configure the rule with exemptedModuleExports: false.
affects: >=1.0.0
gotchaDestructured properties are not considered safe for reassignment; the rule will flag '({ prop }) => { prop = 1; }' even though prop is a local copy.
fix
Avoid reassigning destructured parameters; treat them as read-only.
affects: >=1.0.0
deprecatedThe 'recommended' config from this plugin is deprecated in favor of flat config's 'extends' approach. Use 'plugin:better-mutation/recommended' in classic config only.
fix
Migrate to flat config and reference configs.recommended.
affects: =2.0.0
Errors
Common errors & fixes
ESLint couldn't find the config "plugin:better-mutation/recommended".
Using classic config string plugin name incorrectly or version mismatch.
fix
Ensure eslint-plugin-better-mutation is installed and in .eslintrc use the full string "plugin:better-mutation/recommended".
Cannot find module 'eslint-plugin-better-mutation'
Package not installed or not in node_modules.
fix
Run 'npm install --save-dev eslint-plugin-better-mutation' and verify it appears in package.json.
Error: Cannot read properties of undefined (reading 'no-mutating-functions')
Importing plugin incorrectly; the plugin object is not loaded as expected.
fix
Use the default import: 'import pluginBetterMutation from "eslint-plugin-better-mutation"'.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to run plugin rules
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-better-mutation — npm install eslint-plugin-better-mutation · libregistry