Skip to content
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

Are Array Prototype Methods Supported? #540

Open
matthewwithanm opened this issue Feb 10, 2023 · 1 comment
Open

Are Array Prototype Methods Supported? #540

matthewwithanm opened this issue Feb 10, 2023 · 1 comment

Comments

@matthewwithanm
Copy link

Hey! I'm very confused about the status of Array prototype methods. There are a bunch of open issues about them with conflicting information about how/whether these are meant to be supported. The README specifically calls out using Array.prototype.push(), but I can't seem to get errors for .flatMap(), or .flat().

I was going to comment on the recently opened #539 about .at(), but after some troubleshooting it seems like maybe that's a separate issue? For x.flat(), the check is reaching this code but not matching because objectName is "x":

const failingRule = rules.find(
  (rule) =>
    rule.object === objectName &&
    (rule.property == null || rule.property === propertyName)
);

For [].flat(), it hits this branch but doesn't match because protoChainId is ".flat", instead of the rule's "Array.flat":

const protoChain =
  firstObj === "window" || firstObj === "globalThis"
    ? rawProtoChain.slice(1)
    : rawProtoChain;
const protoChainId = protoChain.join(".");
const failingRule = rules.find(
  (rule) => rule.protoChainId === protoChainId
);

.at() (#539) seems to have a different problem in that there's no rule for it in the list.

What's the expected behavior for these two cases? Should they cause failures? Is this a bug, or is the README just out of date?

Thanks for the help!

@koddsson
Copy link
Contributor

Is this still not working in the latest version (4.1.4)? I think I've fixed it there. If not still working, can you provide a small reproduction case that we can take a look at?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants