Skip to content

Commit 66b3635

Browse files
committed
Add test for adding parens
1 parent 40e8658 commit 66b3635

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ const tests = {
9494
};
9595
`,
9696
},
97+
{
98+
code: `
99+
import * as React from 'react'
100+
(props) => null;
101+
`,
102+
},
97103
]),
98104
invalid: parsers.all([
99105
{
@@ -129,6 +135,39 @@ const tests = {
129135
},
130136
],
131137
},
138+
{
139+
code: `
140+
import { forwardRef } from 'react'
141+
forwardRef(props => {
142+
return null;
143+
});
144+
`,
145+
errors: [
146+
{
147+
message: 'forwardRef is used with this component but no ref parameter is set',
148+
suggestions: [
149+
{
150+
messageId: 'addRefParameter',
151+
output: `
152+
import { forwardRef } from 'react'
153+
forwardRef((props, ref) => {
154+
return null;
155+
});
156+
`,
157+
},
158+
{
159+
messageId: 'removeForwardRef',
160+
output: `
161+
import { forwardRef } from 'react'
162+
props => {
163+
return null;
164+
};
165+
`,
166+
},
167+
],
168+
},
169+
],
170+
},
132171
{
133172
code: `
134173
import * as React from 'react'

0 commit comments

Comments
 (0)