]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/symbol-description.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / symbol-description.md
1 # require symbol description (symbol-description)
2
3 The `Symbol` function may have an optional description:
4
5 ```js
6 var foo = Symbol("some description");
7
8 var someString = "some description";
9 var bar = Symbol(someString);
10 ```
11
12 Using `description` promotes easier debugging: when a symbol is logged the description is used:
13
14 ```js
15 var foo = Symbol("some description");
16
17 > console.log(foo);
18 // Symbol(some description)
19 ```
20
21 It may facilitate identifying symbols when one is observed during debugging.
22
23 ## Rule Details
24
25 This rules requires a description when creating symbols.
26
27 ## Examples
28
29 Examples of **incorrect** code for this rule:
30
31 ```js
32 /*eslint symbol-description: "error"*/
33 /*eslint-env es6*/
34
35 var foo = Symbol();
36 ```
37
38 Examples of **correct** code for this rule:
39
40 ```js
41 /*eslint symbol-description: "error"*/
42 /*eslint-env es6*/
43
44 var foo = Symbol("some description");
45
46 var someString = "some description";
47 var bar = Symbol(someString);
48 ```
49
50 ## When Not To Use It
51
52 This rule should not be used in ES3/5 environments.
53 In addition, this rule can be safely turned off if you don't want to enforce presence of `description` when creating Symbols.
54
55 ## Further Reading
56
57 * [Symbol Objects specification: Symbol description](https://www.ecma-international.org/ecma-262/6.0/#sec-symbol-description)