Skip to content

Commit

Permalink
store parent prior to if
Browse files Browse the repository at this point in the history
  • Loading branch information
evosch committed Dec 6, 2018
1 parent b52fecc commit c021019
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/rules/style-prop-object.js
Expand Up @@ -94,14 +94,14 @@ module.exports = {
if (!node.value || node.name.name !== 'style') {
return;
}

// store parent element
const parentElement = node.parent;

// parent element is a JSXOpeningElement
if (node.parent && node.parent.type === 'JSXOpeningElement') {
// store parent element
const jsxOpeningElement = node.parent;
if (parentElement && parentElement.type === 'JSXOpeningElement') {

// get the name of the JSX element
const name = jsxOpeningElement.name && jsxOpeningElement.name.name;
const name = parentElement.name && parentElement.name.name;

// allowed list contains the name
if (allowed.indexOf(name) > -1) {
Expand Down

0 comments on commit c021019

Please sign in to comment.