@@ -6,9 +6,13 @@ const importDeclarationError = {
6
6
message : errorMessage ,
7
7
type : "ImportDeclaration" ,
8
8
} ;
9
- const jsxElementError = {
9
+ const jsxOpeningElementError = {
10
10
message : errorMessage ,
11
- type : "JSXElement" ,
11
+ type : "JSXOpeningElement" ,
12
+ } ;
13
+ const jsxClosingElementError = {
14
+ message : errorMessage ,
15
+ type : "JSXClosingElement" ,
12
16
} ;
13
17
const identifierError = {
14
18
message : errorMessage ,
@@ -28,78 +32,109 @@ ruleTester.run("text-replace-with-content", rule, {
28
32
{
29
33
code : `import { Text } from '@patternfly/react-core'; <Text>Abc</Text>` ,
30
34
output : `import { Content } from '@patternfly/react-core'; <Content component="p">Abc</Content>` ,
31
- errors : [ importDeclarationError , jsxElementError ] ,
35
+ errors : [
36
+ importDeclarationError ,
37
+ jsxOpeningElementError ,
38
+ jsxClosingElementError ,
39
+ ] ,
32
40
} ,
33
41
{
34
42
code : `import { Text } from '@patternfly/react-core'; <Text component="h3">Abc</Text>` ,
35
43
output : `import { Content } from '@patternfly/react-core'; <Content component="h3">Abc</Content>` ,
36
- errors : [ importDeclarationError , jsxElementError ] ,
44
+ errors : [
45
+ importDeclarationError ,
46
+ jsxOpeningElementError ,
47
+ jsxClosingElementError ,
48
+ ] ,
49
+ } ,
50
+ {
51
+ code : `import { Text, TextContent } from '@patternfly/react-core';
52
+ <TextContent>
53
+ <Text component="h3">Abc</Text>
54
+ </TextContent>` ,
55
+ output : `import { Content, TextContent } from '@patternfly/react-core';
56
+ <Content>
57
+ <Content component="h3">Abc</Content>
58
+ </Content>` ,
59
+ errors : [
60
+ importDeclarationError ,
61
+ jsxOpeningElementError ,
62
+ jsxOpeningElementError ,
63
+ jsxClosingElementError ,
64
+ jsxClosingElementError ,
65
+ ] ,
37
66
} ,
38
- // {
39
- // code: `import { Text, TextContent } from '@patternfly/react-core';
40
- // <TextContent>
41
- // <Text component="h3">Abc</Text>
42
- // </TextContent>`,
43
- // output: `import { Content, TextContent } from '@patternfly/react-core';
44
- // <Content>
45
- // <Content component="h3">Abc</Content>
46
- // </Content>`,
47
- // errors: [importDeclarationError, jsxElementError, jsxElementError],
48
- // },
49
67
{
50
68
code : `import { TextContent } from '@patternfly/react-core'; <TextContent isVisited></TextContent>` ,
51
69
output : `import { Content } from '@patternfly/react-core'; <Content isVisitedLink></Content>` ,
52
- errors : [ importDeclarationError , jsxElementError ] ,
70
+ errors : [
71
+ importDeclarationError ,
72
+ jsxOpeningElementError ,
73
+ jsxClosingElementError ,
74
+ ] ,
75
+ } ,
76
+ {
77
+ code : `import { TextList, TextListItem } from '@patternfly/react-core';
78
+ <TextList>
79
+ <TextListItem>A</TextListItem>
80
+ <TextListItem>B</TextListItem>
81
+ <TextListItem>C</TextListItem>
82
+ </TextList>` ,
83
+ output : `import { Content, TextListItem } from '@patternfly/react-core';
84
+ <Content component="ul">
85
+ <Content component="li">A</Content>
86
+ <Content component="li">B</Content>
87
+ <Content component="li">C</Content>
88
+ </Content>` ,
89
+ errors : [
90
+ importDeclarationError ,
91
+ jsxOpeningElementError ,
92
+ jsxOpeningElementError ,
93
+ jsxClosingElementError ,
94
+ jsxOpeningElementError ,
95
+ jsxClosingElementError ,
96
+ jsxOpeningElementError ,
97
+ jsxClosingElementError ,
98
+ jsxClosingElementError ,
99
+ ] ,
100
+ } ,
101
+ {
102
+ code : `import { TextList, TextListItem } from '@patternfly/react-core';
103
+ <TextList component="dl">
104
+ <TextListItem component="dt">A</TextListItem>
105
+ <TextListItem component="dd">letter A</TextListItem>
106
+ <TextListItem component="dt">B</TextListItem>
107
+ <TextListItem component="dd">letter B</TextListItem>
108
+ </TextList>` ,
109
+ output : `import { Content, TextListItem } from '@patternfly/react-core';
110
+ <Content component="dl">
111
+ <Content component="dt">A</Content>
112
+ <Content component="dd">letter A</Content>
113
+ <Content component="dt">B</Content>
114
+ <Content component="dd">letter B</Content>
115
+ </Content>` ,
116
+ errors : [
117
+ importDeclarationError ,
118
+ jsxOpeningElementError ,
119
+ jsxOpeningElementError ,
120
+ jsxClosingElementError ,
121
+ jsxOpeningElementError ,
122
+ jsxClosingElementError ,
123
+ jsxOpeningElementError ,
124
+ jsxClosingElementError ,
125
+ jsxOpeningElementError ,
126
+ jsxClosingElementError ,
127
+ jsxClosingElementError ,
128
+ ] ,
53
129
} ,
54
- // {
55
- // code: `import { TextList, TextListItem } from '@patternfly/react-core';
56
- // <TextList>
57
- // <TextListItem>A</TextListItem>
58
- // <TextListItem>B</TextListItem>
59
- // <TextListItem>C</TextListItem>
60
- // </TextList>`,
61
- // output: `import { Content, TextListItem } from '@patternfly/react-core';
62
- // <Content component="ul">
63
- // <Content component="li">A</Content>
64
- // <Content component="li">B</Content>
65
- // <Content component="li">C</Content>
66
- // </Content>`,
67
- // errors: [
68
- // importDeclarationError,
69
- // jsxElementError,
70
- // jsxElementError,
71
- // jsxElementError,
72
- // jsxElementError,
73
- // ],
74
- // },
75
- // {
76
- // code: `import { TextList, TextListItem } from '@patternfly/react-core';
77
- // <TextList component="dl">
78
- // <TextListItem component="dt">A</TextListItem>
79
- // <TextListItem component="dd">letter A</TextListItem>
80
- // <TextListItem component="dt">B</TextListItem>
81
- // <TextListItem component="dd">letter B</TextListItem>
82
- // </TextList>`,
83
- // output: `import { Content, TextListItem } from '@patternfly/react-core';
84
- // <Content component="dl">
85
- // <Content component="dt">A</Content>
86
- // <Content component="dd">letter A</Content>
87
- // <Content component="dt">B</Content>
88
- // <Content component="dd">letter B</Content>
89
- // </Content>`,
90
- // errors: [
91
- // importDeclarationError,
92
- // jsxElementError,
93
- // jsxElementError,
94
- // jsxElementError,
95
- // jsxElementError,
96
- // jsxElementError,
97
- // ],
98
- // },
99
130
{
100
131
code : `import { TextList } from '@patternfly/react-core'; <TextList isPlain></TextList>` ,
101
132
output : `import { Content } from '@patternfly/react-core'; <Content component="ul" isPlainList></Content>` ,
102
- errors : [ importDeclarationError , jsxElementError ] ,
133
+ errors : [
134
+ importDeclarationError ,
135
+ jsxOpeningElementError ,
136
+ jsxClosingElementError ,
137
+ ] ,
103
138
} ,
104
139
{
105
140
code : `import { TextVariants } from '@patternfly/react-core'; const foo = TextVariants.h1` ,
@@ -115,7 +150,11 @@ ruleTester.run("text-replace-with-content", rule, {
115
150
{
116
151
code : `import { Text as PFText } from '@patternfly/react-core'; <PFText>Abc</PFText>` ,
117
152
output : `import { Content } from '@patternfly/react-core'; <Content component="p">Abc</Content>` ,
118
- errors : [ importDeclarationError , jsxElementError ] ,
153
+ errors : [
154
+ importDeclarationError ,
155
+ jsxOpeningElementError ,
156
+ jsxClosingElementError ,
157
+ ] ,
119
158
} ,
120
159
] ,
121
160
} ) ;
0 commit comments