no-import-assign
JavaScript / TypeScriptsuspiciousno fixdefault: errorjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”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, {}).
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”...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;Configuration
Section titled “Configuration”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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-import-assign |
full |