Skip to content

Commit a93cae7

Browse files
committed
[Tests] destructuring-assignment: Add more modern context cases
1 parent 2e3f1ef commit a93cae7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/lib/rules/destructuring-assignment.js

+24
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ ruleTester.run('destructuring-assignment', rule, {
374374
code: `
375375
import { useContext } from 'react';
376376
377+
const MyComponent = (props) => {
378+
const {foo} = useContext(aContext);
379+
return <div>{foo}</div>
380+
};
381+
`,
382+
options: ['always'],
383+
settings: { react: { version: '16.9.0' } },
384+
},
385+
{
386+
code: `
387+
import { useContext } from 'react';
388+
377389
const MyComponent = (props) => {
378390
const foo = useContext(aContext);
379391
return <div>{foo.test}</div>
@@ -382,6 +394,18 @@ ruleTester.run('destructuring-assignment', rule, {
382394
options: ['never'],
383395
settings: { react: { version: '16.9.0' } },
384396
},
397+
{
398+
code: `
399+
import { useContext } from 'react';
400+
401+
const MyComponent = (props) => {
402+
const foo = useContext(aContext);
403+
return <div>{foo.test}</div>
404+
};
405+
`,
406+
options: ['always'],
407+
settings: { react: { version: '16.9.0' } },
408+
},
385409
{
386410
code: `
387411
const MyComponent = (props) => {

0 commit comments

Comments
 (0)