版本

no-extra-strict

當已處於嚴格模式時,不允許使用 strict mode 指令。

"use strict"; 指令適用於其出現的範圍以及該範圍內包含的所有內部範圍。因此,在這些內部範圍之一中使用 "use strict"; 指令是不必要的。

"use strict";

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

規則詳細資訊

此規則旨在防止不必要的 "use strict"; 指令。因此,當在已處於嚴格模式時遇到 "use strict"; 指令時,它會發出警告。

此規則的錯誤程式碼範例

"use strict";

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

此規則的正確程式碼範例

"use strict";

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

版本

此規則在 ESLint v0.3.0 中引入,並在 v1.0.0-rc-1 中移除。

延伸閱讀

變更語言