Skip to content

Commit 373167c

Browse files
committed
[Tests] button-has-type: add passing test
Closes jsx-eslint/jsx-ast-utils#125
1 parent 14e315a commit 373167c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/lib/rules/button-has-type.js

+25
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,31 @@ ruleTester.run('button-has-type', rule, {
7373
},
7474
},
7575
},
76+
{
77+
code: `
78+
function MyComponent(): ReactElement {
79+
const buttonProps: (Required<Attributes> & ButtonHTMLAttributes<HTMLButtonElement>)[] = [
80+
{
81+
children: 'test',
82+
key: 'test',
83+
onClick: (): void => {
84+
return;
85+
},
86+
},
87+
];
88+
89+
return <>
90+
{
91+
buttonProps.map(
92+
({ key, ...props }: Required<Attributes> & ButtonHTMLAttributes<HTMLButtonElement>): ReactElement =>
93+
<button key={key} type="button" {...props} />
94+
)
95+
}
96+
</>;
97+
}
98+
`,
99+
features: ['fragment', 'types'],
100+
},
76101
]),
77102
invalid: parsers.all([
78103
{

0 commit comments

Comments
 (0)