Skip to content

Commit

Permalink
Exempt variables prefixed with underscore from no-unused-vars rule
Browse files Browse the repository at this point in the history
This is useful when e.g. using object spread operator to remove only a
certain field from the object.

For example, this can be used to ignore a property from React
component's `this.props`:

    render() {
        const { someAttribute: _unused, ...rest } = this.props;
        return <pre>{ JSON.stringify(rest) }</pre>;
    }
  • Loading branch information
valscion committed Sep 13, 2016
1 parent 1e1bed9 commit 29a6eb8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions config/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module.exports = {
'no-unused-labels': 'warn',
'no-unused-vars': ['warn', {
vars: 'local',
varsIgnorePattern: '^_',
args: 'none'
}],
'no-use-before-define': ['warn', 'nofunc'],
Expand Down

0 comments on commit 29a6eb8

Please sign in to comment.