Skip to content

Commit

Permalink
[Fix] no-render-return-value: should warn when used in assignment e…
Browse files Browse the repository at this point in the history
…xpression

Fixes #2461.
  • Loading branch information
jichu4n authored and ljharb committed Oct 11, 2019
1 parent 360d74a commit da2c7d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/no-render-return-value.js
Expand Up @@ -58,7 +58,8 @@ module.exports = {
parent.type === 'VariableDeclarator' ||
parent.type === 'Property' ||
parent.type === 'ReturnStatement' ||
parent.type === 'ArrowFunctionExpression'
parent.type === 'ArrowFunctionExpression' ||
parent.type === 'AssignmentExpression'
) {
context.report({
node: callee,
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/no-render-return-value.js
Expand Up @@ -96,6 +96,16 @@ ruleTester.run('no-render-return-value', rule, {
errors: [{
message: 'Do not depend on the return value from ReactDOM.render'
}]
}, {
code: 'this.o = ReactDOM.render(<div />, document.body);',
errors: [{
message: 'Do not depend on the return value from ReactDOM.render'
}]
}, {
code: 'var v; v = ReactDOM.render(<div />, document.body);',
errors: [{
message: 'Do not depend on the return value from ReactDOM.render'
}]
}, {
code: 'var inst = React.render(<div />, document.body);',
settings: {
Expand Down

0 comments on commit da2c7d2

Please sign in to comment.