Skip to content

Commit

Permalink
fix: optional case for function overload previous node checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-merry committed Feb 26, 2024
1 parent 7d5dd71 commit e75b139
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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; }',
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',
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

0 comments on commit e75b139

Please sign in to comment.