diff --git a/packages/eslint-plugin-antfu/src/rules/top-level-function.test.ts b/packages/eslint-plugin-antfu/src/rules/top-level-function.test.ts index e975e45..06c671b 100644 --- a/packages/eslint-plugin-antfu/src/rules/top-level-function.test.ts +++ b/packages/eslint-plugin-antfu/src/rules/top-level-function.test.ts @@ -26,7 +26,7 @@ const invalids = [ ], [ 'const foo = (as: string, bar: number): Omit => as + bar', - 'function foo (as: string, bar: number): Omit { return as + bar }', + 'function foo (as: string, bar: number): Omit {\n return as + bar\n}', ], [ 'export const foo = () => {}', @@ -34,11 +34,11 @@ const invalids = [ ], [ 'export const foo = () => ({})', - 'export function foo () { return {} }', + 'export function foo () {\n return {}\n}', ], [ 'export const foo = async () => ({})', - 'export async function foo () { return {} }', + 'export async function foo () {\n return {}\n}', ], ] diff --git a/packages/eslint-plugin-antfu/src/rules/top-level-function.ts b/packages/eslint-plugin-antfu/src/rules/top-level-function.ts index 0986f4a..601c1fc 100644 --- a/packages/eslint-plugin-antfu/src/rules/top-level-function.ts +++ b/packages/eslint-plugin-antfu/src/rules/top-level-function.ts @@ -60,7 +60,7 @@ export default createEslintRule({ : '' const textBody = body.type === 'BlockStatement' ? code.slice(body.range[0], body.range[1]) - : `{ return ${code.slice(body.range[0], body.range[1])} }` + : `{\n return ${code.slice(body.range[0], body.range[1])}\n}` const textGeneric = arrowFn.typeParameters ? code.slice(arrowFn.typeParameters.range[0], arrowFn.typeParameters.range[1]) : ''