2023-03-13 09:17:24 +08:00
|
|
|
import * as prettier from "../../../../src/index.js";
|
2023-02-23 22:15:18 +09:00
|
|
|
|
|
|
|
|
prettier.format("foo ( );", { semi: false });
|
|
|
|
|
prettier.check("foo ( );", { semi: false });
|
|
|
|
|
prettier.formatWithCursor(" 1", { cursorOffset: 2 });
|
|
|
|
|
prettier.resolveConfig("path/to/somewhere").then((options) => {
|
|
|
|
|
if (options !== null) {
|
|
|
|
|
prettier.format("hello world", options);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
prettier.getFileInfo("./tsconfig.json").then((result) => {
|
|
|
|
|
if (result.inferredParser !== "json") {
|
|
|
|
|
throw new Error("Bad parser");
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-01-07 16:53:18 +03:00
|
|
|
prettier.getFileInfo("path/to/some/file", { plugins: ["my-plugin"] });
|
2023-02-23 22:15:18 +09:00
|
|
|
// @ts-expect-error
|
|
|
|
|
prettier.resolveConfig();
|
|
|
|
|
prettier.resolveConfigFile().then((filePath) => {
|
|
|
|
|
if (filePath !== null) {
|
|
|
|
|
prettier.resolveConfig(filePath);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
prettier.resolveConfigFile("/path").then((filePath) => {
|
|
|
|
|
if (filePath !== null) {
|
|
|
|
|
prettier.resolveConfig(filePath);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
prettier.clearConfigCache();
|
|
|
|
|
prettier.getSupportInfo();
|
2024-01-07 16:53:18 +03:00
|
|
|
prettier.getSupportInfo({ showDeprecated: true, plugins: ["my-plugin"] });
|
2023-02-23 22:15:18 +09:00
|
|
|
|
|
|
|
|
prettier.doc.builders.trim;
|
|
|
|
|
prettier.doc.builders.trim.type;
|
|
|
|
|
prettier.doc.builders.cursor;
|
|
|
|
|
prettier.doc.builders.cursor.type;
|
|
|
|
|
prettier.doc.builders.cursor.placeholder;
|
|
|
|
|
|
|
|
|
|
prettier.format("singleAttributePerLine is available", {
|
|
|
|
|
singleAttributePerLine: true,
|
|
|
|
|
});
|