-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support destructuring in harden-exports #2404
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the long delay... I like the better coverage, but would like to see a few tweaks. And I've retagged other good reviewers.
if (prop.value.type === 'Identifier') { | ||
exportNames.push(prop.value.name); | ||
} else if ( | ||
prop.value.type === 'AssignmentPattern' && | ||
prop.value.left.type === 'Identifier' | ||
) { | ||
exportNames.push(prop.value.left.name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing the recursive case in which prop.value.type
is itself an ObjectPattern or ArrayPattern (e.g., export const { wrapper: { propName } } = objWithWrapper;
and export const [{ wrapper: { propName: exportName } }] = [objWithWrapper];
). That was true before as well, but if we're making changes anyway then we ought to fix the gap.
(and likewise for the elements of an ArrayPattern below)
((statement.expression.arguments[0].type === 'Identifier' && | ||
statement.expression.arguments[0].name === exportName) || | ||
// @ts-expect-error XXX non-overlapping | ||
(statement.expression.arguments[0].type === 'ObjectPattern' && | ||
// @ts-expect-error XXX non-overlapping | ||
statement.expression.arguments[0].properties.some( | ||
prop => | ||
prop.value.type === 'Identifier' && | ||
prop.value.name === exportName, | ||
)) || | ||
// @ts-expect-error XXX non-overlapping | ||
(statement.expression.arguments[0].type === 'ArrayPattern' && | ||
// @ts-expect-error XXX non-overlapping | ||
statement.expression.arguments[0].elements.some( | ||
element => | ||
element && | ||
element.type === 'Identifier' && | ||
element.name === exportName, | ||
))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole block could really use some commentary/substructure/etc.
I agree with @gibson042's comments. I would like to see them addressed before I can approve or offer more suggestions. |
Closes: #XXXX
Refs: #XXXX
Description
Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Compatibility Considerations
Upgrade Considerations