Skip to content

Commit b706ee7

Browse files
committed
Style changes
1 parent ff4cc76 commit b706ee7

File tree

3 files changed

+44
-51
lines changed

3 files changed

+44
-51
lines changed

configs/recommended.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = Object.assign({}, all, {
66
languageOptions: all.languageOptions,
77
rules: {
88
'react/display-name': 2,
9-
'react/forward-ref-uses-ref': 2,
109
'react/jsx-key': 2,
1110
'react/jsx-no-comment-textnodes': 2,
1211
'react/jsx-no-duplicate-props': 2,

lib/rules/forward-ref-uses-ref.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ const getMessageData = require('../util/message');
1414
// ------------------------------------------------------------------------------
1515

1616
const messages = {
17-
missingRefParameter:
18-
'forwardRef is used with this component but no ref parameter is set',
17+
missingRefParameter: 'forwardRef is used with this component but no ref parameter is set',
1918
addRefParameter: 'Add a ref parameter',
2019
removeForwardRef: 'Remove forwardRef wrapper',
2120
};
@@ -25,7 +24,7 @@ module.exports = {
2524
docs: {
2625
description: 'Require all forwardRef components include a ref parameter',
2726
category: 'Possible Errors',
28-
recommended: true,
27+
recommended: false,
2928
url: docsUrl('forward-ref-uses-ref'),
3029
},
3130
messages,
@@ -52,8 +51,7 @@ module.exports = {
5251
return (
5352
node.type === 'CallExpression'
5453
&& (isForwardRefIdentifier(node.callee)
55-
|| (node.callee.type === 'MemberExpression'
56-
&& isForwardRefIdentifier(node.callee.property)))
54+
|| (node.callee.type === 'MemberExpression' && isForwardRefIdentifier(node.callee.property)))
5755
);
5856
}
5957

tests/lib/rules/forward-ref-uses-ref.js

+41-45
Original file line numberDiff line numberDiff line change
@@ -30,68 +30,68 @@ const tests = {
3030
code: `
3131
import { forwardRef } from 'react'
3232
forwardRef((props, ref) => {
33-
return null
34-
})
33+
return null;
34+
});
3535
`,
3636
},
3737
{
3838
code: `
3939
import { forwardRef } from 'react'
40-
forwardRef((props, ref) => null)
40+
forwardRef((props, ref) => null);
4141
`,
4242
},
4343
{
4444
code: `
4545
import { forwardRef } from 'react'
4646
forwardRef(function (props, ref) {
47-
return null
48-
})
47+
return null;
48+
});
4949
`,
5050
},
5151
{
5252
code: `
5353
import { forwardRef } from 'react'
5454
forwardRef(function Component(props, ref) {
55-
return null
56-
})
55+
return null;
56+
});
5757
`,
5858
},
5959
{
6060
code: `
6161
import * as React from 'react'
6262
React.forwardRef((props, ref) => {
63-
return null
64-
})
63+
return null;
64+
});
6565
`,
6666
},
6767
{
6868
code: `
6969
import * as React from 'react'
70-
React.forwardRef((props, ref) => null)
70+
React.forwardRef((props, ref) => null);
7171
`,
7272
},
7373
{
7474
code: `
7575
import * as React from 'react'
7676
React.forwardRef(function (props, ref) {
77-
return null
78-
})
77+
return null;
78+
});
7979
`,
8080
},
8181
{
8282
code: `
8383
import * as React from 'react'
8484
React.forwardRef(function Component(props, ref) {
85-
return null
86-
})
85+
return null;
86+
});
8787
`,
8888
},
8989
{
9090
code: `
9191
import * as React from 'react'
9292
function Component(props) {
93-
return null
94-
}
93+
return null;
94+
};
9595
`,
9696
},
9797
]),
@@ -100,30 +100,29 @@ const tests = {
100100
code: `
101101
import { forwardRef } from 'react'
102102
forwardRef((props) => {
103-
return null
104-
})
103+
return null;
104+
});
105105
`,
106106
errors: [
107107
{
108-
message:
109-
'forwardRef is used with this component but no ref parameter is set',
108+
message: 'forwardRef is used with this component but no ref parameter is set',
110109
suggestions: [
111110
{
112111
messageId: 'addRefParameter',
113112
output: `
114113
import { forwardRef } from 'react'
115114
forwardRef((props, ref) => {
116-
return null
117-
})
115+
return null;
116+
});
118117
`,
119118
},
120119
{
121120
messageId: 'removeForwardRef',
122121
output: `
123122
import { forwardRef } from 'react'
124123
(props) => {
125-
return null
126-
}
124+
return null;
125+
};
127126
`,
128127
},
129128
],
@@ -133,25 +132,24 @@ const tests = {
133132
{
134133
code: `
135134
import * as React from 'react'
136-
React.forwardRef((props) => null)
135+
React.forwardRef((props) => null);
137136
`,
138137
errors: [
139138
{
140-
message:
141-
'forwardRef is used with this component but no ref parameter is set',
139+
message: 'forwardRef is used with this component but no ref parameter is set',
142140
suggestions: [
143141
{
144142
messageId: 'addRefParameter',
145143
output: `
146144
import * as React from 'react'
147-
React.forwardRef((props, ref) => null)
145+
React.forwardRef((props, ref) => null);
148146
`,
149147
},
150148
{
151149
messageId: 'removeForwardRef',
152150
output: `
153151
import * as React from 'react'
154-
(props) => null
152+
(props) => null;
155153
`,
156154
},
157155
],
@@ -162,30 +160,29 @@ const tests = {
162160
code: `
163161
import { forwardRef } from 'react'
164162
forwardRef(function (props) {
165-
return null
166-
})
163+
return null;
164+
});
167165
`,
168166
errors: [
169167
{
170-
message:
171-
'forwardRef is used with this component but no ref parameter is set',
168+
message: 'forwardRef is used with this component but no ref parameter is set',
172169
suggestions: [
173170
{
174171
messageId: 'addRefParameter',
175172
output: `
176173
import { forwardRef } from 'react'
177174
forwardRef(function (props, ref) {
178-
return null
179-
})
175+
return null;
176+
});
180177
`,
181178
},
182179
{
183180
messageId: 'removeForwardRef',
184181
output: `
185182
import { forwardRef } from 'react'
186183
function (props) {
187-
return null
188-
}
184+
return null;
185+
};
189186
`,
190187
},
191188
],
@@ -196,30 +193,29 @@ const tests = {
196193
code: `
197194
import * as React from 'react'
198195
React.forwardRef(function Component(props) {
199-
return null
200-
})
196+
return null;
197+
});
201198
`,
202199
errors: [
203200
{
204-
message:
205-
'forwardRef is used with this component but no ref parameter is set',
201+
message: 'forwardRef is used with this component but no ref parameter is set',
206202
suggestions: [
207203
{
208204
messageId: 'addRefParameter',
209205
output: `
210206
import * as React from 'react'
211207
React.forwardRef(function Component(props, ref) {
212-
return null
213-
})
208+
return null;
209+
});
214210
`,
215211
},
216212
{
217213
messageId: 'removeForwardRef',
218214
output: `
219215
import * as React from 'react'
220216
function Component(props) {
221-
return null
222-
}
217+
return null;
218+
};
223219
`,
224220
},
225221
],

0 commit comments

Comments
 (0)