Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/readonly-detect-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/format": patch
---

Accept readonly arrays in the `order` option of `detect`.
2 changes: 1 addition & 1 deletion src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DetectOptions {
* The order of formatters to check for.
* @default ["dprint", "deno", "oxfmt", "biome", "prettier"] // from `defaultDetectOrder`
*/
order?: FormatterName[];
order?: readonly FormatterName[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will break mutable arrays tho, in case we need to filter later again

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both are OK:

type Formatter = "dprint" | "deno" | "oxfmt" | "biome" | "prettier";

declare function test(options: { formatters?: readonly Formatter[] }): void;

declare const ro: readonly Formatter[];
declare const mutable: Formatter[];

test({
  formatters: ro, // ok
});
test({
  formatters: mutable, // ok
});

Internally we can always make a copy if needed, we shouldn't mutate the input array anyway.

}

/**
Expand Down
Loading