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: handle missing case for function overloads #31

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/prefer-arrow-functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ const invalidAndHasSingleReturn = [
output:
'var withLoop = async () => async () => { for (i = 0; i < 5; i++) {}}',
},

// function overloading - don't mislabel as overload
// export { x as y }; has node.declaration === null - regression test for this case
{
code: 'export { _foo as bar }; export async function baz() { return false; }',
mitchell-merry marked this conversation as resolved.
Show resolved Hide resolved
output: 'export { _foo as bar }; export const baz = async () => false;',
},
];

const invalidAndHasSingleReturnWithMultipleMatches = [
Expand Down
4 changes: 2 additions & 2 deletions src/prefer-arrow-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
export default {
meta: {
docs: {
category: 'emcascript6',
category: 'ecmascript6',
Copy link
Contributor

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

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 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

description: 'prefer arrow functions',
recommended: false,
},
Expand Down Expand Up @@ -110,7 +110,7 @@ export default {
if (previousNode.type === 'TSDeclareFunction') return true;
if (
previousNode.type === 'ExportNamedDeclaration' &&
previousNode.declaration.type === 'TSDeclareFunction'
previousNode.declaration?.type === 'TSDeclareFunction'
)
return true;

Expand Down
Loading