Skip to content

Commit

Permalink
docs: update and fix examples for no-unused-vars (#17788)
Browse files Browse the repository at this point in the history
* docs: update and fix examples for no-unused-var

* docs: update previous changes
  • Loading branch information
Tanujkanti4441 committed Nov 24, 2023
1 parent 5a8efd5 commit 383e999
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions docs/src/rules/no-unused-vars.md
Expand Up @@ -56,6 +56,7 @@ function fact(n) {
function getY([x, y]) {
return y;
}
getY(["a", "b"]);
```

:::
Expand Down Expand Up @@ -89,6 +90,7 @@ myFunc = setTimeout(function() {
function getY([, y]) {
return y;
}
getY(["a", "b"]);
```

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

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

Examples of **correct** code for `/* exported variableName */` operation:
```js
/* exported global_var */

::: correct
var global_var = 42;
```

Examples of **correct** code for `/* exported variableName */` operation with `no-unused-vars`:

::: correct { "sourceType": "script" }

```js
/*eslint no-unused-vars: "error"*/
/* exported global_var */

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

```js
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/

// 'foo' and 'bar' were ignored because they have a rest property sibling.
var { foo, ...coords } = data;
var { foo, ...rest } = data;
console.log(rest);

// OR

var bar;
({ bar, ...coords } = data);
({ bar, ...rest } = data);
```

:::
Expand Down

0 comments on commit 383e999

Please sign in to comment.