From 6b9478e70e2dd0a36d756c775014624b0e7baf17 Mon Sep 17 00:00:00 2001 From: Daniel Melanson <30221758+daniel-melanson@users.noreply.github.com> Date: Sat, 30 Sep 2023 12:17:08 -0400 Subject: [PATCH] refactor: use default literal instead default variable --- src/cli/config/init.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cli/config/init.ts b/src/cli/config/init.ts index 88df5853a5..83bd7d1da3 100644 --- a/src/cli/config/init.ts +++ b/src/cli/config/init.ts @@ -108,14 +108,15 @@ export const run: CliCommand = async (args: CliCommandArgs /* , logger: Logger * body = JSON.stringify({ ...pkgJson, jest: jestConfig }, undefined, ' ') } else { // js config - const usesModules = pkgJson.type === 'module' - const content = [] if (!jestPreset) { content.push(`${preset.jsImport('tsjPreset')};`, '') } content.push(`/** @type {import('ts-jest').JestConfigWithTsJest} */`) - content.push(usesModules ? 'const jestConfig = {' : 'module.exports = {') + + const usesModules = pkgJson.type === 'module' + content.push(usesModules ? 'export default {' : 'module.exports = {') + if (jestPreset) { content.push(` preset: '${preset.name}',`) } else { @@ -133,10 +134,6 @@ export const run: CliCommand = async (args: CliCommandArgs /* , logger: Logger * } content.push('};') - if (usesModules) { - content.push('\nexport default jestConfig;') - } - // join all together body = content.join('\n') }