Skip to content

no-import-assign

Reports a write to an imported name (import a from 'a'; a = 1, bb = 2), and a write to a member of a namespace import (ns.x = 1), a delete ns.y and Object.assign(ns, {}).

Imports are read-only live views of the exporting module. Assigning to one throws a TypeError in module code, and the namespace object of import * as ns cannot be changed either.

To fix, keep the value in a local variable, or let the exporting module offer a function that changes it.

Reported
...
d = 1; m++; ns = 1; ns.x = 1; delete ns.y; ns.a.b = 1; [ns.z] = []; Object.assign(ns, {}); Object.keys(ns);
const o = { c }; const [q] = [c]; var v = 1; v = 2; let l = 1; l = 2;
js:
lint:
rules:
no-import-assign: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-import-assign in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-import-assign full