diff --git a/docs/src/rules/no-unused-vars.md b/docs/src/rules/no-unused-vars.md index 718d3cd4f42..1b3e59ce93b 100644 --- a/docs/src/rules/no-unused-vars.md +++ b/docs/src/rules/no-unused-vars.md @@ -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. @@ -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. @@ -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.