Skip to content

Latest commit

Β 

History

139 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eslint-plugin-immutable-2

npm license. npm total downloads. latest GitHub release. GitHub stars. GitHub forks. GitHub open issues. codecov. Mutation testing badge.

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.

Table of contents

Installation

npm install --save-dev eslint-plugin-immutable-2 typescript

@typescript-eslint/parser is loaded automatically by plugin presets.

Compatibility

  • Supported ESLint versions: 9.x and 10.x
  • Config system: Flat Config only (eslint.config.*)
  • Node.js runtime: >=22.0.0

Quick start (flat config)

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}).

Presets

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.

Configuration examples by preset

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,
];

Parser setup behavior

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,
   },
  },
 },
];

Type-aware precision

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.

Rules

Rule Fix Preset key
immutable-data β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-abort-controller-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-atomics-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-buffer-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-cache-api-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-class β€” 🟑 🟣
no-conditional-statement β€” 🟒 🟑 🟣
no-cookie-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-data-view-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-date-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-dom-token-list-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-expression-statement β€” 🟑 🟣
no-form-data-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-headers-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-history-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-let πŸ’‘ 🟒 🟑 🟠 🟣
no-location-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-loop-statement β€” 🟒 🟑 🟣
no-map-set-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-method-signature πŸ’‘ 🟒 🟑 🟠 🟣
no-mixed-interface β€” 🟒 🟑 🟣
no-process-env-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-reflect-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-regexp-lastindex-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-reject β€” 🟣
no-stateful-regexp β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-storage-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-this β€” 🟑 🟣
no-throw β€” 🟑 🟣
no-try β€” 🟑 🟣
no-typed-array-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-url-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
no-url-search-params-mutation β€” 🟒 🟑 🟠 πŸ”΅ 🟣
readonly-array πŸ”§ 🟒 🟑 🟠 🟣
readonly-keyword πŸ”§ 🟒 🟑 🟠 🟣

Contributors ✨

All Contributors.

Thanks goes to these wonderful people (emoji key):

Nick2bad4u
Nick2bad4u

πŸ› πŸ’» πŸ“– πŸ€” πŸš‡ 🚧 πŸ‘€ ⚠️ πŸ”§
Snyk bot
Snyk bot

πŸ›‘οΈ πŸš‡ 🚧 πŸ‘€
StepSecurity Bot
StepSecurity Bot

πŸ›‘οΈ πŸš‡ 🚧
dependabot[bot]
dependabot[bot]

πŸš‡ πŸ›‘οΈ
github-actions[bot]
github-actions[bot]

πŸ’» πŸš‡

About

ESLint plugin to disable all mutation in JavaScript and Typescript... 2

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages