]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/docs/rules/no-undef-init.md
import 8.3.0 source
[pve-eslint.git] / eslint / docs / rules / no-undef-init.md
index 10db58c17b0a684a6ee5f0b03449ac2d60d73e1e..0cf99c192961e4972c671e4098fa719bf43a3acd 100644 (file)
@@ -19,13 +19,12 @@ It's considered a best practice to avoid initializing variables to `undefined`.
 
 ## Rule Details
 
-This rule aims to eliminate variable declarations that initialize to `undefined`.
+This rule aims to eliminate `var` and `let` variable declarations that initialize to `undefined`.
 
 Examples of **incorrect** code for this rule:
 
 ```js
 /*eslint no-undef-init: "error"*/
-/*eslint-env es6*/
 
 var foo = undefined;
 let bar = undefined;
@@ -35,11 +34,29 @@ Examples of **correct** code for this rule:
 
 ```js
 /*eslint no-undef-init: "error"*/
-/*eslint-env es6*/
 
 var foo;
 let bar;
-const baz = undefined;
+```
+
+Please note that this rule does not check `const` declarations, destructuring patterns, function parameters, and class fields.
+
+Examples of additional **correct** code for this rule:
+
+```js
+/*eslint no-undef-init: "error"*/
+
+const foo = undefined;
+
+let { bar = undefined } = baz;
+
+[quux = undefined] = quuux;
+
+(foo = undefined) => {};
+
+class Foo {
+    bar = undefined;
+}
 ```
 
 ## When Not To Use It