2 title: no-import-assign
9 The updates of imported bindings by ES Modules cause runtime errors.
13 This rule warns the assignments, increments, and decrements of imported bindings.
15 Examples of **incorrect** code for this rule:
20 /*eslint no-import-assign: "error"*/
22 import mod, { named } from "./mod.mjs"
23 import * as mod_ns from "./mod.mjs"
25 mod = 1 // ERROR: 'mod' is readonly.
26 named = 2 // ERROR: 'named' is readonly.
27 mod_ns.named = 3 // ERROR: The members of 'mod_ns' are readonly.
28 mod_ns = {} // ERROR: 'mod_ns' is readonly.
29 // Can't extend 'mod_ns'
30 Object.assign(mod_ns, { foo: "foo" }) // ERROR: The members of 'mod_ns' are readonly.
35 Examples of **correct** code for this rule:
40 /*eslint no-import-assign: "error"*/
42 import mod, { named } from "./mod.mjs"
43 import * as mod_ns from "./mod.mjs"
51 obj.named = 4 // Not errored because 'obj' is not namespace objects.
53 test(mod_ns) // Not errored because it doesn't know that 'test' updates the member of the argument.
60 If you don't want to be notified about modifying imported bindings, you can disable this rule.