Skip to content

Commit

Permalink
Merge pull request #1276 from Hypnosphi/fix/no-find-dom-node
Browse files Browse the repository at this point in the history
Make no-find-dom-node work correctly with named imports
  • Loading branch information
ljharb committed Jun 26, 2017
2 parents e670022 + cbe8ae9 commit f70b417
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-find-dom-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
var callee = node.callee;

var isfindDOMNode =
(callee.object && callee.object.callee && callee.object.callee.name === 'findDOMNode') ||
(callee.name === 'findDOMNode') ||
(callee.property && callee.property.name === 'findDOMNode')
;

Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/no-find-dom-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,19 @@ ruleTester.run('no-find-dom-node', rule, {
errors: [{
message: 'Do not use findDOMNode'
}]
}, {
code: [
'class Hello extends Component {',
' componentDidMount() {',
' this.node = findDOMNode(this);',
' }',
' render() {',
' return <div>Hello</div>;',
' }',
'};'
].join('\n'),
errors: [{
message: 'Do not use findDOMNode'
}]
}]
});

0 comments on commit f70b417

Please sign in to comment.