@biomejs/js-api
Version:
JavaScript APIs for the Biome package
117 lines • 3.78 kB
TypeScript
import type { Configuration, Diagnostic, FixFileMode, OpenProjectResult, ProjectKey } from "@biomejs/wasm-nodejs";
import { Distribution } from "./wasm";
export type { Diagnostic, Configuration };
export { Distribution };
export interface FormatContentDebugOptions extends FormatContentOptions {
/**
* If `true`, you'll be able to inspect the IR of the formatter
*/
debug: boolean;
}
export interface FormatContentOptions {
/**
* A virtual path of the file. You should add the extension,
* so Biome knows how to parse the content
*/
filePath: string;
/**
* The range where to format the content
*/
range?: [number, number];
}
export interface FormatResult {
/**
* The new formatted content
*/
content: string;
/**
* A series of errors encountered while executing an operation
*/
diagnostics: Diagnostic[];
}
export interface FormatDebugResult extends FormatResult {
/**
* The IR emitted by the formatter
*/
ir: string;
}
export interface LintContentOptions {
/**
* A virtual path of the file. You should add the extension,
* so Biome knows how to parse the content
*/
filePath: string;
fixFileMode?: FixFileMode;
}
export interface LintResult {
content: string;
diagnostics: Diagnostic[];
}
export interface BiomeCreate {
distribution: Distribution;
}
export interface PrintDiagnosticsOptions {
/**
* The name of the file to print diagnostics for
*/
filePath: string;
/**
* The content of the file the diagnostics were emitted for
*/
fileSource: string;
/**
* Whether to print the diagnostics in verbose mode
*/
verbose?: boolean;
}
export declare class Biome {
private readonly module;
private readonly workspace;
private constructor();
/**
* It creates a new instance of the class {Biome}.
*/
static create(options: BiomeCreate): Promise<Biome>;
/**
* Stop this instance of Biome
*
* After calling `shutdown()` on this object, it should be considered
* unusable as calling any method on it will fail
*/
shutdown(): void;
/**
* Allows to apply a custom configuration.
*
* If fails when the configuration is incorrect.
*
* @param {ProjectKey} projectKey The identifier of the project
* @param {Configuration} configuration
*/
applyConfiguration(projectKey: ProjectKey, configuration: Configuration): void;
/**
* Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects.
*
* @param {string} [path]
*/
openProject(path?: string): OpenProjectResult;
private tryCatchWrapper;
private withFile;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentOptions): FormatResult;
formatContent(projectKey: ProjectKey, content: string, options: FormatContentDebugOptions): FormatDebugResult;
/**
* Lint the content of a file.
*
* @param {ProjectKey} projectKey The identifier of the project
* @param {String} content The content to lint
* @param {LintContentOptions} options Options needed when linting some content
*/
lintContent(projectKey: ProjectKey, content: string, { filePath, fixFileMode }: LintContentOptions): LintResult;
/**
* Print a list of diagnostics to an HTML string.
*
* @param {Diagnostic[]} diagnostics The list of diagnostics to print
* @param {PrintDiagnosticsOptions} options Options needed for printing the diagnostics
*/
printDiagnostics(diagnostics: Diagnostic[], options: PrintDiagnosticsOptions): string;
}
//# sourceMappingURL=index.d.ts.map