Skip to content

Commit

Permalink
[Tests] failing tests for #3828
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb authored and golopot committed Sep 30, 2024
1 parent 1f95a24 commit 4abcf14
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rules/destructuring-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ module.exports = {
if (!propsRefs) {
return;
}

// Skip if props is used elsewhere
if (propsRefs.length > 1) {
return;
Expand Down
37 changes: 36 additions & 1 deletion tests/lib/rules/destructuring-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,41 @@ ${' '}
`,
features: ['ts', 'no-babel'],
},
] : []
] : [],
{
code: `
type Props = { text: string };
export const MyComponent: React.FC<Props> = (props) => {
type MyType = typeof props.text;
return <div>{props.text as MyType}</div>;
};
`,
options: ['always', { destructureInSignature: 'always' }],
features: ['types'],
errors: [
{
messageId: 'useDestructAssignment',
data: { type: 'props' },
},
],
},
{
code: `
type Props = { text: string };
export const MyOtherComponent: React.FC<Props> = (props) => {
const { text } = props;
type MyType = typeof props.text;
return <div>{text as MyType}</div>;
};
`,
options: ['always', { destructureInSignature: 'always' }],
features: ['types'],
errors: [
{
messageId: 'destructureInSignature',
data: { type: 'props' },
},
],
}
)),
});

0 comments on commit 4abcf14

Please sign in to comment.