In strict mode, read-only variables cannot be assigned
This rule applies when a value is assigned to read-only variables in strict mode.
The read-only variables are as follows:
import
bindingsundefined
,NaN
,Infinity
Any assignment to the above variables that silently fails in normal code will throw aTypeError
exception in strict mode.
Note: Applied for module code without"use strict"
directive since module code is always strict mode code.
// Example 1import { A } from 'a';A = 1; // STRICT_MODE_ASSIGN_TO_READONLY_VAR alarm because it is module code.// Example 2'use strict';undefined = 1; // STRICT_MODE_ASSIGN_TO_READONLY_VAR alarmNaN = 2; // STRICT_MODE_ASSIGN_TO_READONLY_VAR alarmInfinity = 3; // STRICT_MODE_ASSIGN_TO_READONLY_VAR alarm
This rule was introduced in DeepScan 1.0.0-alpha.