Skip to content

Commit e333b8b

Browse files
valsciongaearon
authored andcommitted
Exempt variables prefixed with underscore from no-unused-vars rule (facebook#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>; }
1 parent 07105bf commit e333b8b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

config/eslint.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ module.exports = {
131131
'no-unreachable': 'warn',
132132
'no-unused-expressions': 'warn',
133133
'no-unused-labels': 'warn',
134-
'no-unused-vars': ['warn', { vars: 'local', args: 'none' }],
134+
'no-unused-vars': ['warn', {
135+
vars: 'local',
136+
varsIgnorePattern: '^_',
137+
args: 'none'
138+
}],
135139
'no-use-before-define': ['warn', 'nofunc'],
136140
'no-useless-computed-key': 'warn',
137141
'no-useless-concat': 'warn',

0 commit comments

Comments
 (0)