eslint: relax no-return-assign to 'except-parens'

a common pattern to set a ref for a react element is:
<div ref={e => this.refName = e} />

But if you are using our eslint rules (currently set to 
"no-return-assign": ["error", "always”]) it will force you to do:
<div ref={e => {this.refName = e}} />

And now, if you are using prettier, it will format that as:
<div ref={e => {
  this.refName = e
}} />

That seems needlessly verbose. With this change you can now do:
<div ref={e => (this.refName = e)} />

And both eslint and prettier will be ok with that

Test plan:
* verify functions that return an assignment do what you want in eslint

Change-Id: I56abfdb21a7bf3f5b3eae8088f27749f41f2371c
Reviewed-on: https://gerrit.instructure.com/131788
Tested-by: Jenkins
Reviewed-by: Felix Milea-Ciobanu <fmileaciobanu@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2017-11-03 11:14:36 -06:00
parent 8069dbba16
commit 2122e6b9bd
1 changed files with 1 additions and 0 deletions

View File

@ -37,6 +37,7 @@ module.exports = {
"no-continue": [0],
"no-else-return": [0],
"no-plusplus": [0],
"no-return-assign": ['error', 'except-parens'],
"no-underscore-dangle": [0],
"no-unused-vars": [2, { "argsIgnorePattern": "^_"}],
"object-curly-spacing": [0],