Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed May 2, 2024
1 parent a2dc8de commit e1096b1
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export default function transformer(file, api, options) {
const printOptions = options.printOptions;

findComponentJSX(j, { root, componentName: 'Divider' }, (elementPath) => {
const hasLightProp = elementPath.node.openingElement.attributes.findIndex(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'light',
) !== -1;

const hasLightProp =
elementPath.node.openingElement.attributes.findIndex(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'light',
) !== -1;

if (hasLightProp) {
elementPath.node.openingElement.attributes = elementPath.node.openingElement.attributes.filter(
(attr) => {
elementPath.node.openingElement.attributes =
elementPath.node.openingElement.attributes.filter((attr) => {
if (attr.type === 'JSXAttribute' && attr.name.name === 'light') {
return false;
}
return true;
},
);

});

const sxIndex = elementPath.node.openingElement.attributes.findIndex(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'sx',
);
Expand All @@ -41,7 +41,7 @@ export default function transformer(file, api, options) {
const opacityIndex = elementPath.node.openingElement.attributes[
sxIndex
].value.expression.properties.findIndex((key) => key.key.name === 'opacity');

if (opacityIndex === -1) {
assignObject(j, {
target: elementPath.node.openingElement.attributes[sxIndex],
Expand All @@ -58,17 +58,17 @@ export default function transformer(file, api, options) {
(key) => key.key.name === 'defaultProps',
);

const hasLightProp = defaultPropsObject.value.properties.findIndex(
(prop) => prop.key.name === 'light',
) !== -1;
const hasLightProp =
defaultPropsObject.value.properties.findIndex((prop) => prop.key.name === 'light') !== -1;

if (hasLightProp) {

defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(
(prop) => !['light'].includes(prop?.key?.name),
);

const sxIndex = defaultPropsObject.value.properties.findIndex((prop) => prop.key.name === 'sx');
const sxIndex = defaultPropsObject.value.properties.findIndex(
(prop) => prop.key.name === 'sx',
);

if (sxIndex === -1) {
defaultPropsObject.value.properties.push(
Expand All @@ -78,9 +78,9 @@ export default function transformer(file, api, options) {
),
);
} else {
const opacityIndex = defaultPropsObject.value.properties[sxIndex].value.properties.findIndex(
(key) => key.key.name === 'opacity',
);
const opacityIndex = defaultPropsObject.value.properties[
sxIndex
].value.properties.findIndex((key) => key.key.name === 'opacity');

if (opacityIndex === -1) {
defaultPropsObject.value.properties[sxIndex].value.properties.push(
Expand Down

0 comments on commit e1096b1

Please sign in to comment.