Files
test-repo/changelog_unreleased/api/17331.md
T
2025-04-14 09:15:43 +08:00

674 B

Add isSupported function support for languages API (#17331 by @JounQin)

Previously, languages API for custom plugin only supported to infer parser based on the file basename or extension.

Prettier main added isSupported: (file: string) => boolean function to allow plugin check if file is supported based on the full path (eg: files in a specific directory), the file parameter could be a normal path or a url string like file:///C:/test.txt.

If no isSupported provided, it just behaviors the same way as before.

export const languages = [
  {
    name: "foo",
    parsers: ["foo"],
    isSupported: (file) => file.includes(".foo"),
  },
];