@@ -12,12 +12,12 @@ Examples of **incorrect** code for this rule:
12
12
13
13
``` jsx
14
14
// function expression for named component
15
- var Component = function (props ) {
15
+ const Component = function (props ) {
16
16
return < div> {props .content }< / div> ;
17
17
};
18
18
19
19
// arrow function for named component
20
- var Component = (props ) => {
20
+ const Component = (props ) => {
21
21
return < div> {props .content }< / div> ;
22
22
};
23
23
@@ -49,11 +49,11 @@ Examples of **incorrect** code for this rule:
49
49
``` jsx
50
50
// only function declarations for named components
51
51
// [2, { "namedComponents": "function-declaration" }]
52
- var Component = function (props ) {
52
+ const Component = function (props ) {
53
53
return < div / > ;
54
54
};
55
55
56
- var Component = (props ) => {
56
+ const Component = (props ) => {
57
57
return < div / > ;
58
58
};
59
59
@@ -63,7 +63,7 @@ function Component (props) {
63
63
return < div / > ;
64
64
};
65
65
66
- var Component = (props ) => {
66
+ const Component = (props ) => {
67
67
return < div / > ;
68
68
};
69
69
@@ -73,7 +73,7 @@ function Component (props) {
73
73
return < div / > ;
74
74
};
75
75
76
- var Component = function (props ) {
76
+ const Component = function (props ) {
77
77
return < div / > ;
78
78
};
79
79
@@ -107,13 +107,13 @@ function Component (props) {
107
107
108
108
// only function expressions for named components
109
109
// [2, { "namedComponents": "function-expression" }]
110
- var Component = function (props ) {
110
+ const Component = function (props ) {
111
111
return < div / > ;
112
112
};
113
113
114
114
// only arrow functions for named components
115
115
// [2, { "namedComponents": "arrow-function" }]
116
- var Component = (props ) => {
116
+ const Component = (props ) => {
117
117
return < div / > ;
118
118
};
119
119
@@ -170,11 +170,11 @@ The following patterns can **not** be autofixed in TypeScript:
170
170
``` tsx
171
171
// function expressions and arrow functions that have type annotations cannot be autofixed to function declarations
172
172
// [2, { "namedComponents": "function-declaration" }]
173
- var Component: React .FC <Props > = function (props ) {
173
+ const Component: React .FC <Props > = function (props ) {
174
174
return <div />;
175
175
};
176
176
177
- var Component: React .FC <Props > = (props ) => {
177
+ const Component: React .FC <Props > = (props ) => {
178
178
return <div />;
179
179
};
180
180
@@ -184,7 +184,7 @@ function Component<T>(props: Props<T>) {
184
184
return <div />;
185
185
};
186
186
187
- var Component = function <T >(props : Props <T >) {
187
+ const Component = function <T >(props : Props <T >) {
188
188
return <div />;
189
189
};
190
190
@@ -203,13 +203,13 @@ The following patterns can be autofixed in TypeScript:
203
203
``` tsx
204
204
// autofix to function expression with type annotation
205
205
// [2, { "namedComponents": "function-expression" }]
206
- var Component: React .FC <Props > = (props ) => {
206
+ const Component: React .FC <Props > = (props ) => {
207
207
return <div />;
208
208
};
209
209
210
210
// autofix to arrow function with type annotation
211
211
// [2, { "namedComponents": "function-expression" }]
212
- var Component: React .FC <Props > = function (props ) {
212
+ const Component: React .FC <Props > = function (props ) {
213
213
return <div />;
214
214
};
215
215
@@ -219,7 +219,7 @@ function Component<T extends {}>(props: Props<T>) {
219
219
return <div />;
220
220
}
221
221
222
- var Component = function <T extends {}>(props : Props <T >) {
222
+ const Component = function <T extends {}>(props : Props <T >) {
223
223
return <div />;
224
224
};
225
225
@@ -229,7 +229,7 @@ function Component<T1, T2>(props: Props<T1, T2>) {
229
229
return <div />;
230
230
}
231
231
232
- var Component = function <T1 , T2 >(props : Props <T2 >) {
232
+ const Component = function <T1 , T2 >(props : Props <T2 >) {
233
233
return <div />;
234
234
};
235
235
0 commit comments