Skip to content

Commit 29a6eb8

Browse files
committed
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 1e1bed9 commit 29a6eb8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

config/eslint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ module.exports = {
133133
'no-unused-labels': 'warn',
134134
'no-unused-vars': ['warn', {
135135
vars: 'local',
136+
varsIgnorePattern: '^_',
136137
args: 'none'
137138
}],
138139
'no-use-before-define': ['warn', 'nofunc'],

0 commit comments

Comments
 (0)