Skip to content

Commit

Permalink
docs: reorder options in no-unused-vars (#16625)
Browse files Browse the repository at this point in the history
Refs #16616
  • Loading branch information
mdjermanovic committed Dec 8, 2022
1 parent 7276fe5 commit 75276c9
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions docs/src/rules/no-unused-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,6 @@ Examples of **correct** code for the `{ "args": "none" }` option:

:::

### ignoreRestSiblings

The `ignoreRestSiblings` option is a boolean (default: `false`). Using a [Rest Property](https://github.com/tc39/proposal-object-rest-spread) it is possible to "omit" properties from an object, but by default the sibling properties are marked as "unused". With this option enabled the rest property's siblings are ignored.

Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option:

::: correct

```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 bar;
({ bar, ...coords } = data);
```

:::

### argsIgnorePattern

The `argsIgnorePattern` option specifies exceptions not to check for usage: arguments whose names match a regexp pattern. For example, variables whose names begin with an underscore.
Expand All @@ -285,47 +266,6 @@ foo();

:::

### destructuredArrayIgnorePattern

The `destructuredArrayIgnorePattern` option specifies exceptions not to check for usage: elements of array destructuring patterns whose names match a regexp pattern. For example, variables whose names begin with an underscore.

Examples of **correct** code for the `{ "destructuredArrayIgnorePattern": "^_" }` option:

::: correct

```js
/*eslint no-unused-vars: ["error", { "destructuredArrayIgnorePattern": "^_" }]*/

const [a, _b, c] = ["a", "b", "c"];
console.log(a+c);

const { x: [_a, foo] } = bar;
console.log(foo);

function baz([_c, x]) {
x;
}
baz();

function test({p: [_q, r]}) {
r;
}
test();

let _m, n;
foo.forEach(item => {
[_m, n] = item;
console.log(n);
});

let _o, p;
_o = 1;
[_o, p] = foo;
p;
```

:::

### caughtErrors

The `caughtErrors` option is used for `catch` block arguments validation.
Expand Down Expand Up @@ -395,6 +335,66 @@ try {

:::

### destructuredArrayIgnorePattern

The `destructuredArrayIgnorePattern` option specifies exceptions not to check for usage: elements of array destructuring patterns whose names match a regexp pattern. For example, variables whose names begin with an underscore.

Examples of **correct** code for the `{ "destructuredArrayIgnorePattern": "^_" }` option:

::: correct

```js
/*eslint no-unused-vars: ["error", { "destructuredArrayIgnorePattern": "^_" }]*/

const [a, _b, c] = ["a", "b", "c"];
console.log(a+c);

const { x: [_a, foo] } = bar;
console.log(foo);

function baz([_c, x]) {
x;
}
baz();

function test({p: [_q, r]}) {
r;
}
test();

let _m, n;
foo.forEach(item => {
[_m, n] = item;
console.log(n);
});

let _o, p;
_o = 1;
[_o, p] = foo;
p;
```

:::

### ignoreRestSiblings

The `ignoreRestSiblings` option is a boolean (default: `false`). Using a [Rest Property](https://github.com/tc39/proposal-object-rest-spread) it is possible to "omit" properties from an object, but by default the sibling properties are marked as "unused". With this option enabled the rest property's siblings are ignored.

Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option:

::: correct

```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 bar;
({ bar, ...coords } = data);
```

:::

## When Not To Use It

If you don't want to be notified about unused variables or function arguments, you can safely turn this rule off.

0 comments on commit 75276c9

Please sign in to comment.