Skip to content

Commit

Permalink
[Refactor] void-dom-elements-no-children: improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Apr 28, 2021
1 parent 6cf3812 commit 6437617
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/util/Components.js
Expand Up @@ -393,25 +393,29 @@ function componentRule(rule, context) {
* @returns {Boolean} True if createElement called from pragma
*/
isCreateElement(node) {
const calledOnPragma = (
// match `React.createElement()`
if (
node
&& node.callee
&& node.callee.object
&& node.callee.object.name === pragma
&& node.callee.property
&& node.callee.property.name === 'createElement'
);
) {
return true;
}

const calledDirectly = (
// match `createElement()`
if (
node
&& node.callee
&& node.callee.name === 'createElement'
);

if (this.isDestructuredFromPragmaImport('createElement')) {
return calledDirectly || calledOnPragma;
&& this.isDestructuredFromPragmaImport('createElement')
) {
return true;
}
return calledOnPragma;

return false;
},

/**
Expand Down

0 comments on commit 6437617

Please sign in to comment.