tweak: make it so disabling uv or ruff fmters disables both (#21921)
This commit is contained in:
parent
d2d5d84d1e
commit
ce26120205
2 changed files with 47 additions and 0 deletions
|
|
@ -51,6 +51,13 @@ export namespace Format {
|
||||||
formatters[item.name] = item
|
formatters[item.name] = item
|
||||||
}
|
}
|
||||||
for (const [name, item] of Object.entries(cfg.formatter ?? {})) {
|
for (const [name, item] of Object.entries(cfg.formatter ?? {})) {
|
||||||
|
// Ruff and uv are both the same formatter, so disabling either should disable both.
|
||||||
|
if (["ruff", "uv"].includes(name) && (cfg.formatter?.ruff?.disabled || cfg.formatter?.uv?.disabled)) {
|
||||||
|
// TODO combine formatters so shared backends like Ruff/uv don't need linked disable handling here.
|
||||||
|
delete formatters.ruff
|
||||||
|
delete formatters.uv
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (item.disabled) {
|
if (item.disabled) {
|
||||||
delete formatters[name]
|
delete formatters[name]
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,46 @@ describe("Format", () => {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
it.live("status() excludes uv when ruff is disabled", () =>
|
||||||
|
provideTmpdirInstance(
|
||||||
|
() =>
|
||||||
|
Format.Service.use((fmt) =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const statuses = yield* fmt.status()
|
||||||
|
expect(statuses.find((item) => item.name === "ruff")).toBeUndefined()
|
||||||
|
expect(statuses.find((item) => item.name === "uv")).toBeUndefined()
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
config: {
|
||||||
|
formatter: {
|
||||||
|
ruff: { disabled: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
it.live("status() excludes ruff when uv is disabled", () =>
|
||||||
|
provideTmpdirInstance(
|
||||||
|
() =>
|
||||||
|
Format.Service.use((fmt) =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const statuses = yield* fmt.status()
|
||||||
|
expect(statuses.find((item) => item.name === "ruff")).toBeUndefined()
|
||||||
|
expect(statuses.find((item) => item.name === "uv")).toBeUndefined()
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
config: {
|
||||||
|
formatter: {
|
||||||
|
uv: { disabled: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
it.live("service initializes without error", () => provideTmpdirInstance(() => Format.Service.use(() => Effect.void)))
|
it.live("service initializes without error", () => provideTmpdirInstance(() => Format.Service.use(() => Effect.void)))
|
||||||
|
|
||||||
it.live("status() initializes formatter state per directory", () =>
|
it.live("status() initializes formatter state per directory", () =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue