Strict mode should be declared properly

  • BAD_USE_STRICT
  • Error
  • Medium
  • No tags

This rule applies when strict mode is not properly declared.

If not properly declared, strict mode is not applied, so debugging and runtime behaviors might be unexpected.

It can be applied to the following:

  1. 'use strict' directive is not at the beginning of function body or global code
  2. Typing mistakes like 'use_strict'

Noncompliant Code Example

View with compliant examples side by side
// Example 1
function f() {
    var x;
    'use strict'; // BAD_USE_STRICT alarm
}

// Example 2
function g() {
    'use_strict'; // BAD_USE_STRICT alarm
}

Compliant Code Example

View with noncompliant examples side by side
// Example 1
function f() {
    'use strict';
    var x;
}

// Example 2
function g() {
    'use strict';
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See