Skip to content

Commit

Permalink
Exempt variables prefixed with underscore from no-unused-vars rule (#640
Browse files Browse the repository at this point in the history
)

* Split no-unused-vars ESLint config to multiple lines

* Exempt variables prefixed with underscore from no-unused-vars rule

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 authored and gaearon committed Sep 16, 2016
1 parent 07105bf commit e333b8b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ module.exports = {
'no-unreachable': 'warn',
'no-unused-expressions': 'warn',
'no-unused-labels': 'warn',
'no-unused-vars': ['warn', { vars: 'local', args: 'none' }],
'no-unused-vars': ['warn', {
vars: 'local',
varsIgnorePattern: '^_',
args: 'none'
}],
'no-use-before-define': ['warn', 'nofunc'],
'no-useless-computed-key': 'warn',
'no-useless-concat': 'warn',
Expand Down

0 comments on commit e333b8b

Please sign in to comment.