Getting Started
Install the plugin:
npm install --save-dev eslint-plugin-immutable-2 typescript
Enable one preset in your Flat Config:
import immutable from "eslint-plugin-immutable-2";
export default [
immutable.configs.recommended,
];
recommended is the low-friction default preset. It works out of the box with
the bundled parser wiring, and it gains additional semantic precision when you
enable typed parser services for rules such as immutable-data. Move to
immutable when you want no-let, readonly typing, and the warning-level
no-method-signature rule in your baseline.
Alternative: manual scoped setupâ
If you prefer to apply plugin rules inside your own file-scoped config object, spread the preset rules manually.
import tsParser from "@typescript-eslint/parser";
import immutable from "eslint-plugin-immutable-2";
export default [
{
files: ["**/*.{ts,tsx,mts,cts}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: "latest",
// Enable when you want checker-backed precision.
// projectService: true,
sourceType: "module",
},
},
plugins: {
immutable,
},
rules: {
...immutable.configs.recommended.rules,
},
},
];
Use this pattern when you only extend rules and want full control over parser setup per scope.
Recommended rolloutâ
- Start with
recommended. - Move to
immutablewhen the team is ready for broader declaration and readonly typing discipline. - Fix violations in small batches.
- Move to
functional-litefor structural functional constraints such as loop and conditional restrictions. - Move to
functionalonce the team is ready for stricter statement, exception, andthisbans. - Use
allwhen you want every immutable rule enabled.
Need a subset instead of a full preset?â
immutable.configs.immutableimmutable.configs["functional-lite"]immutable.configs.functional
See the Presets section in this sidebar for details and examples.