ESLint plugin for teams that want TypeScript-first immutability and functional-style conventions in modern flat config projects.
The plugin ships focused flat-config presets with parser setup already wired in. Typed parser services remain opt-in so consumers can decide when they want the extra semantic precision.
Oxlint: Not compatible as a complete plugin (verified with Oxlint 1.80.0). Most syntax-only rules can run, but two of the 35 rules use TypeScript parser services; for example, Oxlint misses
readonly-array's typed inference on code that ESLint reports. Oxlint does not support type-aware JavaScript plugin rules, so use ESLint for the complete rule and preset behavior.
- Installation
- Quick start (flat config)
- Presets
- Configuration examples by preset
- Type-aware precision
- Rules
- Contributors β¨
npm install --save-dev eslint-plugin-immutable-2 typescript
@typescript-eslint/parseris loaded automatically by plugin presets.
- Supported ESLint versions:
9.xand10.x - Config system: Flat Config only (
eslint.config.*) - Node.js runtime:
>=22.0.0
import immutable from "eslint-plugin-immutable-2";
export default [immutable.configs.recommended];That is enough for the default JS/TS preset file globs
(**/*.{js,cjs,mjs,jsx,ts,tsx,mts,cts}).
This plugin intentionally exports five presets:
| Preset | Config key | Use when |
|---|---|---|
| π’ Functional Lite | immutable.configs["functional-lite"] |
You want a moderate step up from immutable with lightweight structural functional rules. |
| π‘ Functional | immutable.configs.functional |
You want the strict functional tier without turning on every rule in the plugin. |
| π Immutable | immutable.configs.immutable |
You want the broader immutable baseline with no-let, readonly typing, and method-shape discipline. |
| π΅ Recommended | immutable.configs.recommended |
You want the default low-friction entrypoint focused on high-signal mutation hazards. |
| π£ All | immutable.configs.all |
You want every rule in this plugin enabled. |
import immutable from "eslint-plugin-immutable-2";
export default [
// Default low-friction starting point.
immutable.configs.recommended,
// Broader immutable baseline with readonly typing and declaration discipline.
// immutable.configs.immutable,
// Small structural functional step-up on top of the immutable baseline.
// immutable.configs["functional-lite"],
// Strict functional-style coverage without enabling every rule.
// immutable.configs.functional,
// Every rule in the plugin.
// immutable.configs.all,
];Each preset already includes:
files: ["**/*.{js,cjs,mjs,jsx,ts,tsx,mts,cts}"]languageOptions.parser(@typescript-eslint/parser)languageOptions.parserOptions:ecmaVersion: "latest"sourceType: "module"
End users usually do not need to wire parser config manually.
If you need custom parser options (for example project, projectService, or
tsconfigRootDir), extend a preset:
import immutable from "eslint-plugin-immutable-2";
const recommended = immutable.configs.recommended;
export default [
{
...recommended,
languageOptions: {
...recommended.languageOptions,
parserOptions: {
...recommended.languageOptions?.parserOptions,
projectService: true,
},
},
},
];The plugin presets already set the parser and base parser options, but they do
not automatically enable project/projectService for you.
If you want the most accurate checker-backed behavior from rules such as
immutable-data and the implicit-array inference branch of readonly-array,
extend a preset with typed parser services:
import immutable from "eslint-plugin-immutable-2";
export default [
{
...recommended,
languageOptions: {
...recommended.languageOptions,
parserOptions: {
...recommended.languageOptions?.parserOptions,
projectService: true,
},
},
},
];Without parser services, the plugin still loads and syntax-first rules still run, but checker-backed branches may fall back to conservative behavior.
The plugin does not currently expose any custom settings.immutable runtime
switches. Behavior is controlled through preset choice and per-rule options.
Fixlegend:π§= autofixableπ‘= suggestions availableβ= report only
Preset keylegend:
Thanks goes to these wonderful people (emoji key):
Nick2bad4u π π» π π€ π π§ π |
Snyk bot π‘οΈ π π§ π |
StepSecurity Bot π‘οΈ π π§ |
dependabot[bot] π π‘οΈ |
github-actions[bot] π» π |