@@ -12,57 +12,92 @@ jest.mock('@primer/primitives/dist/deprecations/colors_v2', () => testDeprecatio
12
12
13
13
const ruleTester = new RuleTester ( {
14
14
parserOptions : {
15
+ ecmaVersion : 'latest' ,
16
+ sourceType : 'module' ,
15
17
ecmaFeatures : {
16
18
jsx : true
17
19
}
18
20
}
19
21
} )
20
22
21
23
ruleTester . run ( 'no-deprecated-colors' , rule , {
22
- valid : [ ] ,
24
+ valid : [
25
+ `import {Box} from '@other/design-system'; <Box color="text.primary">Hello</Box>` ,
26
+ `import {Box} from '@primer/components'; <Box color="fg.default">Hello</Box>`
27
+ ] ,
23
28
invalid : [
24
29
{
25
- code : ' <Box color="text.primary" />' ,
26
- output : ' <Box color="fg.default" />' ,
30
+ code : `import {Box} from '@primer/components'; function Example() { return <Box color="text.primary">Hello</Box> }` ,
31
+ output : `import {Box} from '@primer/components'; function Example() { return <Box color="fg.default">Hello</Box> }` ,
27
32
errors : [
28
33
{
29
34
message : '"text.primary" is deprecated. Use "fg.default" instead.'
30
35
}
31
36
]
32
37
} ,
33
38
{
34
- code : '<Box bg="bg.primary" />' ,
35
- output : '<Box bg="canvas.default" />' ,
39
+ code : `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }` ,
40
+ output : `import Box from '@primer/components/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }` ,
41
+ errors : [
42
+ {
43
+ message : '"text.primary" is deprecated. Use "fg.default" instead.'
44
+ }
45
+ ]
46
+ } ,
47
+ {
48
+ code : `import {Box} from '@primer/components'; const Example = () => <Box color="text.primary">Hello</Box>` ,
49
+ output : `import {Box} from '@primer/components'; const Example = () => <Box color="fg.default">Hello</Box>` ,
50
+ errors : [
51
+ {
52
+ message : '"text.primary" is deprecated. Use "fg.default" instead.'
53
+ }
54
+ ]
55
+ } ,
56
+ {
57
+ code : `import {Box} from '@primer/components'; <Box bg="bg.primary" />` ,
58
+ output : `import {Box} from '@primer/components'; <Box bg="canvas.default" />` ,
36
59
errors : [
37
60
{
38
61
message : '"bg.primary" is deprecated. Use "canvas.default" instead.'
39
62
}
40
63
]
41
64
} ,
42
65
{
43
- code : ' <Box color="auto.green.5" />' ,
66
+ code : `import {Box} from '@primer/components'; <Box color="auto.green.5" />` ,
44
67
errors : [
45
68
{
46
69
message : '"auto.green.5" is deprecated.' ,
47
70
suggestions : [
48
71
{
49
72
desc : 'Use "success.fg" instead.' ,
50
- output : ' <Box color="success.fg" />'
73
+ output : `import {Box} from '@primer/components'; <Box color="success.fg" />`
51
74
} ,
52
75
{
53
76
desc : 'Use "success.emphasis" instead.' ,
54
- output : ' <Box color="success.emphasis" />'
77
+ output : `import {Box} from '@primer/components'; <Box color="success.emphasis" />`
55
78
}
56
79
]
57
80
}
58
81
]
59
82
} ,
60
83
{
61
- code : ' <Box color="fade.fg10" />' ,
84
+ code : `import {Box} from '@primer/components'; <Box color="fade.fg10" />` ,
62
85
errors : [
63
86
{
64
87
message :
65
- '"fade.fg10" is deprecated. See https://primer.style/primitives or reach out in the #primer Slack channel to find a suitable replacement.'
88
+ '"fade.fg10" is deprecated. Go to https://primer.style/primitives or reach out in the #primer channel on Slack to find a suitable replacement.'
89
+ }
90
+ ]
91
+ } ,
92
+ {
93
+ code : `import {Box, Text} from '@primer/components'; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>` ,
94
+ output : `import {Box, Text} from '@primer/components'; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>` ,
95
+ errors : [
96
+ {
97
+ message : '"bg.primary" is deprecated. Use "canvas.default" instead.'
98
+ } ,
99
+ {
100
+ message : '"text.primary" is deprecated. Use "fg.default" instead.'
66
101
}
67
102
]
68
103
}
0 commit comments