Skip to content

Commit

Permalink
Merge pull request #1195 from oliviertassinari/fix
Browse files Browse the repository at this point in the history
fix: void-dom-elements-no-children
  • Loading branch information
yannickcr committed May 16, 2017
2 parents 0dd4685 + 03a8066 commit 647bcd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/rules/void-dom-elements-no-children.js
Expand Up @@ -110,7 +110,7 @@ module.exports = {
return;
}

if (args.length < 2) {
if (args.length < 2 || args[1].type !== 'ObjectExpression') {
return;
}

Expand Down
16 changes: 9 additions & 7 deletions tests/lib/rules/void-dom-elements-no-children.js
Expand Up @@ -53,33 +53,35 @@ ruleTester.run('void-dom-elements-no-children', rule, {
code: 'document.createElement("img")'
}, {
code: 'React.createElement("img");'
}, {
code: [
'const props = {}',
'React.createElement("img", props)'
].join('\n')
}, {
code: [
'import React from "react";',
'const { createElement } = React;',
'createElement("div")'
].join('\n'),
parser: 'babel-eslint'
].join('\n')
}, {
code: [
'import React from "react";',
'const { createElement } = React;',
'createElement("img")'
].join('\n'),
parser: 'babel-eslint'
].join('\n')
}, {
code: [
'import React, {createElement, PureComponent} from \'react\';',
'class Button extends PureComponent {',
' handleClick = ev => {',
' handleClick(ev) {',
' ev.preventDefault();',
' }',
' render() {',
' return <div onClick={this.handleClick}>Hello</div>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
].join('\n')
}
],
invalid: [
Expand Down

0 comments on commit 647bcd4

Please sign in to comment.