Skip to content

Commit

Permalink
feat: add SegmentedControl.Button to no-sx-prop rule
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed Sep 17, 2024
1 parent db903cd commit 21102b7
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions src/rules/no-sx-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@
const url = require('../url')

const forbidden = new Set([
'SegmentedControl',
// 'ActionList',
// 'ActionList.Divider',
// 'ActionList.Group',
// 'ActionList.Item',
// 'ActionList.LeadingVisual',
// 'ActionList.LinkItem',

// 'ActionMenu.Button',
// 'ActionMenu.Overlay',

// 'Avatar',
// 'AvatarStack',

// 'BorderBox',
// 'Box',

// 'BranchName',

// 'Breadcrumbs',
// 'Breadcrumbs.Item',

'SegmentedControl',
'SegmentedControl.Button',

'SplitPageLayout.Pane',

// 'UnderlineNav',
// 'UnderlineNav.Item',
])
Expand All @@ -36,14 +54,24 @@ module.exports = {
create(context) {
return {
JSXOpeningElement(node) {
if (!forbidden.has(node.name.name)) {
return
if (node.name.type === 'JSXMemberExpression') {
if (node.name.object.type === 'JSXIdentifier' && node.name.property.type === 'JSXIdentifier') {
const name = `${node.name.object.name}.${node.name.property.name}`
if (forbidden.has(name)) {
context.report({
node,
messageId: 'sxProp',
})
}
}
} else if (node.name.type === 'JSXIdentifier') {
if (forbidden.has(node.name.name)) {
context.report({
node,
messageId: 'sxProp',
})
}
}

context.report({
node,
messageId: 'sxProp',
})
},
}
},
Expand Down

0 comments on commit 21102b7

Please sign in to comment.