]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/docs/src/rules/no-underscore-dangle.md
import 8.41.0 source
[pve-eslint.git] / eslint / docs / src / rules / no-underscore-dangle.md
index f74beacf0030f368b7d2a3af38d0b5c67c0a23c7..d35aefeb72d14a5f320b5bd91215ad5274aac921 100644 (file)
@@ -1,6 +1,5 @@
 ---
 title: no-underscore-dangle
-layout: doc
 rule_type: suggestion
 ---
 
@@ -61,6 +60,8 @@ This rule has an object option:
 * `"allowAfterThisConstructor": false` (default) disallows dangling underscores in members of the `this.constructor` object
 * `"enforceInMethodNames": false` (default) allows dangling underscores in method names
 * `"enforceInClassFields": false` (default) allows dangling underscores in es2022 class fields names
+* `"allowInArrayDestructuring": true` (default) allows dangling underscores in variable names assigned by array destructuring
+* `"allowInObjectDestructuring": true` (default) allows dangling underscores in variable names assigned by object destructuring
 * `"allowFunctionParams": true` (default) allows dangling underscores in function parameter names
 
 ### allow
@@ -183,6 +184,50 @@ class Foo {
 
 :::
 
+### allowInArrayDestructuring
+
+Examples of **incorrect** code for this rule with the `{ "allowInArrayDestructuring": false }` option:
+
+::: incorrect
+
+```js
+/*eslint no-underscore-dangle: ["error", { "allowInArrayDestructuring": false }]*/
+
+const [_foo, _bar] = list;
+const [foo_, ..._bar] = list;
+const [foo, [bar, _baz]] = list;
+```
+
+:::
+
+### allowInObjectDestructuring
+
+Examples of **incorrect** code for this rule with the `{ "allowInObjectDestructuring": false }` option:
+
+::: incorrect
+
+```js
+/*eslint no-underscore-dangle: ["error", { "allowInObjectDestructuring": false }]*/
+
+const { foo, bar: _bar } = collection;
+const { foo, bar, _baz } = collection;
+```
+
+:::
+
+Examples of **correct** code for this rule with the `{ "allowInObjectDestructuring": false }` option:
+
+::: correct
+
+```js
+/*eslint no-underscore-dangle: ["error", { "allowInObjectDestructuring": false }]*/
+
+const { foo, bar, _baz: { a, b } } = collection;
+const { foo, bar, _baz: baz } = collection;
+```
+
+:::
+
 ### allowFunctionParams
 
 Examples of **incorrect** code for this rule with the `{ "allowFunctionParams": false }` option: