-
-
Notifications
You must be signed in to change notification settings - Fork 11
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: handle missing case for function overloads #31
Conversation
40c3312
to
e75b139
Compare
Not really sure why the build is suddenly failing, maybe you know:
Definitely seems unrelated to my change. Also, the version in package.json is 3.3.0. |
Thanks @mitchell-merry, are there any other test scenarios you can think of that would be worthwhile adding as well? Not specifically related to this bug, but to help us discover other potential ones. |
/cc @renato-bohler |
Not sure, sorry. I ran this in quite a large codebase and found no issues besides this when I ran. (I'm fairly new to custom eslint plugins, so not familiar with the edge cases) Is there a reason why the |
I suppose the |
if you merge main I've bumped that to 18
By this I mean, can you think of other variations of valid syntax which could be relevant ( Same question to @renato-bohler. The answer might be no by the way, I'm just raising it as thinking of these variations can find potential bugs really quickly that's all. |
e75b139
to
011c98a
Compare
done
No, not at the moment. |
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.
Huh, didn't run into this case, my bad 😅
We could also add this test to alwaysValid
to verify that overloaded functions are still untransformed when we have export { foo }
before it:
export { foo }; export function bar(val: number): void; export function bar(val: string | number): void {}
But the change makes sense and works for me. Thanks for catching this!
@@ -9,7 +9,7 @@ import { | |||
export default { | |||
meta: { | |||
docs: { | |||
category: 'emcascript6', | |||
category: 'ecmascript6', |
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.
Unsure of the impact of this change
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.
I don't even see category
as a field in the docs: https://eslint.org/docs/latest/extend/custom-rules#rule-structure so I'm not sure either. But I have to imagine the impact would be minimal
If it's possible, could we get this PR in so as to fix the latest version of the package? Thank you |
Description (What)
3.3.1 throws an error on this case:
because when it checks the
baz()
line, it gets the previous node, and assumes thatnode.declaration
is non-null. In this case (export { _foo as bar };
), it is. We can just return false in this case since it is not an overload.The error:
Justification (Why)
3.3.1 currently breaks when a module like above exists in a codebase.
How Can This Be Tested?
I added a unit test.
You can run eslint against a file with the contents above and confirm that it breaks before this change, and works after.