Skip to content

Commit dd0663f

Browse files
authored
fix: biome JS API v3 bug (#1200)
* fix: biome JS API v3 bug * chore: add changeset
1 parent 5664487 commit dd0663f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.changeset/brown-vans-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
fix Biome JS API v3 bug

packages/cli/src/cli/loaders/formatters/biome.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "path";
22
import fs from "fs/promises";
33
import { Biome, Distribution } from "@biomejs/js-api";
4+
import { parse as parseJsonc } from "jsonc-parser";
45
import { ILoader } from "../_types";
56
import { createBaseFormatterLoader } from "./_base";
67

@@ -70,8 +71,15 @@ async function formatDataWithBiome(
7071
if (configPath) {
7172
const configContent = await fs.readFile(configPath, "utf-8");
7273
try {
73-
const config = JSON.parse(configContent);
74-
biome.applyConfiguration(projectKey, config);
74+
// Parse JSONC (JSON with comments) properly using jsonc-parser
75+
const config = parseJsonc(configContent);
76+
77+
// WORKAROUND: Biome JS API v3 has a bug where applying the full config
78+
// causes formatter settings to be ignored. Apply only relevant sections.
79+
// Specifically, exclude $schema, vcs, and files from the config.
80+
const { $schema, vcs, files, ...relevantConfig } = config;
81+
82+
biome.applyConfiguration(projectKey, relevantConfig);
7583
} catch (parseError) {
7684
throw new Error(
7785
`Invalid Biome configuration in ${configPath}: ${parseError instanceof Error ? parseError.message : "JSON parse error"}`,

0 commit comments

Comments
 (0)