Skip to content

Commit 4a852ec

Browse files
committed
fixes
1 parent a6db9d6 commit 4a852ec

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/rules/__tests__/no-system-props.test.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ruleTester.run('no-system-props', rule, {
2323
invalid: [
2424
{
2525
code: `import {Button} from '@primer/components'; <Button width={200} />`,
26-
output: `import {Button} from '@primer/components'; <Button sx={{width: 200}} />`,
26+
output: `import {Button} from '@primer/components'; <Button sx={{width: 200}} />`,
2727
errors: [
2828
{
2929
messageId: 'noSystemProps',
@@ -33,7 +33,7 @@ ruleTester.run('no-system-props', rule, {
3333
},
3434
{
3535
code: `import {Button} from '@primer/components'; <Button width="200" />`,
36-
output: `import {Button} from '@primer/components'; <Button sx={{width: "200"}} />`,
36+
output: `import {Button} from '@primer/components'; <Button sx={{width: "200"}} />`,
3737
errors: [
3838
{
3939
messageId: 'noSystemProps',
@@ -43,7 +43,7 @@ ruleTester.run('no-system-props', rule, {
4343
},
4444
{
4545
code: `import {Button} from '@primer/components'; <Button width={"200"} />`,
46-
output: `import {Button} from '@primer/components'; <Button sx={{width: "200"}} />`,
46+
output: `import {Button} from '@primer/components'; <Button sx={{width: "200"}} />`,
4747
errors: [
4848
{
4949
messageId: 'noSystemProps',
@@ -53,7 +53,7 @@ ruleTester.run('no-system-props', rule, {
5353
},
5454
{
5555
code: `import {Button} from '@primer/components'; <Button width={myWidth} />`,
56-
output: `import {Button} from '@primer/components'; <Button sx={{width: myWidth}} />`,
56+
output: `import {Button} from '@primer/components'; <Button sx={{width: myWidth}} />`,
5757
errors: [
5858
{
5959
messageId: 'noSystemProps',
@@ -63,7 +63,7 @@ ruleTester.run('no-system-props', rule, {
6363
},
6464
{
6565
code: `import {Button} from '@primer/components'; <Button width={200} height={100} />`,
66-
output: `import {Button} from '@primer/components'; <Button sx={{width: 200, height: 100}} />`,
66+
output: `import {Button} from '@primer/components'; <Button sx={{width: 200, height: 100}} />`,
6767
errors: [
6868
{
6969
messageId: 'noSystemProps',
@@ -110,6 +110,16 @@ ruleTester.run('no-system-props', rule, {
110110
data: {propNames: 'width', componentName: 'Button'}
111111
}
112112
]
113+
},
114+
{
115+
code: `import {Label} from '@primer/components'; <Label width={200} outline />`,
116+
output: `import {Label} from '@primer/components'; <Label outline sx={{width: 200}} />`,
117+
errors: [
118+
{
119+
messageId: 'noSystemProps',
120+
data: {propNames: 'width', componentName: 'Label'}
121+
}
122+
]
113123
}
114124
]
115125
})

src/rules/no-system-props.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ const excludedComponents = new Set(['Box', 'Text'])
77

88
// Components for which we allow a set of prop names
99
const excludedComponentProps = new Map([
10+
['AnchoredOverlay', new Set(['width', 'height'])],
1011
['Avatar', new Set(['size'])],
12+
['Dialog', new Set(['width', 'height'])],
1113
['Label', new Set(['variant'])],
1214
['ProgressBar', new Set(['bg'])],
13-
['Spinner', new Set(['size'])]
15+
['Spinner', new Set(['size'])],
16+
['StyledOcticon', new Set(['size'])]
1417
])
1518

1619
module.exports = {
@@ -96,7 +99,7 @@ module.exports = {
9699
}
97100

98101
const sxPropTextFromStylesMap = styles => {
99-
return `sx={{${objectEntriesStringFromStylesMap(styles)}}}`
102+
return ` sx={{${objectEntriesStringFromStylesMap(styles)}}}`
100103
}
101104

102105
const objectEntriesStringFromStylesMap = styles => {

0 commit comments

Comments
 (0)