no-extra-strict
当已经处于严格模式时,不允许使用严格模式指令。
¥Disallows strict mode directives when already in strict mode.
"use strict";
指令适用于它出现的范围以及该范围内包含的所有内部范围。因此,在这些内部范围之一中使用 "use strict";
指令是不必要的。
¥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
该规则旨在防止不必要的 "use strict";
指令。因此,它会在已经处于严格模式时遇到 "use strict";
指令时触发警告。
¥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;
}());
版本
此规则是在 ESLint v0.3.0 中引入,并在 v1.0.0-rc-1 中删除。