Commit e333b8b8 authored by Vesa Laakso's avatar Vesa Laakso Committed by Dan Abramov
Browse files

Exempt variables prefixed with underscore from no-unused-vars rule (#640)

* 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>;
    }
parent 07105bfd
Showing with 5 additions and 1 deletion
+5 -1
...@@ -131,7 +131,11 @@ module.exports = { ...@@ -131,7 +131,11 @@ module.exports = {
'no-unreachable': 'warn', 'no-unreachable': 'warn',
'no-unused-expressions': 'warn', 'no-unused-expressions': 'warn',
'no-unused-labels': '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-use-before-define': ['warn', 'nofunc'],
'no-useless-computed-key': 'warn', 'no-useless-computed-key': 'warn',
'no-useless-concat': 'warn', 'no-useless-concat': 'warn',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment