Skip to content

Commit 383e999

Browse files
docs: update and fix examples for no-unused-vars (#17788)
* docs: update and fix examples for no-unused-var * docs: update previous changes
1 parent 5a8efd5 commit 383e999

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

docs/src/rules/no-unused-vars.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function fact(n) {
5656
function getY([x, y]) {
5757
return y;
5858
}
59+
getY(["a", "b"]);
5960
```
6061

6162
:::
@@ -89,6 +90,7 @@ myFunc = setTimeout(function() {
8990
function getY([, y]) {
9091
return y;
9192
}
93+
getY(["a", "b"]);
9294
```
9395

9496
:::
@@ -105,11 +107,18 @@ Note that `/* exported */` has no effect for any of the following:
105107

106108
The line comment `// exported variableName` will not work as `exported` is not line-specific.
107109

108-
Examples of **correct** code for `/* exported variableName */` operation:
110+
```js
111+
/* exported global_var */
109112

110-
::: correct
113+
var global_var = 42;
114+
```
115+
116+
Examples of **correct** code for `/* exported variableName */` operation with `no-unused-vars`:
117+
118+
::: correct { "sourceType": "script" }
111119

112120
```js
121+
/*eslint no-unused-vars: "error"*/
113122
/* exported global_var */
114123

115124
var global_var = 42;
@@ -386,11 +395,15 @@ Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option:
386395

387396
```js
388397
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
398+
389399
// 'foo' and 'bar' were ignored because they have a rest property sibling.
390-
var { foo, ...coords } = data;
400+
var { foo, ...rest } = data;
401+
console.log(rest);
402+
403+
// OR
391404

392405
var bar;
393-
({ bar, ...coords } = data);
406+
({ bar, ...rest } = data);
394407
```
395408

396409
:::

0 commit comments

Comments
 (0)