Skip to content

Commit 75276c9

Browse files
authored
docs: reorder options in no-unused-vars (#16625)
Refs #16616
1 parent 7276fe5 commit 75276c9

1 file changed

Lines changed: 60 additions & 60 deletions

File tree

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

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,6 @@ Examples of **correct** code for the `{ "args": "none" }` option:
247247

248248
:::
249249

250-
### ignoreRestSiblings
251-
252-
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.
253-
254-
Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option:
255-
256-
::: correct
257-
258-
```js
259-
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
260-
// 'foo' and 'bar' were ignored because they have a rest property sibling.
261-
var { foo, ...coords } = data;
262-
263-
var bar;
264-
({ bar, ...coords } = data);
265-
```
266-
267-
:::
268-
269250
### argsIgnorePattern
270251

271252
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.
@@ -285,47 +266,6 @@ foo();
285266

286267
:::
287268

288-
### destructuredArrayIgnorePattern
289-
290-
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.
291-
292-
Examples of **correct** code for the `{ "destructuredArrayIgnorePattern": "^_" }` option:
293-
294-
::: correct
295-
296-
```js
297-
/*eslint no-unused-vars: ["error", { "destructuredArrayIgnorePattern": "^_" }]*/
298-
299-
const [a, _b, c] = ["a", "b", "c"];
300-
console.log(a+c);
301-
302-
const { x: [_a, foo] } = bar;
303-
console.log(foo);
304-
305-
function baz([_c, x]) {
306-
x;
307-
}
308-
baz();
309-
310-
function test({p: [_q, r]}) {
311-
r;
312-
}
313-
test();
314-
315-
let _m, n;
316-
foo.forEach(item => {
317-
[_m, n] = item;
318-
console.log(n);
319-
});
320-
321-
let _o, p;
322-
_o = 1;
323-
[_o, p] = foo;
324-
p;
325-
```
326-
327-
:::
328-
329269
### caughtErrors
330270

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

396336
:::
397337

338+
### destructuredArrayIgnorePattern
339+
340+
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.
341+
342+
Examples of **correct** code for the `{ "destructuredArrayIgnorePattern": "^_" }` option:
343+
344+
::: correct
345+
346+
```js
347+
/*eslint no-unused-vars: ["error", { "destructuredArrayIgnorePattern": "^_" }]*/
348+
349+
const [a, _b, c] = ["a", "b", "c"];
350+
console.log(a+c);
351+
352+
const { x: [_a, foo] } = bar;
353+
console.log(foo);
354+
355+
function baz([_c, x]) {
356+
x;
357+
}
358+
baz();
359+
360+
function test({p: [_q, r]}) {
361+
r;
362+
}
363+
test();
364+
365+
let _m, n;
366+
foo.forEach(item => {
367+
[_m, n] = item;
368+
console.log(n);
369+
});
370+
371+
let _o, p;
372+
_o = 1;
373+
[_o, p] = foo;
374+
p;
375+
```
376+
377+
:::
378+
379+
### ignoreRestSiblings
380+
381+
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.
382+
383+
Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option:
384+
385+
::: correct
386+
387+
```js
388+
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
389+
// 'foo' and 'bar' were ignored because they have a rest property sibling.
390+
var { foo, ...coords } = data;
391+
392+
var bar;
393+
({ bar, ...coords } = data);
394+
```
395+
396+
:::
397+
398398
## When Not To Use It
399399

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

0 commit comments

Comments
 (0)