ESLint v8.x reached end-of-life on 2024-10-05 and is no longer maintained. Upgrade or consider long-term support options
Versions

no-extra-strict

Disallows strict mode directives when already in strict mode.

The "use strict"; directive applies to the scope in which it appears and all inner scopes contained within that scope. Therefore, using the "use strict"; directive in one of these inner scopes is unnecessary.

"use strict";

(function () {
    "use strict";
    var foo = true;
}());

Rule Details

This rule is aimed at preventing unnecessary "use strict"; directives. As such, it will warn when it encounters a "use strict"; directive when already in strict mode.

Example of incorrect code for this rule:

"use strict";

(function () {
    "use strict";
    var foo = true;
}());

Examples of correct code for this rule:

"use strict";

(function () {
    var foo = true;
}());
(function () {
    "use strict";
    var foo = true;
}());

Version

This rule was introduced in ESLint v0.3.0 and removed in v1.0.0-rc-1.

Further Reading

Change Language