Co-authored-by: fisker Cheung <lionkay@gmail.com> Co-authored-by: fisker <lionkay@gmail.com>
674 B
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"),
},
];