]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-wrap-func.md
first commit
[pve-eslint.git] / eslint / docs / rules / no-wrap-func.md
1 # no-wrap-func: disallow unnecessary parentheses around function expressions
2
3 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-extra-parens](no-extra-parens.md) rule. The `"functions"` option in the new rule is equivalent to the removed rule.
4
5
6 Although it's possible to wrap functions in parentheses, this can be confusing when the code also contains immediately-invoked function expressions (IIFEs) since parentheses are often used to make this distinction. For example:
7
8 ```js
9 var foo = (function() {
10 // IIFE
11 }());
12
13 var bar = (function() {
14 // not an IIFE
15 });
16 ```
17
18 ## Rule Details
19
20 This rule will raise a warning when it encounters a function expression wrapped in parentheses with no following invoking parentheses.
21
22 Example of **incorrect** code for this rule:
23
24 ```js
25 var a = (function() {/*...*/});
26 ```
27
28 Examples of **correct** code for this rule:
29
30 ```js
31 var a = function() {/*...*/};
32
33 (function() {/*...*/})();
34 ```