]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-extra-strict.md
import 8.23.1 source
[pve-eslint.git] / eslint / docs / src / rules / no-extra-strict.md
1 ---
2 title: no-extra-strict
3 layout: doc
4
5 further_reading:
6 - https://es5.github.io/#C
7 ---
8
9 Disallows strict mode directives when already in strict mode.
10
11 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict) rule. The `"global"` or `"function"` options in the new rule are similar to the removed rule.
12
13 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.
14
15 ```js
16 "use strict";
17
18 (function () {
19 "use strict";
20 var foo = true;
21 }());
22 ```
23
24 ## Rule Details
25
26 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.
27
28 Example of **incorrect** code for this rule:
29
30 ::: incorrect
31
32 ```js
33 "use strict";
34
35 (function () {
36 "use strict";
37 var foo = true;
38 }());
39 ```
40
41 :::
42
43 Examples of **correct** code for this rule:
44
45 ::: correct
46
47 ```js
48 "use strict";
49
50 (function () {
51 var foo = true;
52 }());
53 ```
54
55 :::
56
57 ::: correct
58
59 ```js
60 (function () {
61 "use strict";
62 var foo = true;
63 }());
64 ```
65
66 :::