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

Fix the shouldUseGitHubOverride logic for ESM imports #1430

Merged
merged 1 commit into from Apr 16, 2024

Conversation

mgol
Copy link
Contributor

@mgol mgol commented Mar 13, 2024

The shouldUseGitHubOverride util is called with Module._load parameters. So far, it assumed it will get a string request and a NodeModule parent parameters. However, for ESM imports parent is actually undefined.

Account for this in code by making parent an optional argument; add a test.

Fixes gh-1421

cc @fbartho

The `shouldUseGitHubOverride` util is called with `Module._load` parameters.
So far, it assumed it will get a string `request` and a `NodeModule` `parent`
parameters. However, for ESM imports `parent` is actually `undefined`.

Account for this in code by making `parent` an optional argument; add a test.

Fixes dangergh-1421
Copy link
Member

@fbartho fbartho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Matches what we talked about!


it("ignores modules without a parent", () => {
const module = "./peril"
const parent: any = undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could avoid the type here - the following would work as well:

Suggested change
const parent: any = undefined
const parent = undefined

but I used what's more consistent with the other test cases.

Let me know if you'd like to drop this any.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine :+

@orta orta merged commit 09cf908 into danger:main Apr 16, 2024
2 checks passed
@mgol mgol deleted the module-github-override-fix branch April 16, 2024 12:22
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

Successfully merging this pull request may close these issues.

[BUG] prettier.resolveConfig fails due to faulty shouldUseGitHubOverride
3 participants