From 1e1bed91f002487e239fee290eac070ded6ec67f Mon Sep 17 00:00:00 2001 From: Vesa Laakso Date: Tue, 13 Sep 2016 22:16:40 +0300 Subject: [PATCH 1/2] Split no-unused-vars ESLint config to multiple lines --- config/eslint.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/eslint.js b/config/eslint.js index 9c77d1f7b39..f3ffdf528f2 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -131,7 +131,10 @@ 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', + args: 'none' + }], 'no-use-before-define': ['warn', 'nofunc'], 'no-useless-computed-key': 'warn', 'no-useless-concat': 'warn', From 29a6eb865fc39c9da0459c061df0d67d8bda58da Mon Sep 17 00:00:00 2001 From: Vesa Laakso Date: Tue, 13 Sep 2016 22:20:46 +0300 Subject: [PATCH 2/2] 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
{ JSON.stringify(rest) }
; } --- config/eslint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/config/eslint.js b/config/eslint.js index f3ffdf528f2..d83c66a85f7 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -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'],