An enhanced version of the ESLint core rule no-unused-vars with allowances for experimental object rest properties.
This plugin provides a single rule which functions the same as the core rule
no-unused-vars, except it adds the
ignoreDestructuredVarsWithRest option. Enabling this option will allow unused variables appearing in destructuring assignments that also contain experimental rest properties. This is useful for shallow-cloning an object while omitting certain properties.
Install ESLint and
$ npm install --save-dev eslint eslint-plugin-no-unused-vars-rest
no-unused-vars-rest to the plugins section of your
.eslintrc configuration file, and configure the rule under the rules section. Don't forget to disable the core rule
Alternatively you may use the plugin's recommended configuration, which applies the above configuration.
When not using this rule the following pattern is considered a problem by the core rule
const extra ...rest = blah; // Error 'extra' is defined but never used.return rest;
When using this rule with
ignoreDestructuredVarsWithRest: true the following pattern is acceptable:
const extra ...rest = blah;return rest;