in src/rules/no-system-props.js [86:115]
fix(fixer) {
const existingSxProp = jsxNode.attributes.find(
attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'sx'
)
const systemPropstylesMap = stylesMapFromPropNodes(systemProps, context)
if (existingSxProp && existingSxProp.value.expression.type !== 'ObjectExpression') {
return
}
const stylesToAdd = existingSxProp
? excludeSxEntriesFromStyleMap(systemPropstylesMap, existingSxProp)
: systemPropstylesMap
return [
// Remove the bad props
...systemProps.map(node => fixer.remove(node)),
...(stylesToAdd.size > 0
? [
existingSxProp
? // Update an existing sx prop
fixer.insertTextAfter(
last(existingSxProp.value.expression.properties),
`, ${objectEntriesStringFromStylesMap(stylesToAdd)}`
)
: // Insert new sx prop
fixer.insertTextAfter(last(jsxNode.attributes), sxPropTextFromStylesMap(systemPropstylesMap))
]
: [])
]
}