Skip to content

Commit ce26120

Browse files
authored
tweak: make it so disabling uv or ruff fmters disables both (#21921)
1 parent d2d5d84 commit ce26120

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

packages/opencode/src/format/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ export namespace Format {
5151
formatters[item.name] = item
5252
}
5353
for (const [name, item] of Object.entries(cfg.formatter ?? {})) {
54+
// Ruff and uv are both the same formatter, so disabling either should disable both.
55+
if (["ruff", "uv"].includes(name) && (cfg.formatter?.ruff?.disabled || cfg.formatter?.uv?.disabled)) {
56+
// TODO combine formatters so shared backends like Ruff/uv don't need linked disable handling here.
57+
delete formatters.ruff
58+
delete formatters.uv
59+
continue
60+
}
5461
if (item.disabled) {
5562
delete formatters[name]
5663
continue

packages/opencode/test/format/format.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,46 @@ describe("Format", () => {
6464
),
6565
)
6666

67+
it.live("status() excludes uv when ruff is disabled", () =>
68+
provideTmpdirInstance(
69+
() =>
70+
Format.Service.use((fmt) =>
71+
Effect.gen(function* () {
72+
const statuses = yield* fmt.status()
73+
expect(statuses.find((item) => item.name === "ruff")).toBeUndefined()
74+
expect(statuses.find((item) => item.name === "uv")).toBeUndefined()
75+
}),
76+
),
77+
{
78+
config: {
79+
formatter: {
80+
ruff: { disabled: true },
81+
},
82+
},
83+
},
84+
),
85+
)
86+
87+
it.live("status() excludes ruff when uv is disabled", () =>
88+
provideTmpdirInstance(
89+
() =>
90+
Format.Service.use((fmt) =>
91+
Effect.gen(function* () {
92+
const statuses = yield* fmt.status()
93+
expect(statuses.find((item) => item.name === "ruff")).toBeUndefined()
94+
expect(statuses.find((item) => item.name === "uv")).toBeUndefined()
95+
}),
96+
),
97+
{
98+
config: {
99+
formatter: {
100+
uv: { disabled: true },
101+
},
102+
},
103+
},
104+
),
105+
)
106+
67107
it.live("service initializes without error", () => provideTmpdirInstance(() => Format.Service.use(() => Effect.void)))
68108

69109
it.live("status() initializes formatter state per directory", () =>

0 commit comments

Comments
 (0)