Movatterモバイル変換


[0]ホーム

URL:


In strict mode, read-only variables cannot be assigned

  • STRICT_MODE_ASSIGN_TO_READONLY_VAR
  • Error
  • High
  • No tags

This rule applies when a value is assigned to read-only variables in strict mode.

The read-only variables are as follows:

  1. import bindings
  2. Predefined global variables such asundefined,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.

Noncompliant Code Example

// 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

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See

Was this documentation helpful?

Last updated on April 29, 2025

[8]ページ先頭

©2009-2025 Movatter.jp