Update rule doc

This commit is contained in:
2018-08-20 12:26:59 +05:30
parent 76e545fb08
commit 4b3a6b0f37
+5 -4
View File
@@ -1,11 +1,12 @@
# Always initialize variables during declaration. Set it explicitly to undefined, if required. (undef-init) # Always initialize variables during declaration. Set it explicitly to undefined, if required. (undef-init)
## Rule Details
### It is better to explicitly initialize all variable declarations. ### It is better to explicitly initialize all variable declarations.
Instead of naked var / let declarations (which are implicitly set to `undefined` anyway), always explicitly set them to `undefined`. It makes clear that you explicitly intended to set them to undefined, not just because you forgot to initialize. Instead of naked var / let declarations (which are implicitly set to `undefined` anyway), always explicitly set them to `undefined`. It makes clear that you explicitly intended to set them to undefined, not just because you forgot to initialize.
## Rule Details Note: Initialization is not allowed in the `ForDeclaration` part of for-of and for-in statements. Hence, those need not (and can not) be set to undefined.
Ex: `for (var i in []){do_something()}` is correct.
This rule aims to...
Examples of **incorrect** code for this rule: Examples of **incorrect** code for this rule:
@@ -38,7 +39,7 @@ for (var i in []){do_something()}
### Options ### Options
There are no options There are no options.
## When Not To Use It ## When Not To Use It