From cd9bfb6d66df1c41fdda4d446e1d007dcc1b2a84 Mon Sep 17 00:00:00 2001 From: Matthias Giger Date: Sat, 27 Apr 2024 09:50:44 +0200 Subject: [PATCH] fix(parse): also extend file based object configurations release-npm --- package.json | 2 +- parse.ts | 5 ----- test/basic.test.ts | 6 +++++- test/fixture/file/configuration.ts | 10 ++++++++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 17a96da..aa0c505 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "format": "bun biome format . --write", "postinstall": "bun index.ts", "lint": "bun biome lint .", - "types": "tsc --noEmit" + "types": "tsc" }, "dependencies": { "avait": "^1.0.0", diff --git a/parse.ts b/parse.ts index 819d665..0706d7e 100644 --- a/parse.ts +++ b/parse.ts @@ -2,7 +2,6 @@ import { existsSync } from 'node:fs' import { join } from 'node:path' import { it } from 'avait' import { merge } from 'ts-deepmerge' -import { state } from './state' import type { Configuration, Options } from './types' const isExtension = async (value: string) => { @@ -57,10 +56,6 @@ export async function parse(value: Options, configuration: Configuration['config return configuration.createFile() } - if (typeof value === 'object' && state.language !== 'json') { - return configuration.createFile(value) - } - // biome-ignore lint/style/noParameterAssign: Easier in this case. value = extendTemplate(value, configuration) diff --git a/test/basic.test.ts b/test/basic.test.ts index f8cbde9..6637465 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -17,7 +17,7 @@ test('Adds configuration files for basic package setup.', () => { expect(existsSync(join(fixturePath, 'LICENSE.md'))).toBe(true) }) -test('Adds configuration files for basic file setup.', () => { +test('Adds configuration files for basic file setup.', async () => { const fixturePath = './test/fixture/file' execSync('bun ./../../../index.ts', { @@ -26,6 +26,10 @@ test('Adds configuration files for basic file setup.', () => { }) expect(existsSync(join(fixturePath, 'prettier.config.js'))).toBe(true) + expect(existsSync(join(fixturePath, 'playwright.config.ts'))).toBe(true) + expect(existsSync(join(fixturePath, 'biome.json'))).toBe(true) + + expect(await Bun.file(join(fixturePath, 'biome.json')).text()).not.toContain('recommended') }) test('Also parses JavaScript configuration.', async () => { diff --git a/test/fixture/file/configuration.ts b/test/fixture/file/configuration.ts index c0d347a..15c3343 100644 --- a/test/fixture/file/configuration.ts +++ b/test/fixture/file/configuration.ts @@ -16,3 +16,13 @@ export const playwright = { reuseExistingServer: !process.env.CI, }, } + +export const biome = { + extends: 'recommended', + linter: { + ignore: ['public'], + }, + formatter: { + ignore: ['public'], + }, +}