]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-caller.md
import 8.41.0 source
[pve-eslint.git] / eslint / docs / src / rules / no-caller.md
1 ---
2 title: no-caller
3 rule_type: suggestion
4 ---
5
6
7 The use of `arguments.caller` and `arguments.callee` make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 while in strict mode.
8
9 ```js
10 function foo() {
11 var callee = arguments.callee;
12 }
13 ```
14
15 ## Rule Details
16
17 This rule is aimed at discouraging the use of deprecated and sub-optimal code by disallowing the use of `arguments.caller` and `arguments.callee`. As such, it will warn when `arguments.caller` and `arguments.callee` are used.
18
19 Examples of **incorrect** code for this rule:
20
21 ::: incorrect
22
23 ```js
24 /*eslint no-caller: "error"*/
25
26 function foo(n) {
27 if (n <= 0) {
28 return;
29 }
30
31 arguments.callee(n - 1);
32 }
33
34 [1,2,3,4,5].map(function(n) {
35 return !(n > 1) ? 1 : arguments.callee(n - 1) * n;
36 });
37 ```
38
39 :::
40
41 Examples of **correct** code for this rule:
42
43 ::: correct
44
45 ```js
46 /*eslint no-caller: "error"*/
47
48 function foo(n) {
49 if (n <= 0) {
50 return;
51 }
52
53 foo(n - 1);
54 }
55
56 [1,2,3,4,5].map(function factorial(n) {
57 return !(n > 1) ? 1 : factorial(n - 1) * n;
58 });
59 ```
60
61 :::