Skip to content

Commit 21102b7

Browse files
committed
feat: add SegmentedControl.Button to no-sx-prop rule
1 parent db903cd commit 21102b7

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

src/rules/no-sx-prop.js

+36-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@
33
const url = require('../url')
44

55
const forbidden = new Set([
6-
'SegmentedControl',
76
// 'ActionList',
87
// 'ActionList.Divider',
98
// 'ActionList.Group',
109
// 'ActionList.Item',
1110
// 'ActionList.LeadingVisual',
1211
// 'ActionList.LinkItem',
1312

13+
// 'ActionMenu.Button',
14+
// 'ActionMenu.Overlay',
15+
16+
// 'Avatar',
17+
// 'AvatarStack',
18+
19+
// 'BorderBox',
20+
// 'Box',
21+
22+
// 'BranchName',
23+
24+
// 'Breadcrumbs',
25+
// 'Breadcrumbs.Item',
26+
27+
'SegmentedControl',
28+
'SegmentedControl.Button',
29+
30+
'SplitPageLayout.Pane',
31+
1432
// 'UnderlineNav',
1533
// 'UnderlineNav.Item',
1634
])
@@ -36,14 +54,24 @@ module.exports = {
3654
create(context) {
3755
return {
3856
JSXOpeningElement(node) {
39-
if (!forbidden.has(node.name.name)) {
40-
return
57+
if (node.name.type === 'JSXMemberExpression') {
58+
if (node.name.object.type === 'JSXIdentifier' && node.name.property.type === 'JSXIdentifier') {
59+
const name = `${node.name.object.name}.${node.name.property.name}`
60+
if (forbidden.has(name)) {
61+
context.report({
62+
node,
63+
messageId: 'sxProp',
64+
})
65+
}
66+
}
67+
} else if (node.name.type === 'JSXIdentifier') {
68+
if (forbidden.has(node.name.name)) {
69+
context.report({
70+
node,
71+
messageId: 'sxProp',
72+
})
73+
}
4174
}
42-
43-
context.report({
44-
node,
45-
messageId: 'sxProp',
46-
})
4775
},
4876
}
4977
},

0 commit comments

Comments
 (0)