]>
Commit | Line | Data |
---|---|---|
8f9d1d4d DC |
1 | --- |
2 | title: no-delete-var | |
8f9d1d4d DC |
3 | rule_type: suggestion |
4 | --- | |
5 | ||
6 | ||
eb39fafa DC |
7 | |
8 | The purpose of the `delete` operator is to remove a property from an object. Using the `delete` operator on a variable might lead to unexpected behavior. | |
9 | ||
10 | ## Rule Details | |
11 | ||
12 | This rule disallows the use of the `delete` operator on variables. | |
13 | ||
14 | If ESLint parses code in strict mode, the parser (instead of this rule) reports the error. | |
15 | ||
16 | Examples of **incorrect** code for this rule: | |
17 | ||
8f9d1d4d DC |
18 | ::: incorrect |
19 | ||
eb39fafa DC |
20 | ```js |
21 | /*eslint no-delete-var: "error"*/ | |
22 | ||
23 | var x; | |
24 | delete x; | |
25 | ``` | |
8f9d1d4d DC |
26 | |
27 | ::: |